Skip to content

Commit

Permalink
updating to the latest version of Entities
Browse files Browse the repository at this point in the history
  • Loading branch information
tbg10101 committed May 2, 2020
1 parent f6075f0 commit a48edb0
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 72 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"dependencies": {
"com.10101software.dots.hybridsimulation": "file:../../..",
"com.unity.entities": "0.9.1-preview.15",
"com.unity.entities": "0.10.0-preview.6",
"com.unity.ide.rider": "1.2.1",
"com.unity.render-pipelines.universal": "8.0.1",
"com.unity.ugui": "1.0.0",
Expand Down
20 changes: 10 additions & 10 deletions Runtime/Scripts/MonoBehaviours/WorldBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public T GetOrCreateSystem<T>(Type parent) where T : ComponentSystemBase {
return _world.GetOrCreateSystem<T>(parent);
}

public T GetOrCreateSystem<T>(ComponentSystemBase group) where T : ComponentSystemBase {
public T GetOrCreateSystem<T>(ComponentSystemGroup group) where T : ComponentSystemBase {
return _world.GetOrCreateSystem<T>(group);
}

public ComponentSystemBase GetOrCreateSystem(ComponentSystemBase group, Type systemType) {
public ComponentSystemBase GetOrCreateSystem(ComponentSystemGroup group, Type systemType) {
return _world.GetOrCreateSystem(group, systemType);
}

public ComponentSystemBase AddSystem(ComponentSystemBase group, ComponentSystemBase system) {
public ComponentSystemBase AddSystem(ComponentSystemGroup group, ComponentSystemBase system) {
return _world.AddSystem(group, system);
}
}
Expand Down Expand Up @@ -67,23 +67,23 @@ public T GetOrCreateSystem<T>(Type parent) where T : ComponentSystemBase {
return system;
}

public T GetOrCreateSystem<T>(ComponentSystemBase group) where T : ComponentSystemBase {
public T GetOrCreateSystem<T>(ComponentSystemGroup group) where T : ComponentSystemBase {
T system = _world.GetOrCreateSystem<T>();

AddSystemToGroup(group, system);

return system;
}

public ComponentSystemBase GetOrCreateSystem(ComponentSystemBase group, Type systemType) {
public ComponentSystemBase GetOrCreateSystem(ComponentSystemGroup group, Type systemType) {
ComponentSystemBase system = _world.GetOrCreateSystem(systemType);

AddSystemToGroup(group, system);

return system;
}

public ComponentSystemBase AddSystem(ComponentSystemBase group, ComponentSystemBase system) {
public ComponentSystemBase AddSystem(ComponentSystemGroup group, ComponentSystemBase system) {
_world.AddSystem(system);

AddSystemToGroup(group, system);
Expand All @@ -99,14 +99,14 @@ public void Dispose() {
_world.Dispose();
}

private void AddSystemToGroup(ComponentSystemBase group, ComponentSystemBase system) {
private void AddSystemToGroup(ComponentSystemGroup group, ComponentSystemBase system) {
switch (group) {
case ComponentSystemGroup csg:
csg.AddSystemToUpdateList(system);
break;
case IList<ComponentSystemBase> lcsg:
lcsg.Add(system);
break;
case ComponentSystemGroup csg:
csg.AddSystemToUpdateList(system);
break;
default:
throw new Exception("Group must be compatible.");
}
Expand Down
5 changes: 3 additions & 2 deletions Runtime/Scripts/Systems/Groups/ListComponentSystemGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
using UnityEngine;

namespace Software10101.DOTS.Systems.Groups {
[Obsolete("This was an experiment, probably won't keep it.")]
public abstract class ListComponentSystemGroup :
ComponentSystem,
ComponentSystemGroup,
IList<ComponentSystemBase>,
IReadOnlyList<ComponentSystemBase>,
IList {
Expand All @@ -23,6 +22,8 @@ public abstract class ListComponentSystemGroup :
public bool IsFixedSize => ((IList)_mutableSystemsList).IsFixedSize;
public bool IsReadOnly => ((ICollection<ComponentSystemBase>)_mutableSystemsList).IsReadOnly;

public override IEnumerable<ComponentSystemBase> Systems => _systems;

protected override void OnUpdate() {
if (_systemsListDirtyFlag) {
_systemsListDirtyFlag = false;
Expand Down
42 changes: 0 additions & 42 deletions Runtime/Scripts/Systems/Groups/NeverSortedComponentSystemGroup.cs

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion Runtime/Scripts/Systems/Groups/PresentationSystemGroup.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
namespace Software10101.DOTS.Systems.Groups {
internal sealed class PresentationSystemGroup : NeverSortedComponentSystemGroup { }
internal sealed class PresentationSystemGroup : ListComponentSystemGroup { }
}
2 changes: 1 addition & 1 deletion Runtime/Scripts/Systems/Groups/SimulationSystemGroup.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
namespace Software10101.DOTS.Systems.Groups {
internal sealed class SimulationSystemGroup : NeverSortedComponentSystemGroup { }
internal sealed class SimulationSystemGroup : ListComponentSystemGroup { }
}
9 changes: 0 additions & 9 deletions Runtime/Scripts/Utils/PlayerLoopUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ public static class PlayerLoopUtil {
private static readonly MethodInfo TriggerUpdateMethod = DummyWrapperType
.GetMethod("TriggerUpdate", BindingFlags.Public | BindingFlags.Instance);

private static readonly FieldInfo CurrentPlayerLoopField = typeof(ScriptBehaviourUpdateOrder)
.GetField("currentPlayerLoop", BindingFlags.Static | BindingFlags.NonPublic);

/// <summary>
/// Adds a system to the player loop in the same way that
/// <see cref="Unity.Entities.ScriptBehaviourUpdateOrder.UpdatePlayerLoop"/> does.
Expand Down Expand Up @@ -56,7 +53,6 @@ public static void AddSubSystem(Type parent, ComponentSystemBase system) {
currentPlayerLoop.subSystemList[i].subSystemList = newSubSystems;

PlayerLoop.SetPlayerLoop(currentPlayerLoop);
CurrentPlayerLoopField.SetValue(null, currentPlayerLoop);

return;
}
Expand Down Expand Up @@ -114,7 +110,6 @@ public static void RemoveSubSystem(Type parent, ComponentSystemBase system) {
currentPlayerLoop.subSystemList[i].subSystemList = newSubSystems;

PlayerLoop.SetPlayerLoop(currentPlayerLoop);
CurrentPlayerLoopField.SetValue(null, currentPlayerLoop);

return;
}
Expand Down Expand Up @@ -142,10 +137,6 @@ private static void ValidateReflectionComponents() {
throw new Exception("Could not find TriggerUpdate!");
}

if (CurrentPlayerLoopField == null) {
throw new Exception("Could not find currentPlayerLoop!");
}

if (DummyWrapperSystem == null) {
throw new Exception("Could not find m_System!");
}
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"name": "com.10101software.dots.hybridsimulation",
"description": "A framework for using FixedUpdate in a simulation world which is linked to a GameObject-based presentation layer.",
"version": "0.3.3",
"version": "0.4.0",
"unity": "2020.1",
"displayName": "DOTS Hybrid Simulation Worlds",
"dependencies": {
"com.unity.entities": "0.9.1-preview.15",
"com.unity.collections": "0.7.1-preview.3"
"com.unity.entities": "0.10.0-preview.6"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit a48edb0

Please sign in to comment.