diff --git a/Arch.SystemGroups/Arch.SystemGroups.asmdef b/Arch.SystemGroups/Arch.SystemGroups.asmdef
new file mode 100644
index 0000000..3af8ccb
--- /dev/null
+++ b/Arch.SystemGroups/Arch.SystemGroups.asmdef
@@ -0,0 +1,13 @@
+{
+ "name": "Arch.SystemGroups",
+ "references": [],
+ "includePlatforms": [],
+ "excludePlatforms": [],
+ "allowUnsafeCode": false,
+ "overrideReferences": false,
+ "precompiledReferences": [],
+ "autoReferenced": true,
+ "defineConstraints": [],
+ "versionDefines": [],
+ "noEngineReferences": false
+}
\ No newline at end of file
diff --git a/Arch.SystemGroups/Builder/ArchSystemsWorldBuilder.cs b/Arch.SystemGroups/Builder/ArchSystemsWorldBuilder.cs
index 17c244f..8a9c6b8 100644
--- a/Arch.SystemGroups/Builder/ArchSystemsWorldBuilder.cs
+++ b/Arch.SystemGroups/Builder/ArchSystemsWorldBuilder.cs
@@ -5,284 +5,289 @@
using Arch.SystemGroups.Throttling;
using UnityEngine.Pool;
-namespace Arch.SystemGroups;
-
-///
-/// The builder of systems attached to the Unity Player Loop
-///
-///
-public readonly struct ArchSystemsWorldBuilder
+namespace Arch.SystemGroups
{
- private struct GroupInfo
- {
- public Dictionary> Systems;
- public Dictionary> Edges;
- public List DisconnectedDependencies;
- }
-
- private readonly Dictionary _groupsInfo;
- private readonly Dictionary> _customGroups;
-
- private readonly IPlayerLoop _playerLoop;
-
- private readonly IFixedUpdateBasedSystemGroupThrottler _fixedUpdateBasedSystemGroupThrottler;
- private readonly IUpdateBasedSystemGroupThrottler _updateBasedSystemGroupThrottler;
- private readonly ISystemGroupExceptionHandler _exceptionHandler;
-
///
- /// Create a systems builder for the given world
+ /// The builder of systems attached to the Unity Player Loop
///
- /// ECS World (Normally "Arch.Core.World")
- /// Throttler for all Fixed Update based Systems
- /// Throttler for all Update based Systems
- /// Exception handler
- public ArchSystemsWorldBuilder(T world,
- IFixedUpdateBasedSystemGroupThrottler fixedUpdateBasedSystemGroupThrottler = null,
- IUpdateBasedSystemGroupThrottler updateBasedSystemGroupThrottler = null,
- ISystemGroupExceptionHandler exceptionHandler = null) : this(world,
- UnityPlayerLoop.Instance, fixedUpdateBasedSystemGroupThrottler, updateBasedSystemGroupThrottler,
- exceptionHandler)
+ ///
+ public readonly struct ArchSystemsWorldBuilder
{
- }
+ private struct GroupInfo
+ {
+ public Dictionary> Systems;
+ public Dictionary> Edges;
+ public List DisconnectedDependencies;
+ }
- internal ArchSystemsWorldBuilder(T world, IPlayerLoop playerLoop,
- IFixedUpdateBasedSystemGroupThrottler fixedUpdateBasedSystemGroupThrottler = null,
- IUpdateBasedSystemGroupThrottler updateBasedSystemGroupThrottler = null,
- ISystemGroupExceptionHandler exceptionHandler = null)
- {
- World = world;
- _playerLoop = playerLoop;
- _fixedUpdateBasedSystemGroupThrottler = fixedUpdateBasedSystemGroupThrottler;
- _updateBasedSystemGroupThrottler = updateBasedSystemGroupThrottler;
- _exceptionHandler = exceptionHandler;
-
- _groupsInfo = DictionaryPool.Get();
- _customGroups = DictionaryPool>.Get();
- }
+ private readonly Dictionary _groupsInfo;
+ private readonly Dictionary> _customGroups;
+
+ private readonly IPlayerLoop _playerLoop;
+
+ private readonly IFixedUpdateBasedSystemGroupThrottler _fixedUpdateBasedSystemGroupThrottler;
+ private readonly IUpdateBasedSystemGroupThrottler _updateBasedSystemGroupThrottler;
+ private readonly ISystemGroupExceptionHandler _exceptionHandler;
+
+ ///
+ /// Create a systems builder for the given world
+ ///
+ /// ECS World (Normally "Arch.Core.World")
+ /// Throttler for all Fixed Update based Systems
+ /// Throttler for all Update based Systems
+ /// Exception handler
+ public ArchSystemsWorldBuilder(T world,
+ IFixedUpdateBasedSystemGroupThrottler fixedUpdateBasedSystemGroupThrottler = null,
+ IUpdateBasedSystemGroupThrottler updateBasedSystemGroupThrottler = null,
+ ISystemGroupExceptionHandler exceptionHandler = null) : this(world,
+ UnityPlayerLoop.Instance, fixedUpdateBasedSystemGroupThrottler, updateBasedSystemGroupThrottler,
+ exceptionHandler)
+ {
+ }
- ///
- /// Current World
- ///
- public T World { get; }
+ internal ArchSystemsWorldBuilder(T world, IPlayerLoop playerLoop,
+ IFixedUpdateBasedSystemGroupThrottler fixedUpdateBasedSystemGroupThrottler = null,
+ IUpdateBasedSystemGroupThrottler updateBasedSystemGroupThrottler = null,
+ ISystemGroupExceptionHandler exceptionHandler = null)
+ {
+ World = world;
+ _playerLoop = playerLoop;
+ _fixedUpdateBasedSystemGroupThrottler = fixedUpdateBasedSystemGroupThrottler;
+ _updateBasedSystemGroupThrottler = updateBasedSystemGroupThrottler;
+ _exceptionHandler = exceptionHandler;
+
+ _groupsInfo = DictionaryPool.Get();
+ _customGroups = DictionaryPool>.Get();
+ }
- ///
- /// Creates Groups Automatically
- ///
- public ArchSystemsWorldBuilder TryCreateGroup(Type updateInGroupType,
- Action>> addToEdges,
- Action> validateDependencies,
- bool throttlingEnabled)
- where TGroup : CustomGroupBase, new()
- {
- if (_customGroups.ContainsKey(typeof(TGroup)))
- return this;
+ ///
+ /// Current World
+ ///
+ public T World { get; }
+
+ ///
+ /// Creates Groups Automatically
+ ///
+ public ArchSystemsWorldBuilder TryCreateGroup(Type updateInGroupType,
+ Action>> addToEdges,
+ Action> validateDependencies,
+ bool throttlingEnabled)
+ where TGroup : CustomGroupBase, new()
+ {
+ if (_customGroups.ContainsKey(typeof(TGroup)))
+ return this;
- var newGroup = new TGroup();
+ var newGroup = new TGroup();
- _customGroups[typeof(TGroup)] = newGroup;
+ _customGroups[typeof(TGroup)] = newGroup;
- return AddToGroup(new ExecutionNode(newGroup, throttlingEnabled), updateInGroupType, typeof(TGroup),
- addToEdges, validateDependencies);
- }
+ return AddToGroup(new ExecutionNode(newGroup, throttlingEnabled), updateInGroupType, typeof(TGroup),
+ addToEdges, validateDependencies);
+ }
- ///
- /// Registers a group that is not created automatically
- ///
- public void TryRegisterGroup(Type updateInGroupType, Action>> addToEdges,
- Action> validateDependencies,
- bool throttlingEnabled)
- where TGroup : CustomGroupBase
- {
- // Thr group should be injected in advance
- if (!_customGroups.TryGetValue(typeof(TGroup), out var customGroup))
- throw new GroupNotFoundException(typeof(TGroup));
+ ///
+ /// Registers a group that is not created automatically
+ ///
+ public void TryRegisterGroup(Type updateInGroupType, Action>> addToEdges,
+ Action> validateDependencies,
+ bool throttlingEnabled)
+ where TGroup : CustomGroupBase
+ {
+ // Thr group should be injected in advance
+ if (!_customGroups.TryGetValue(typeof(TGroup), out var customGroup))
+ throw new GroupNotFoundException(typeof(TGroup));
- AddToGroup(new ExecutionNode(customGroup, throttlingEnabled), updateInGroupType, typeof(TGroup),
- addToEdges, validateDependencies, false);
- }
+ AddToGroup(new ExecutionNode(customGroup, throttlingEnabled), updateInGroupType, typeof(TGroup),
+ addToEdges, validateDependencies, false);
+ }
- ///
- /// Used by auto-generated code
- ///
- public ArchSystemsWorldBuilder AddToGroup(ISystem system, Type updateInGroupType, Type systemType,
- Action>> addToEdges, Action> validateDependencies,
- bool throttlingEnabled, bool assertGroupExists = true)
- {
- return AddToGroup(new ExecutionNode(system, throttlingEnabled), updateInGroupType, systemType,
- addToEdges,
- validateDependencies,
- assertGroupExists);
- }
+ ///
+ /// Used by auto-generated code
+ ///
+ public ArchSystemsWorldBuilder AddToGroup(ISystem system, Type updateInGroupType, Type systemType,
+ Action>> addToEdges,
+ Action> validateDependencies,
+ bool throttlingEnabled, bool assertGroupExists = true)
+ {
+ return AddToGroup(new ExecutionNode(system, throttlingEnabled), updateInGroupType, systemType,
+ addToEdges,
+ validateDependencies,
+ assertGroupExists);
+ }
- private ArchSystemsWorldBuilder AddToGroup(ExecutionNode node, Type updateInGroupType, Type systemType,
- Action>> addToEdges, Action> validateDependencies,
- bool assertGroupExists = true)
- {
- if (!_groupsInfo.TryGetValue(updateInGroupType, out var group))
- _groupsInfo[updateInGroupType] = group = new GroupInfo
+ private ArchSystemsWorldBuilder AddToGroup(ExecutionNode node, Type updateInGroupType, Type systemType,
+ Action>> addToEdges,
+ Action> validateDependencies,
+ bool assertGroupExists = true)
+ {
+ if (!_groupsInfo.TryGetValue(updateInGroupType, out var group))
+ _groupsInfo[updateInGroupType] = group = new GroupInfo
+ {
+ Systems = DictionaryPool>.Get(),
+ Edges = DictionaryPool>.Get(),
+ DisconnectedDependencies = ListPool.Get()
+ };
+
+ if (group.Systems.ContainsKey(systemType))
{
- Systems = DictionaryPool>.Get(),
- Edges = DictionaryPool>.Get(),
- DisconnectedDependencies = ListPool.Get()
- };
+ if (assertGroupExists)
+ throw new InvalidOperationException(
+ $"System {systemType} is already added to the group {updateInGroupType}.");
+ return this;
+ }
+
+ group.Systems[systemType] = node;
+ addToEdges(group.Edges);
+ validateDependencies(group.DisconnectedDependencies);
- if (group.Systems.ContainsKey(systemType))
- {
- if (assertGroupExists)
- throw new InvalidOperationException(
- $"System {systemType} is already added to the group {updateInGroupType}.");
return this;
}
- group.Systems[systemType] = node;
- addToEdges(group.Edges);
- validateDependencies(group.DisconnectedDependencies);
-
- return this;
- }
+ internal void AddCustomGroup(TGroup customGroup) where TGroup : CustomGroupBase
+ {
+ _customGroups.Add(typeof(TGroup), customGroup);
+ }
- internal void AddCustomGroup(TGroup customGroup) where TGroup : CustomGroupBase
- {
- _customGroups.Add(typeof(TGroup), customGroup);
- }
+ ///
+ /// Finalize the builder and create a systems world
+ ///
+ public SystemGroupWorld Finish()
+ {
+ return Finish(SystemGroupAggregate.Factory.Instance, default);
+ }
- ///
- /// Finalize the builder and create a systems world
- ///
- public SystemGroupWorld Finish()
- {
- return Finish(SystemGroupAggregate.Factory.Instance, default);
- }
+ ///
+ /// Finalize the builder and create a systems world according to the custom aggregation mechanism
+ ///
+ /// factory for custom aggregation
+ /// data for custom aggregation
+ /// Type of aggregation data
+ ///
+ public SystemGroupWorld Finish(ISystemGroupAggregate.IFactory aggregateFactory,
+ TAggregationData aggregationData)
+ {
+ var initializationSystemGroup = InitializationSystemGroup.Empty;
+ var simulationSystemGroup = SimulationSystemGroup.Empty;
+ var presentationSystemGroup = PresentationSystemGroup.Empty;
+ var postRenderingSystemGroup = PostRenderingSystemGroup.Empty;
+ var physicsSystemGroup = PhysicsSystemGroup.Empty;
+ var postPhysicsSystemGroup = PostPhysicsSystemGroup.Empty;
+
+ // detect detached dependencies
+ var disconnectedDependencies = ListPool.Get();
+
+ CreateSystemGroup(ref initializationSystemGroup, CreateInitializationSystemGroup, disconnectedDependencies);
+ CreateSystemGroup(ref simulationSystemGroup, CreateSimulationSystemGroup, disconnectedDependencies);
+ CreateSystemGroup(ref presentationSystemGroup, CreatePresentationSystemGroup, disconnectedDependencies);
+ CreateSystemGroup(ref postRenderingSystemGroup, CreatePostRenderingSystemGroup, disconnectedDependencies);
+ CreateSystemGroup(ref physicsSystemGroup, CreatePhysicsSystemGroup, disconnectedDependencies);
+ CreateSystemGroup(ref postPhysicsSystemGroup, CreatePostPhysicsSystemGroup, disconnectedDependencies);
+
+ // All remaining groups are empty at the moment
+ // Fill them with systems
+
+ foreach (var (systemType, groupInfo) in _groupsInfo)
+ {
+ if (!_customGroups.TryGetValue(systemType, out var customGroup))
+ throw new GroupNotFoundException(systemType);
+
+ // validate dependencies
+ if (groupInfo.DisconnectedDependencies.Count > 0)
+ disconnectedDependencies.Add(new DisconnectedDependenciesInfo(systemType,
+ new List(groupInfo.DisconnectedDependencies)));
+
+ customGroup.SetSystems(ArchSystemsSorter.SortSystems(groupInfo.Systems, groupInfo.Edges));
+ CleanUpGroupInfo(in groupInfo);
+ }
+
+ // At this point we gather all information about wrong dependencies
+ if (disconnectedDependencies.Count > 0)
+ throw new DisconnectedDependenciesFoundException(disconnectedDependencies);
+
+ ListPool.Release(disconnectedDependencies);
+ DictionaryPool.Release(_groupsInfo);
+ DictionaryPool>.Release(_customGroups);
+
+ _playerLoop.AppendWorldToCurrentPlayerLoop(
+ aggregateFactory,
+ aggregationData,
+ initializationSystemGroup,
+ simulationSystemGroup,
+ presentationSystemGroup,
+ postRenderingSystemGroup,
+ physicsSystemGroup,
+ postPhysicsSystemGroup
+ );
+
+ return new SystemGroupWorld(new SystemGroup[]
+ {
+ initializationSystemGroup,
+ simulationSystemGroup,
+ presentationSystemGroup,
+ postRenderingSystemGroup,
+ physicsSystemGroup,
+ postPhysicsSystemGroup
+ }, _playerLoop, aggregateFactory);
+ }
- ///
- /// Finalize the builder and create a systems world according to the custom aggregation mechanism
- ///
- /// factory for custom aggregation
- /// data for custom aggregation
- /// Type of aggregation data
- ///
- public SystemGroupWorld Finish(ISystemGroupAggregate.IFactory aggregateFactory,
- TAggregationData aggregationData)
- {
- var initializationSystemGroup = InitializationSystemGroup.Empty;
- var simulationSystemGroup = SimulationSystemGroup.Empty;
- var presentationSystemGroup = PresentationSystemGroup.Empty;
- var postRenderingSystemGroup = PostRenderingSystemGroup.Empty;
- var physicsSystemGroup = PhysicsSystemGroup.Empty;
- var postPhysicsSystemGroup = PostPhysicsSystemGroup.Empty;
-
- // detect detached dependencies
- var disconnectedDependencies = ListPool.Get();
-
- CreateSystemGroup(ref initializationSystemGroup, CreateInitializationSystemGroup, disconnectedDependencies);
- CreateSystemGroup(ref simulationSystemGroup, CreateSimulationSystemGroup, disconnectedDependencies);
- CreateSystemGroup(ref presentationSystemGroup, CreatePresentationSystemGroup, disconnectedDependencies);
- CreateSystemGroup(ref postRenderingSystemGroup, CreatePostRenderingSystemGroup, disconnectedDependencies);
- CreateSystemGroup(ref physicsSystemGroup, CreatePhysicsSystemGroup, disconnectedDependencies);
- CreateSystemGroup(ref postPhysicsSystemGroup, CreatePostPhysicsSystemGroup, disconnectedDependencies);
-
- // All remaining groups are empty at the moment
- // Fill them with systems
-
- foreach (var (systemType, groupInfo) in _groupsInfo)
+ private PostPhysicsSystemGroup CreatePostPhysicsSystemGroup(List> list)
{
- if (!_customGroups.TryGetValue(systemType, out var customGroup))
- throw new GroupNotFoundException(systemType);
-
- // validate dependencies
- if (groupInfo.DisconnectedDependencies.Count > 0)
- disconnectedDependencies.Add(new DisconnectedDependenciesInfo(systemType, new List(groupInfo.DisconnectedDependencies)));
-
- customGroup.SetSystems(ArchSystemsSorter.SortSystems(groupInfo.Systems, groupInfo.Edges));
- CleanUpGroupInfo(in groupInfo);
+ return new PostPhysicsSystemGroup(list, _fixedUpdateBasedSystemGroupThrottler, _exceptionHandler);
}
- // At this point we gather all information about wrong dependencies
- if (disconnectedDependencies.Count > 0)
- throw new DisconnectedDependenciesFoundException(disconnectedDependencies);
-
- ListPool.Release(disconnectedDependencies);
- DictionaryPool.Release(_groupsInfo);
- DictionaryPool>.Release(_customGroups);
-
- _playerLoop.AppendWorldToCurrentPlayerLoop(
- aggregateFactory,
- aggregationData,
- initializationSystemGroup,
- simulationSystemGroup,
- presentationSystemGroup,
- postRenderingSystemGroup,
- physicsSystemGroup,
- postPhysicsSystemGroup
- );
-
- return new SystemGroupWorld(new SystemGroup[]
+ private PhysicsSystemGroup CreatePhysicsSystemGroup(List> list)
{
- initializationSystemGroup,
- simulationSystemGroup,
- presentationSystemGroup,
- postRenderingSystemGroup,
- physicsSystemGroup,
- postPhysicsSystemGroup
- }, _playerLoop, aggregateFactory);
- }
+ return new PhysicsSystemGroup(list, _fixedUpdateBasedSystemGroupThrottler, _exceptionHandler);
+ }
- private PostPhysicsSystemGroup CreatePostPhysicsSystemGroup(List> list)
- {
- return new PostPhysicsSystemGroup(list, _fixedUpdateBasedSystemGroupThrottler, _exceptionHandler);
- }
+ private PostRenderingSystemGroup CreatePostRenderingSystemGroup(List> list)
+ {
+ return new PostRenderingSystemGroup(list, _updateBasedSystemGroupThrottler, _exceptionHandler);
+ }
- private PhysicsSystemGroup CreatePhysicsSystemGroup(List> list)
- {
- return new PhysicsSystemGroup(list, _fixedUpdateBasedSystemGroupThrottler, _exceptionHandler);
- }
+ private PresentationSystemGroup CreatePresentationSystemGroup(List> list)
+ {
+ return new PresentationSystemGroup(list, _updateBasedSystemGroupThrottler, _exceptionHandler);
+ }
- private PostRenderingSystemGroup CreatePostRenderingSystemGroup(List> list)
- {
- return new PostRenderingSystemGroup(list, _updateBasedSystemGroupThrottler, _exceptionHandler);
- }
+ private SimulationSystemGroup CreateSimulationSystemGroup(List> list)
+ {
+ return new SimulationSystemGroup(list, _updateBasedSystemGroupThrottler, _exceptionHandler);
+ }
- private PresentationSystemGroup CreatePresentationSystemGroup(List> list)
- {
- return new PresentationSystemGroup(list, _updateBasedSystemGroupThrottler, _exceptionHandler);
- }
+ private InitializationSystemGroup CreateInitializationSystemGroup(List> list)
+ {
+ return new InitializationSystemGroup(list, _updateBasedSystemGroupThrottler, _exceptionHandler);
+ }
- private SimulationSystemGroup CreateSimulationSystemGroup(List> list)
- {
- return new SimulationSystemGroup(list, _updateBasedSystemGroupThrottler, _exceptionHandler);
- }
+ private void CreateSystemGroup(ref TGroup group, Func>, TGroup> constructor,
+ List disconnectedDependencies)
+ where TGroup : SystemGroup
+ {
+ if (_groupsInfo.TryGetValue(typeof(TGroup), out var groupsInfo))
+ {
+ // validate dependencies
+ if (groupsInfo.DisconnectedDependencies.Count > 0)
+ disconnectedDependencies.Add(new DisconnectedDependenciesInfo(typeof(TGroup),
+ new List(groupsInfo.DisconnectedDependencies)));
- private InitializationSystemGroup CreateInitializationSystemGroup(List> list)
- {
- return new InitializationSystemGroup(list, _updateBasedSystemGroupThrottler, _exceptionHandler);
- }
+ group = constructor(ArchSystemsSorter.SortSystems(groupsInfo.Systems, groupsInfo.Edges));
- private void CreateSystemGroup(ref TGroup group, Func>, TGroup> constructor,
- List disconnectedDependencies)
- where TGroup : SystemGroup
- {
- if (_groupsInfo.TryGetValue(typeof(TGroup), out var groupsInfo))
- {
- // validate dependencies
- if (groupsInfo.DisconnectedDependencies.Count > 0)
- disconnectedDependencies.Add(new DisconnectedDependenciesInfo(typeof(TGroup), new List(groupsInfo.DisconnectedDependencies)));
-
- group = constructor(ArchSystemsSorter.SortSystems(groupsInfo.Systems, groupsInfo.Edges));
-
- CleanUpGroupInfo(in groupsInfo);
- _groupsInfo.Remove(typeof(TGroup));
+ CleanUpGroupInfo(in groupsInfo);
+ _groupsInfo.Remove(typeof(TGroup));
+ }
}
- }
- private void CleanUpGroupInfo(in GroupInfo groupInfo)
- {
- DictionaryPool>.Release(groupInfo.Systems);
+ private void CleanUpGroupInfo(in GroupInfo groupInfo)
+ {
+ DictionaryPool>.Release(groupInfo.Systems);
- foreach (var (_, edges) in groupInfo.Edges)
- ListPool.Release(edges);
+ foreach (var (_, edges) in groupInfo.Edges)
+ ListPool.Release(edges);
- DictionaryPool>.Release(groupInfo.Edges);
- ListPool.Release(groupInfo.DisconnectedDependencies);
+ DictionaryPool>.Release(groupInfo.Edges);
+ ListPool.Release(groupInfo.DisconnectedDependencies);
+ }
}
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/Builder/ArchSystemsWorldBuilderExtensions.cs b/Arch.SystemGroups/Builder/ArchSystemsWorldBuilderExtensions.cs
index 4aba55f..9ae9bc7 100644
--- a/Arch.SystemGroups/Builder/ArchSystemsWorldBuilderExtensions.cs
+++ b/Arch.SystemGroups/Builder/ArchSystemsWorldBuilderExtensions.cs
@@ -1,16 +1,17 @@
-namespace Arch.SystemGroups;
-
-///
-/// Publicly available extensions for the ArchSystemsWorldBuilder
-///
-public static class ArchSystemsWorldBuilderExtensions
+namespace Arch.SystemGroups
{
///
- /// Inject a custom group into the world. It allows to create a group with custom parameters.
+ /// Publicly available extensions for the ArchSystemsWorldBuilder
///
- public static ref ArchSystemsWorldBuilder InjectCustomGroup(ref this ArchSystemsWorldBuilder builder, TGroup group) where TGroup : CustomGroupBase
+ public static class ArchSystemsWorldBuilderExtensions
{
- builder.AddCustomGroup(group);
- return ref builder;
+ ///
+ /// Inject a custom group into the world. It allows to create a group with custom parameters.
+ ///
+ public static ref ArchSystemsWorldBuilder InjectCustomGroup(ref this ArchSystemsWorldBuilder builder, TGroup group) where TGroup : CustomGroupBase
+ {
+ builder.AddCustomGroup(group);
+ return ref builder;
+ }
}
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/DefaultSystemGroups/InitializationSystemGroup.cs b/Arch.SystemGroups/DefaultSystemGroups/InitializationSystemGroup.cs
index af9fad1..23dd7ca 100644
--- a/Arch.SystemGroups/DefaultSystemGroups/InitializationSystemGroup.cs
+++ b/Arch.SystemGroups/DefaultSystemGroups/InitializationSystemGroup.cs
@@ -3,23 +3,24 @@
using Arch.SystemGroups.UnityBridge;
using JetBrains.Annotations;
-namespace Arch.SystemGroups.DefaultSystemGroups;
-
-///
-/// Updates at the end of the Initialization phase of the player loop
-///
-public class InitializationSystemGroup : SystemGroup
+namespace Arch.SystemGroups.DefaultSystemGroups
{
- internal InitializationSystemGroup(List> nodes, [CanBeNull] ISystemGroupThrottler throttler, [CanBeNull] ISystemGroupExceptionHandler exceptionHandler) : base(nodes, throttler, exceptionHandler)
+ ///
+ /// Updates at the end of the Initialization phase of the player loop
+ ///
+ public class InitializationSystemGroup : SystemGroup
{
- }
+ internal InitializationSystemGroup(List> nodes, [CanBeNull] ISystemGroupThrottler throttler, [CanBeNull] ISystemGroupExceptionHandler exceptionHandler) : base(nodes, throttler, exceptionHandler)
+ {
+ }
- internal static readonly InitializationSystemGroup Empty = new (null, null, null);
+ internal static readonly InitializationSystemGroup Empty = new (null, null, null);
- public override void Update()
- {
- Update(TimeProvider.GetInfo());
- }
+ public override void Update()
+ {
+ Update(TimeProvider.GetInfo());
+ }
+ }
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/DefaultSystemGroups/PhysicsSystemGroup.cs b/Arch.SystemGroups/DefaultSystemGroups/PhysicsSystemGroup.cs
index c7b4cb2..5694654 100644
--- a/Arch.SystemGroups/DefaultSystemGroups/PhysicsSystemGroup.cs
+++ b/Arch.SystemGroups/DefaultSystemGroups/PhysicsSystemGroup.cs
@@ -4,22 +4,23 @@
using Arch.SystemGroups.UnityBridge;
using JetBrains.Annotations;
-namespace Arch.SystemGroups.DefaultSystemGroups;
-
-///
-/// Updates at the beginning of the FixedUpdate phase of the player loop
-/// before all fixed updates
-///
-public class PhysicsSystemGroup : SystemGroup
+namespace Arch.SystemGroups.DefaultSystemGroups
{
- internal PhysicsSystemGroup(List> nodes, [CanBeNull] ISystemGroupThrottler throttler, [CanBeNull] ISystemGroupExceptionHandler exceptionHandler) : base(nodes, throttler, exceptionHandler)
+ ///
+ /// Updates at the beginning of the FixedUpdate phase of the player loop
+ /// before all fixed updates
+ ///
+ public class PhysicsSystemGroup : SystemGroup
{
- }
+ internal PhysicsSystemGroup(List> nodes, [CanBeNull] ISystemGroupThrottler throttler, [CanBeNull] ISystemGroupExceptionHandler exceptionHandler) : base(nodes, throttler, exceptionHandler)
+ {
+ }
- internal static readonly PhysicsSystemGroup Empty = new (null, null, null);
+ internal static readonly PhysicsSystemGroup Empty = new (null, null, null);
- public override void Update()
- {
- Update(TimeProvider.GetFixedInfo());
+ public override void Update()
+ {
+ Update(TimeProvider.GetFixedInfo());
+ }
}
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/DefaultSystemGroups/PostPhysicsSystemGroup.cs b/Arch.SystemGroups/DefaultSystemGroups/PostPhysicsSystemGroup.cs
index 78bd937..3798908 100644
--- a/Arch.SystemGroups/DefaultSystemGroups/PostPhysicsSystemGroup.cs
+++ b/Arch.SystemGroups/DefaultSystemGroups/PostPhysicsSystemGroup.cs
@@ -3,22 +3,23 @@
using Arch.SystemGroups.UnityBridge;
using JetBrains.Annotations;
-namespace Arch.SystemGroups.DefaultSystemGroups;
-
-///
-/// Updates at the end of the FixedUpdate phase of the player loop
-///
-public class PostPhysicsSystemGroup : SystemGroup
+namespace Arch.SystemGroups.DefaultSystemGroups
{
- internal PostPhysicsSystemGroup(List> nodes, [CanBeNull] ISystemGroupThrottler throttler,
- [CanBeNull] ISystemGroupExceptionHandler exceptionHandler) : base(nodes, throttler, exceptionHandler)
+ ///
+ /// Updates at the end of the FixedUpdate phase of the player loop
+ ///
+ public class PostPhysicsSystemGroup : SystemGroup
{
- }
+ internal PostPhysicsSystemGroup(List> nodes, [CanBeNull] ISystemGroupThrottler throttler,
+ [CanBeNull] ISystemGroupExceptionHandler exceptionHandler) : base(nodes, throttler, exceptionHandler)
+ {
+ }
- internal static readonly PostPhysicsSystemGroup Empty = new(null, null, null);
+ internal static readonly PostPhysicsSystemGroup Empty = new(null, null, null);
- public override void Update()
- {
- Update(TimeProvider.GetFixedInfo());
+ public override void Update()
+ {
+ Update(TimeProvider.GetFixedInfo());
+ }
}
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/DefaultSystemGroups/PostRenderingSystemGroup.cs b/Arch.SystemGroups/DefaultSystemGroups/PostRenderingSystemGroup.cs
index 9f90758..e7d39d5 100644
--- a/Arch.SystemGroups/DefaultSystemGroups/PostRenderingSystemGroup.cs
+++ b/Arch.SystemGroups/DefaultSystemGroups/PostRenderingSystemGroup.cs
@@ -3,22 +3,23 @@
using Arch.SystemGroups.UnityBridge;
using JetBrains.Annotations;
-namespace Arch.SystemGroups.DefaultSystemGroups;
-
-///
-/// Updates at the end of the PostLateUpdate phase of the player loop.
-///
-public class PostRenderingSystemGroup : SystemGroup
+namespace Arch.SystemGroups.DefaultSystemGroups
{
- internal PostRenderingSystemGroup(List> nodes, [CanBeNull] ISystemGroupThrottler throttler,
- [CanBeNull] ISystemGroupExceptionHandler exceptionHandler) : base(nodes, throttler, exceptionHandler)
+ ///
+ /// Updates at the end of the PostLateUpdate phase of the player loop.
+ ///
+ public class PostRenderingSystemGroup : SystemGroup
{
- }
+ internal PostRenderingSystemGroup(List> nodes, [CanBeNull] ISystemGroupThrottler throttler,
+ [CanBeNull] ISystemGroupExceptionHandler exceptionHandler) : base(nodes, throttler, exceptionHandler)
+ {
+ }
- internal static readonly PostRenderingSystemGroup Empty = new (null, null, null);
+ internal static readonly PostRenderingSystemGroup Empty = new (null, null, null);
- public override void Update()
- {
- Update(TimeProvider.GetInfo());
+ public override void Update()
+ {
+ Update(TimeProvider.GetInfo());
+ }
}
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/DefaultSystemGroups/PresentationSystemGroup.cs b/Arch.SystemGroups/DefaultSystemGroups/PresentationSystemGroup.cs
index 3a66694..415030a 100644
--- a/Arch.SystemGroups/DefaultSystemGroups/PresentationSystemGroup.cs
+++ b/Arch.SystemGroups/DefaultSystemGroups/PresentationSystemGroup.cs
@@ -4,22 +4,23 @@
using Arch.SystemGroups.UnityBridge;
using JetBrains.Annotations;
-namespace Arch.SystemGroups.DefaultSystemGroups;
-
-///
-/// Updates at the end of the PreLateUpdate phase of the player loop.
-///
-public class PresentationSystemGroup : SystemGroup
+namespace Arch.SystemGroups.DefaultSystemGroups
{
- internal PresentationSystemGroup(List> systems, [CanBeNull] ISystemGroupThrottler throttler,
- [CanBeNull] ISystemGroupExceptionHandler exceptionHandler) : base(systems, throttler, exceptionHandler)
+ ///
+ /// Updates at the end of the PreLateUpdate phase of the player loop.
+ ///
+ public class PresentationSystemGroup : SystemGroup
{
- }
+ internal PresentationSystemGroup(List> systems, [CanBeNull] ISystemGroupThrottler throttler,
+ [CanBeNull] ISystemGroupExceptionHandler exceptionHandler) : base(systems, throttler, exceptionHandler)
+ {
+ }
- internal static readonly PresentationSystemGroup Empty = new (null, null, null);
+ internal static readonly PresentationSystemGroup Empty = new (null, null, null);
- public override void Update()
- {
- Update(TimeProvider.GetInfo());
+ public override void Update()
+ {
+ Update(TimeProvider.GetInfo());
+ }
}
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/DefaultSystemGroups/SimulationSystemGroup.cs b/Arch.SystemGroups/DefaultSystemGroups/SimulationSystemGroup.cs
index ed3e83f..7007ed0 100644
--- a/Arch.SystemGroups/DefaultSystemGroups/SimulationSystemGroup.cs
+++ b/Arch.SystemGroups/DefaultSystemGroups/SimulationSystemGroup.cs
@@ -3,22 +3,23 @@
using Arch.SystemGroups.UnityBridge;
using JetBrains.Annotations;
-namespace Arch.SystemGroups.DefaultSystemGroups;
-
-///
-/// Updates at the end of the Update phase of the player loop
-///
-public class SimulationSystemGroup : SystemGroup
+namespace Arch.SystemGroups.DefaultSystemGroups
{
- internal SimulationSystemGroup(List> systems, [CanBeNull] ISystemGroupThrottler throttler,
- [CanBeNull] ISystemGroupExceptionHandler exceptionHandler) : base(systems, throttler, exceptionHandler)
+ ///
+ /// Updates at the end of the Update phase of the player loop
+ ///
+ public class SimulationSystemGroup : SystemGroup
{
- }
+ internal SimulationSystemGroup(List> systems, [CanBeNull] ISystemGroupThrottler throttler,
+ [CanBeNull] ISystemGroupExceptionHandler exceptionHandler) : base(systems, throttler, exceptionHandler)
+ {
+ }
- internal static readonly SimulationSystemGroup Empty = new (null, null, null);
+ internal static readonly SimulationSystemGroup Empty = new (null, null, null);
- public override void Update()
- {
- Update(TimeProvider.GetInfo());
+ public override void Update()
+ {
+ Update(TimeProvider.GetInfo());
+ }
}
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/DefaultSystemGroups/SystemGroupsUtils.cs b/Arch.SystemGroups/DefaultSystemGroups/SystemGroupsUtils.cs
index 99a233c..d387edc 100644
--- a/Arch.SystemGroups/DefaultSystemGroups/SystemGroupsUtils.cs
+++ b/Arch.SystemGroups/DefaultSystemGroups/SystemGroupsUtils.cs
@@ -1,18 +1,19 @@
-namespace Arch.SystemGroups.DefaultSystemGroups;
-
-///
-/// System Groups Utility Functions
-///
-public static class SystemGroupsUtils
+namespace Arch.SystemGroups.DefaultSystemGroups
{
///
- /// The number of defined system groups:
- ///
- ///
- ///
- ///
- ///
- ///
+ /// System Groups Utility Functions
///
- public const int Count = 6;
+ public static class SystemGroupsUtils
+ {
+ ///
+ /// The number of defined system groups:
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public const int Count = 6;
+ }
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/ExecutionNode.cs b/Arch.SystemGroups/ExecutionNode.cs
index 89f9c78..1426409 100644
--- a/Arch.SystemGroups/ExecutionNode.cs
+++ b/Arch.SystemGroups/ExecutionNode.cs
@@ -1,96 +1,97 @@
using Arch.System;
-namespace Arch.SystemGroups;
-
-internal readonly struct ExecutionNode
+namespace Arch.SystemGroups
{
- public readonly bool ThrottlingEnabled;
- public readonly bool IsGroup;
- public readonly ISystem System;
- public readonly CustomGroupBase CustomGroup;
-
- public ExecutionNode(ISystem system, bool throttlingEnabled)
+ internal readonly struct ExecutionNode
{
- ThrottlingEnabled = throttlingEnabled;
- System = system;
- CustomGroup = null;
- IsGroup = false;
- }
+ public readonly bool ThrottlingEnabled;
+ public readonly bool IsGroup;
+ public readonly ISystem System;
+ public readonly CustomGroupBase CustomGroup;
- public ExecutionNode(CustomGroupBase customGroup, bool throttlingEnabled)
- {
- IsGroup = true;
- ThrottlingEnabled = throttlingEnabled;
- CustomGroup = customGroup;
- System = null;
- }
-
- public void Initialize()
- {
- if (IsGroup)
+ public ExecutionNode(ISystem system, bool throttlingEnabled)
{
- CustomGroup.Initialize();
+ ThrottlingEnabled = throttlingEnabled;
+ System = system;
+ CustomGroup = null;
+ IsGroup = false;
}
- else
+
+ public ExecutionNode(CustomGroupBase customGroup, bool throttlingEnabled)
{
- System.Initialize();
+ IsGroup = true;
+ ThrottlingEnabled = throttlingEnabled;
+ CustomGroup = customGroup;
+ System = null;
}
- }
- public void Dispose()
- {
- if (IsGroup)
- {
- CustomGroup.Dispose();
- }
- else
+ public void Initialize()
{
- System.Dispose();
+ if (IsGroup)
+ {
+ CustomGroup.Initialize();
+ }
+ else
+ {
+ System.Initialize();
+ }
}
- }
- public void BeforeUpdate(in T t, bool throttle)
- {
- if (throttle && ThrottlingEnabled)
- return;
-
- if (IsGroup)
+ public void Dispose()
{
- CustomGroup.BeforeUpdate(t, throttle);
+ if (IsGroup)
+ {
+ CustomGroup.Dispose();
+ }
+ else
+ {
+ System.Dispose();
+ }
}
- else
- {
- System.BeforeUpdate(t);
- }
- }
- public void Update(in T t, bool throttle)
- {
- if (throttle && ThrottlingEnabled)
- return;
-
- if (IsGroup)
- {
- CustomGroup.Update(t, throttle);
- }
- else
+ public void BeforeUpdate(in T t, bool throttle)
{
- System.Update(t);
+ if (throttle && ThrottlingEnabled)
+ return;
+
+ if (IsGroup)
+ {
+ CustomGroup.BeforeUpdate(t, throttle);
+ }
+ else
+ {
+ System.BeforeUpdate(t);
+ }
}
- }
- public void AfterUpdate(in T t, bool throttle)
- {
- if (throttle && ThrottlingEnabled)
- return;
-
- if (IsGroup)
+ public void Update(in T t, bool throttle)
{
- CustomGroup.AfterUpdate(t, throttle);
+ if (throttle && ThrottlingEnabled)
+ return;
+
+ if (IsGroup)
+ {
+ CustomGroup.Update(t, throttle);
+ }
+ else
+ {
+ System.Update(t);
+ }
}
- else
+
+ public void AfterUpdate(in T t, bool throttle)
{
- System.AfterUpdate(t);
+ if (throttle && ThrottlingEnabled)
+ return;
+
+ if (IsGroup)
+ {
+ CustomGroup.AfterUpdate(t, throttle);
+ }
+ else
+ {
+ System.AfterUpdate(t);
+ }
}
}
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/Groups/CustomGroupBase.cs b/Arch.SystemGroups/Groups/CustomGroupBase.cs
index a0fc398..a3cac54 100644
--- a/Arch.SystemGroups/Groups/CustomGroupBase.cs
+++ b/Arch.SystemGroups/Groups/CustomGroupBase.cs
@@ -4,135 +4,136 @@
using Arch.SystemGroups.Metadata;
using UnityEngine.Pool;
-namespace Arch.SystemGroups;
-
-///
-/// The base class that can be used to provide custom behaviour for a group
-///
-///
-public abstract class CustomGroupBase
+namespace Arch.SystemGroups
{
///
- /// Creates an empty group
- ///
- protected CustomGroupBase()
- {
- }
-
- ///
- /// Creates a group from the collection from which a pooled instance of the list will be created
- ///
- protected CustomGroupBase(IEnumerable> systems, bool throttlingEnabled)
- {
- Nodes = ListPool>.Get();
- AddRange(systems.Select(s => new ExecutionNode(s, throttlingEnabled)));
- }
-
- internal List> Nodes { get; private set; }
-
- ///
- /// Override to provide Dispose behaviour, you can use as the default implementation
- ///
- public abstract void Dispose();
-
- ///
- /// Override to provide initialization behaviour, you can use as the default
- /// implementation
- ///
- public abstract void Initialize();
-
- ///
- /// Override to provide BeforeUpdate, you can use as the default implementation
- ///
- ///
- /// Indicates that the current invocation is throttled
- public abstract void BeforeUpdate(in T t, bool throttle);
-
- ///
- /// Override to provide Update behaviour, you can use as the default implementation
- ///
- ///
- /// Indicates that the current invocation is throttled
- public abstract void Update(in T t, bool throttle);
-
- ///
- /// Override to provide AfterUpdate behaviour, you can use as the default
- /// implementation
- ///
- /// Indicates that the current invocation is throttled
- ///
- public abstract void AfterUpdate(in T t, bool throttle);
-
- ///
- /// Adds systems to the group
- ///
- ///
- internal void AddRange(IEnumerable> systems)
- {
- Nodes.AddRange(systems);
- }
-
- internal void SetSystems(List> systems)
- {
- Nodes = systems;
- }
-
- ///
- /// Initialize all systems in the group
- ///
- protected void InitializeInternal()
- {
- foreach (var node in Nodes)
- node.Initialize();
- }
-
- ///
- /// Dispose all systems in the group
- ///
- protected void DisposeInternal()
- {
- foreach (var node in Nodes)
- node.Dispose();
-
- ListPool>.Release(Nodes);
- }
-
- ///
- /// Update all systems
- ///
- /// Delta time
- /// Current update is throttled
- protected void BeforeUpdateInternal(in T t, bool throttle)
- {
- for (var index = 0; index < Nodes.Count; ++index)
- Nodes[index].BeforeUpdate(in t, throttle);
- }
-
- ///
- /// Update all systems
+ /// The base class that can be used to provide custom behaviour for a group
///
- /// Delta time
- /// Current update is throttled
- protected void UpdateInternal(in T t, bool throttle)
+ ///
+ public abstract class CustomGroupBase
{
- for (var index = 0; index < Nodes.Count; ++index)
- Nodes[index].Update(in t, throttle);
- }
-
- ///
- /// Update all systems
- ///
- /// Delta time
- /// Current update is throttled
- protected void AfterUpdateInternal(in T t, bool throttle)
- {
- for (var index = 0; index < Nodes.Count; ++index)
- Nodes[index].AfterUpdate(in t, throttle);
- }
+ ///
+ /// Creates an empty group
+ ///
+ protected CustomGroupBase()
+ {
+ }
+
+ ///
+ /// Creates a group from the collection from which a pooled instance of the list will be created
+ ///
+ protected CustomGroupBase(IEnumerable> systems, bool throttlingEnabled)
+ {
+ Nodes = ListPool>.Get();
+ AddRange(systems.Select(s => new ExecutionNode(s, throttlingEnabled)));
+ }
+
+ internal List> Nodes { get; private set; }
+
+ ///
+ /// Override to provide Dispose behaviour, you can use as the default implementation
+ ///
+ public abstract void Dispose();
+
+ ///
+ /// Override to provide initialization behaviour, you can use as the default
+ /// implementation
+ ///
+ public abstract void Initialize();
+
+ ///
+ /// Override to provide BeforeUpdate, you can use as the default implementation
+ ///
+ ///
+ /// Indicates that the current invocation is throttled
+ public abstract void BeforeUpdate(in T t, bool throttle);
+
+ ///
+ /// Override to provide Update behaviour, you can use as the default implementation
+ ///
+ ///
+ /// Indicates that the current invocation is throttled
+ public abstract void Update(in T t, bool throttle);
+
+ ///
+ /// Override to provide AfterUpdate behaviour, you can use as the default
+ /// implementation
+ ///
+ /// Indicates that the current invocation is throttled
+ ///
+ public abstract void AfterUpdate(in T t, bool throttle);
+
+ ///
+ /// Adds systems to the group
+ ///
+ ///
+ internal void AddRange(IEnumerable> systems)
+ {
+ Nodes.AddRange(systems);
+ }
+
+ internal void SetSystems(List> systems)
+ {
+ Nodes = systems;
+ }
+
+ ///
+ /// Initialize all systems in the group
+ ///
+ protected void InitializeInternal()
+ {
+ foreach (var node in Nodes)
+ node.Initialize();
+ }
+
+ ///
+ /// Dispose all systems in the group
+ ///
+ protected void DisposeInternal()
+ {
+ foreach (var node in Nodes)
+ node.Dispose();
+
+ ListPool>.Release(Nodes);
+ }
+
+ ///
+ /// Update all systems
+ ///
+ /// Delta time
+ /// Current update is throttled
+ protected void BeforeUpdateInternal(in T t, bool throttle)
+ {
+ for (var index = 0; index < Nodes.Count; ++index)
+ Nodes[index].BeforeUpdate(in t, throttle);
+ }
+
+ ///
+ /// Update all systems
+ ///
+ /// Delta time
+ /// Current update is throttled
+ protected void UpdateInternal(in T t, bool throttle)
+ {
+ for (var index = 0; index < Nodes.Count; ++index)
+ Nodes[index].Update(in t, throttle);
+ }
+
+ ///
+ /// Update all systems
+ ///
+ /// Delta time
+ /// Current update is throttled
+ protected void AfterUpdateInternal(in T t, bool throttle)
+ {
+ for (var index = 0; index < Nodes.Count; ++index)
+ Nodes[index].AfterUpdate(in t, throttle);
+ }
- ///
- /// The metadata of the group in an abstract form
- ///
- ///
- protected abstract AttributesInfoBase GetMetadataInternal();
+ ///
+ /// The metadata of the group in an abstract form
+ ///
+ ///
+ protected abstract AttributesInfoBase GetMetadataInternal();
+ }
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/Groups/DefaultGroup.cs b/Arch.SystemGroups/Groups/DefaultGroup.cs
index ef560e9..53ab734 100644
--- a/Arch.SystemGroups/Groups/DefaultGroup.cs
+++ b/Arch.SystemGroups/Groups/DefaultGroup.cs
@@ -1,56 +1,57 @@
-namespace Arch.SystemGroups;
-
-///
-/// Similar to `Arch.System.Group` but with better API that allows pooling
-///
-///
-public abstract class DefaultGroup : CustomGroupBase
+namespace Arch.SystemGroups
{
///
- /// Creates an empty group, for auto-generated code only,
- /// Don't invoke it manually
+ /// Similar to `Arch.System.Group` but with better API that allows pooling
///
- protected DefaultGroup()
+ ///
+ public abstract class DefaultGroup : CustomGroupBase
{
- }
+ ///
+ /// Creates an empty group, for auto-generated code only,
+ /// Don't invoke it manually
+ ///
+ protected DefaultGroup()
+ {
+ }
- ///
- /// Initialize all systems in the group
- ///
- public override void Initialize()
- {
- InitializeInternal();
- }
+ ///
+ /// Initialize all systems in the group
+ ///
+ public override void Initialize()
+ {
+ InitializeInternal();
+ }
- ///
- /// Dispose all systems in the group
- ///
- public override void Dispose()
- {
- DisposeInternal();
- }
+ ///
+ /// Dispose all systems in the group
+ ///
+ public override void Dispose()
+ {
+ DisposeInternal();
+ }
- ///
- /// To comply with Arch.System.ISystem
- ///
- public override void BeforeUpdate(in T t, bool throttle)
- {
- BeforeUpdateInternal(in t, throttle);
- }
+ ///
+ /// To comply with Arch.System.ISystem
+ ///
+ public override void BeforeUpdate(in T t, bool throttle)
+ {
+ BeforeUpdateInternal(in t, throttle);
+ }
- ///
- /// To comply with Arch.System.ISystem
- ///
- public override void Update(in T t, bool throttle)
- {
- UpdateInternal(in t, throttle);
- }
+ ///
+ /// To comply with Arch.System.ISystem
+ ///
+ public override void Update(in T t, bool throttle)
+ {
+ UpdateInternal(in t, throttle);
+ }
- ///
- /// To comply with Arch.System.ISystem
- ///
- public override void AfterUpdate(in T t, bool throttle)
- {
- AfterUpdateInternal(in t, throttle);
+ ///
+ /// To comply with Arch.System.ISystem
+ ///
+ public override void AfterUpdate(in T t, bool throttle)
+ {
+ AfterUpdateInternal(in t, throttle);
+ }
}
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/Groups/GroupNotFoundException.cs b/Arch.SystemGroups/Groups/GroupNotFoundException.cs
index 98136dd..364206b 100644
--- a/Arch.SystemGroups/Groups/GroupNotFoundException.cs
+++ b/Arch.SystemGroups/Groups/GroupNotFoundException.cs
@@ -1,22 +1,23 @@
using System;
-namespace Arch.SystemGroups;
-
-///
-/// Indicates that the group was not injected into the builder
-/// but there are systems included in it.
-///
-public class GroupNotFoundException : Exception
+namespace Arch.SystemGroups
{
- private readonly Type _type;
-
- internal GroupNotFoundException(Type type)
- {
- _type = type;
- }
-
///
- ///
+ /// Indicates that the group was not injected into the builder
+ /// but there are systems included in it.
///
- public override string Message => $"Group {_type} was not injected into the builder";
+ public class GroupNotFoundException : Exception
+ {
+ private readonly Type _type;
+
+ internal GroupNotFoundException(Type type)
+ {
+ _type = type;
+ }
+
+ ///
+ ///
+ ///
+ public override string Message => $"Group {_type} was not injected into the builder";
+ }
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/ISystemGroupExceptionHandler.cs b/Arch.SystemGroups/ISystemGroupExceptionHandler.cs
index 90b34dd..cd5adcc 100644
--- a/Arch.SystemGroups/ISystemGroupExceptionHandler.cs
+++ b/Arch.SystemGroups/ISystemGroupExceptionHandler.cs
@@ -1,39 +1,40 @@
using System;
-namespace Arch.SystemGroups;
-
-///
-/// Provides exceptions handling on the level of the
-///
-public interface ISystemGroupExceptionHandler
+namespace Arch.SystemGroups
{
///
- /// Action to tell the System Group how to behave after the exception
+ /// Provides exceptions handling on the level of the
///
- public enum Action : byte
+ public interface ISystemGroupExceptionHandler
{
///
- /// Continue execution of the system
+ /// Action to tell the System Group how to behave after the exception
///
- Continue,
+ public enum Action : byte
+ {
+ ///
+ /// Continue execution of the system
+ ///
+ Continue,
- ///
- /// Put the system group into the Error state and stops the execution
- ///
- Suspend,
+ ///
+ /// Put the system group into the Error state and stops the execution
+ ///
+ Suspend,
+
+ ///
+ /// Dispose the system group and stops the execution
+ ///
+ Dispose
+ }
///
- /// Dispose the system group and stops the execution
+ /// Handles the exception thrown by the system group, at some point the execution of the system group
+ /// should be suspended to prevent exceptions flood
///
- Dispose
+ /// Exception
+ /// System Group Type
+ /// An action to tell the System Group how to behave after
+ Action Handle(Exception exception, Type systemGroupType);
}
-
- ///
- /// Handles the exception thrown by the system group, at some point the execution of the system group
- /// should be suspended to prevent exceptions flood
- ///
- /// Exception
- /// System Group Type
- /// An action to tell the System Group how to behave after
- Action Handle(Exception exception, Type systemGroupType);
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/Metadata/AttributesInfo.cs b/Arch.SystemGroups/Metadata/AttributesInfo.cs
index f728f28..e81698e 100644
--- a/Arch.SystemGroups/Metadata/AttributesInfo.cs
+++ b/Arch.SystemGroups/Metadata/AttributesInfo.cs
@@ -1,34 +1,35 @@
using System;
using System.Collections.Generic;
-namespace Arch.SystemGroups.Metadata;
-
-///
-/// Generated attributes info, allows to avoid reflection if such access is needed
-///
-public abstract class AttributesInfoBase
+namespace Arch.SystemGroups.Metadata
{
///
- /// reflection, will be null for system groups
+ /// Generated attributes info, allows to avoid reflection if such access is needed
///
- public abstract Type UpdateInGroup { get; }
+ public abstract class AttributesInfoBase
+ {
+ ///
+ /// reflection, will be null for system groups
+ ///
+ public abstract Type UpdateInGroup { get; }
- ///
- /// Metadata of the group this system belongs to, will be null for system groups
- ///
- public abstract AttributesInfoBase GroupMetadata { get; }
+ ///
+ /// Metadata of the group this system belongs to, will be null for system groups
+ ///
+ public abstract AttributesInfoBase GroupMetadata { get; }
- ///
- /// Get first attribute of type
- ///
- /// Type of attribute
- /// Null if such attribute is not defined for the class
- public abstract T GetAttribute() where T : Attribute;
+ ///
+ /// Get first attribute of type
+ ///
+ /// Type of attribute
+ /// Null if such attribute is not defined for the class
+ public abstract T GetAttribute() where T : Attribute;
- ///
- /// Get all attributes of type
- ///
- /// Type of attribute
- /// An empty list if no attributes are found
- public abstract IReadOnlyList GetAttributes() where T : Attribute;
+ ///
+ /// Get all attributes of type
+ ///
+ /// Type of attribute
+ /// An empty list if no attributes are found
+ public abstract IReadOnlyList GetAttributes() where T : Attribute;
+ }
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/Metadata/SystemGroupAttributesInfo.cs b/Arch.SystemGroups/Metadata/SystemGroupAttributesInfo.cs
index 65991dd..9a4f666 100644
--- a/Arch.SystemGroups/Metadata/SystemGroupAttributesInfo.cs
+++ b/Arch.SystemGroups/Metadata/SystemGroupAttributesInfo.cs
@@ -1,39 +1,40 @@
using System;
using System.Collections.Generic;
-namespace Arch.SystemGroups.Metadata;
-
-///
-/// Dummy attributes info for system groups
-///
-public class SystemGroupAttributesInfo : AttributesInfoBase
+namespace Arch.SystemGroups.Metadata
{
///
- /// Instance shared between all System Groups as they provide no attributes data
+ /// Dummy attributes info for system groups
///
- public static readonly SystemGroupAttributesInfo Instance = new();
+ public class SystemGroupAttributesInfo : AttributesInfoBase
+ {
+ ///
+ /// Instance shared between all System Groups as they provide no attributes data
+ ///
+ public static readonly SystemGroupAttributesInfo Instance = new();
- ///
- /// Returns null
- ///
- public override Type UpdateInGroup => null;
+ ///
+ /// Returns null
+ ///
+ public override Type UpdateInGroup => null;
- ///
- /// Returns null
- ///
- public override AttributesInfoBase GroupMetadata => null;
+ ///
+ /// Returns null
+ ///
+ public override AttributesInfoBase GroupMetadata => null;
- ///
- /// Returns null
- ///
- ///
- ///
- public override T GetAttribute() => null;
+ ///
+ /// Returns null
+ ///
+ ///
+ ///
+ public override T GetAttribute() => null;
- ///
- /// Returns an empty array
- ///
- ///
- ///
- public override IReadOnlyList GetAttributes() => Array.Empty();
+ ///
+ /// Returns an empty array
+ ///
+ ///
+ ///
+ public override IReadOnlyList GetAttributes() => Array.Empty();
+ }
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/PlayerLoopHelper/Aggregation/ISystemGroupAggregate.cs b/Arch.SystemGroups/PlayerLoopHelper/Aggregation/ISystemGroupAggregate.cs
index f7cdcb0..deeeead 100644
--- a/Arch.SystemGroups/PlayerLoopHelper/Aggregation/ISystemGroupAggregate.cs
+++ b/Arch.SystemGroups/PlayerLoopHelper/Aggregation/ISystemGroupAggregate.cs
@@ -1,54 +1,55 @@
using System;
-namespace Arch.SystemGroups;
-
-///
-/// Non-generic interface for
-///
-public interface ISystemGroupAggregate
+namespace Arch.SystemGroups
{
///
- /// Count of system groups
+ /// Non-generic interface for
///
- int Count { get; }
+ public interface ISystemGroupAggregate
+ {
+ ///
+ /// Count of system groups
+ ///
+ int Count { get; }
- ///
- /// This function is called from Unity Player Loop
- ///
- void TriggerUpdate();
+ ///
+ /// This function is called from Unity Player Loop
+ ///
+ void TriggerUpdate();
- ///
- /// Remove a system group from the aggregate
- ///
- void Remove(SystemGroup systemGroup);
-}
-
-///
-/// Defines a way of aggregating system groups of the same type
-/// Additional Data set per world basis
-///
-public interface ISystemGroupAggregate : ISystemGroupAggregate
-{
- ///
- /// Add a system group to the aggregate
- ///
- void Add(in T data, SystemGroup systemGroup);
+ ///
+ /// Remove a system group from the aggregate
+ ///
+ void Remove(SystemGroup systemGroup);
+ }
///
- /// Factory for SystemGroupAggregate
+ /// Defines a way of aggregating system groups of the same type
+ /// Additional Data set per world basis
///
- interface IFactory : ISystemGroupAggregateFactory
+ public interface ISystemGroupAggregate : ISystemGroupAggregate
{
- ISystemGroupAggregate ISystemGroupAggregateFactory.Create(Type systemGroupType)
- {
- return Create(systemGroupType);
- }
+ ///
+ /// Add a system group to the aggregate
+ ///
+ void Add(in T data, SystemGroup systemGroup);
///
- /// Creates a new instance of SystemGroupAggregate.
- /// Called once per type of SystemGroup
+ /// Factory for SystemGroupAggregate
///
- ///
- new ISystemGroupAggregate Create(Type systemGroupType);
+ interface IFactory : ISystemGroupAggregateFactory
+ {
+ ISystemGroupAggregate ISystemGroupAggregateFactory.Create(Type systemGroupType)
+ {
+ return Create(systemGroupType);
+ }
+
+ ///
+ /// Creates a new instance of SystemGroupAggregate.
+ /// Called once per type of SystemGroup
+ ///
+ ///
+ new ISystemGroupAggregate Create(Type systemGroupType);
+ }
}
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/PlayerLoopHelper/Aggregation/ISystemGroupAggregateFactory.cs b/Arch.SystemGroups/PlayerLoopHelper/Aggregation/ISystemGroupAggregateFactory.cs
index 9a4484b..a5e0fe2 100644
--- a/Arch.SystemGroups/PlayerLoopHelper/Aggregation/ISystemGroupAggregateFactory.cs
+++ b/Arch.SystemGroups/PlayerLoopHelper/Aggregation/ISystemGroupAggregateFactory.cs
@@ -1,11 +1,12 @@
using System;
-namespace Arch.SystemGroups;
-
-///
-/// Base interface for all system group aggregates
-///
-public interface ISystemGroupAggregateFactory
+namespace Arch.SystemGroups
{
- internal ISystemGroupAggregate Create(Type systemGroupType);
+ ///
+ /// Base interface for all system group aggregates
+ ///
+ public interface ISystemGroupAggregateFactory
+ {
+ internal ISystemGroupAggregate Create(Type systemGroupType);
+ }
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/PlayerLoopHelper/Aggregation/OrderedSystemGroupAggregate.cs b/Arch.SystemGroups/PlayerLoopHelper/Aggregation/OrderedSystemGroupAggregate.cs
index 7dee744..12ce80b 100644
--- a/Arch.SystemGroups/PlayerLoopHelper/Aggregation/OrderedSystemGroupAggregate.cs
+++ b/Arch.SystemGroups/PlayerLoopHelper/Aggregation/OrderedSystemGroupAggregate.cs
@@ -1,63 +1,64 @@
using System.Collections.Generic;
-namespace Arch.SystemGroups;
-
-///
-/// Executes system groups in a specific order
-///
-public class OrderedSystemGroupAggregate : ISystemGroupAggregate
+namespace Arch.SystemGroups
{
- private readonly SortedList _sortedList;
-
///
- /// Creates a new instance of OrderedSystemGroupAggregate with the specified comparer
+ /// Executes system groups in a specific order
///
- /// Comparer should never return 0 for different system groups as it is forbidden by .
- /// Specify "debounceEqualValues" to force it
- /// If True overrides the behaviour of comparer in a way that it never returns 0
- /// Initial capacity of the underlying collection
- public OrderedSystemGroupAggregate(IComparer comparer, bool debounceEqualValues = false, int initialCapacity = 16)
+ public class OrderedSystemGroupAggregate : ISystemGroupAggregate
{
- if (debounceEqualValues)
- comparer = new DebouncedComparer(comparer);
+ private readonly SortedList _sortedList;
- _sortedList = new SortedList(initialCapacity, comparer);
- }
+ ///
+ /// Creates a new instance of OrderedSystemGroupAggregate with the specified comparer
+ ///
+ /// Comparer should never return 0 for different system groups as it is forbidden by .
+ /// Specify "debounceEqualValues" to force it
+ /// If True overrides the behaviour of comparer in a way that it never returns 0
+ /// Initial capacity of the underlying collection
+ public OrderedSystemGroupAggregate(IComparer comparer, bool debounceEqualValues = false, int initialCapacity = 16)
+ {
+ if (debounceEqualValues)
+ comparer = new DebouncedComparer(comparer);
+
+ _sortedList = new SortedList(initialCapacity, comparer);
+ }
- ///
- ///
- ///
- public int Count => _sortedList.Count;
+ ///
+ ///
+ ///
+ public int Count => _sortedList.Count;
- internal IList Values => _sortedList.Values;
+ internal IList Values => _sortedList.Values;
- ///
- ///
- ///
- public void TriggerUpdate()
- {
- for (var i = 0; i < _sortedList.Values.Count; i++)
+ ///
+ ///
+ ///
+ public void TriggerUpdate()
{
- var systemGroup = _sortedList.Values[i];
- systemGroup.Update();
+ for (var i = 0; i < _sortedList.Values.Count; i++)
+ {
+ var systemGroup = _sortedList.Values[i];
+ systemGroup.Update();
+ }
}
- }
- ///
- ///
- ///
- public void Add(in T data, SystemGroup systemGroup)
- {
- _sortedList.Add(data, systemGroup);
- }
+ ///
+ ///
+ ///
+ public void Add(in T data, SystemGroup systemGroup)
+ {
+ _sortedList.Add(data, systemGroup);
+ }
- ///
- ///
- ///
- public void Remove(SystemGroup systemGroup)
- {
- var index = _sortedList.Values.IndexOf(systemGroup);
- if (index > -1)
- _sortedList.RemoveAt(index);
+ ///
+ ///
+ ///
+ public void Remove(SystemGroup systemGroup)
+ {
+ var index = _sortedList.Values.IndexOf(systemGroup);
+ if (index > -1)
+ _sortedList.RemoveAt(index);
+ }
}
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/PlayerLoopHelper/Aggregation/SystemGroupAggregate.cs b/Arch.SystemGroups/PlayerLoopHelper/Aggregation/SystemGroupAggregate.cs
index 1f46e00..5853481 100644
--- a/Arch.SystemGroups/PlayerLoopHelper/Aggregation/SystemGroupAggregate.cs
+++ b/Arch.SystemGroups/PlayerLoopHelper/Aggregation/SystemGroupAggregate.cs
@@ -1,53 +1,54 @@
using System;
using System.Collections.Generic;
-namespace Arch.SystemGroups;
-
-///
-/// Contains the list of system groups of the same type
-///
-internal class SystemGroupAggregate : ISystemGroupAggregate
+namespace Arch.SystemGroups
{
- internal class Factory : ISystemGroupAggregate.IFactory
+ ///
+ /// Contains the list of system groups of the same type
+ ///
+ internal class SystemGroupAggregate : ISystemGroupAggregate
{
- internal static readonly Factory Instance = new();
+ internal class Factory : ISystemGroupAggregate.IFactory
+ {
+ internal static readonly Factory Instance = new();
- public ISystemGroupAggregate Create(Type systemGroupType) => new SystemGroupAggregate(systemGroupType);
- }
+ public ISystemGroupAggregate Create(Type systemGroupType) => new SystemGroupAggregate(systemGroupType);
+ }
- private readonly List _systemGroups = new(16);
+ private readonly List _systemGroups = new(16);
- ///
- /// For debugging purpose only
- ///
- internal readonly Type GroupType;
+ ///
+ /// For debugging purpose only
+ ///
+ internal readonly Type GroupType;
- public SystemGroupAggregate(Type groupType)
- {
- GroupType = groupType;
- }
+ public SystemGroupAggregate(Type groupType)
+ {
+ GroupType = groupType;
+ }
- public int Count => _systemGroups.Count;
+ public int Count => _systemGroups.Count;
- public void TriggerUpdate()
- {
- for (var i = 0; i < _systemGroups.Count; i++)
+ public void TriggerUpdate()
{
- _systemGroups[i].Update();
+ for (var i = 0; i < _systemGroups.Count; i++)
+ {
+ _systemGroups[i].Update();
+ }
}
- }
- public void Add(in None none, SystemGroup systemGroup)
- {
- _systemGroups.Add(systemGroup);
- }
+ public void Add(in None none, SystemGroup systemGroup)
+ {
+ _systemGroups.Add(systemGroup);
+ }
- public void Remove(SystemGroup systemGroup)
- {
- _systemGroups.Remove(systemGroup);
- }
+ public void Remove(SystemGroup systemGroup)
+ {
+ _systemGroups.Remove(systemGroup);
+ }
- internal struct None
- {
+ internal struct None
+ {
+ }
}
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/PlayerLoopHelper/Aggregation/SystemGroupAggregateCache.cs b/Arch.SystemGroups/PlayerLoopHelper/Aggregation/SystemGroupAggregateCache.cs
index f489d52..a69ffd5 100644
--- a/Arch.SystemGroups/PlayerLoopHelper/Aggregation/SystemGroupAggregateCache.cs
+++ b/Arch.SystemGroups/PlayerLoopHelper/Aggregation/SystemGroupAggregateCache.cs
@@ -2,54 +2,55 @@
using System.Collections.Generic;
using Arch.SystemGroups.DefaultSystemGroups;
-namespace Arch.SystemGroups;
-
-///
-/// Caches the system group aggregates by type of system group, produced for each
-///
-internal class SystemGroupAggregateCache
+namespace Arch.SystemGroups
{
- private readonly Dictionary _aggregates = new (SystemGroupsUtils.Count);
-
- internal void GetAllAggregates(List results) where TAggregate : ISystemGroupAggregate
+ ///
+ /// Caches the system group aggregates by type of system group, produced for each
+ ///
+ internal class SystemGroupAggregateCache
{
- foreach (var aggregate in _aggregates.Values)
- results.Add((TAggregate) aggregate);
- }
+ private readonly Dictionary _aggregates = new (SystemGroupsUtils.Count);
- public int Count => _aggregates.Count;
+ internal void GetAllAggregates(List results) where TAggregate : ISystemGroupAggregate
+ {
+ foreach (var aggregate in _aggregates.Values)
+ results.Add((TAggregate) aggregate);
+ }
- public ISystemGroupAggregate Add(Type systemGroupType, ISystemGroupAggregate.IFactory factory)
- {
- var aggregate = factory.Create(systemGroupType);
- _aggregates.Add(systemGroupType, aggregate);
- return aggregate;
- }
+ public int Count => _aggregates.Count;
- public void Remove(IPlayerLoop playerLoop, Type systemGroupType, SystemGroup systemGroup)
- {
- if (_aggregates.TryGetValue(systemGroupType, out var aggregate))
+ public ISystemGroupAggregate Add(Type systemGroupType, ISystemGroupAggregate.IFactory factory)
{
- aggregate.Remove(systemGroup);
- if (aggregate.Count == 0)
+ var aggregate = factory.Create(systemGroupType);
+ _aggregates.Add(systemGroupType, aggregate);
+ return aggregate;
+ }
+
+ public void Remove(IPlayerLoop playerLoop, Type systemGroupType, SystemGroup systemGroup)
+ {
+ if (_aggregates.TryGetValue(systemGroupType, out var aggregate))
{
- _aggregates.Remove(systemGroupType);
- playerLoop.RemoveAggregate(aggregate);
+ aggregate.Remove(systemGroup);
+ if (aggregate.Count == 0)
+ {
+ _aggregates.Remove(systemGroupType);
+ playerLoop.RemoveAggregate(aggregate);
+ }
}
- }
- }
+ }
- public bool TryGetValue(Type systemGroupType, out ISystemGroupAggregate aggregate) => _aggregates.TryGetValue(systemGroupType, out aggregate);
+ public bool TryGetValue(Type systemGroupType, out ISystemGroupAggregate aggregate) => _aggregates.TryGetValue(systemGroupType, out aggregate);
- public bool TryGetValue(Type systemGroupType, out ISystemGroupAggregate aggregate)
- {
- if (_aggregates.TryGetValue(systemGroupType, out var value))
+ public bool TryGetValue(Type systemGroupType, out ISystemGroupAggregate aggregate)
{
- aggregate = (ISystemGroupAggregate) value;
- return true;
- }
+ if (_aggregates.TryGetValue(systemGroupType, out var value))
+ {
+ aggregate = (ISystemGroupAggregate) value;
+ return true;
+ }
- aggregate = default;
- return false;
+ aggregate = default;
+ return false;
+ }
}
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/PlayerLoopHelper/DebouncedComparer.cs b/Arch.SystemGroups/PlayerLoopHelper/DebouncedComparer.cs
index 6995b5b..40fa2fc 100644
--- a/Arch.SystemGroups/PlayerLoopHelper/DebouncedComparer.cs
+++ b/Arch.SystemGroups/PlayerLoopHelper/DebouncedComparer.cs
@@ -1,19 +1,20 @@
using System.Collections.Generic;
-namespace Arch.SystemGroups;
-
-internal class DebouncedComparer : IComparer
+namespace Arch.SystemGroups
{
- private readonly IComparer _inner;
-
- public DebouncedComparer(IComparer inner)
+ internal class DebouncedComparer : IComparer
{
- _inner = inner;
- }
+ private readonly IComparer _inner;
+
+ public DebouncedComparer(IComparer inner)
+ {
+ _inner = inner;
+ }
- public int Compare(T x, T y)
- {
- var result = _inner.Compare(x, y);
- return result == 0 ? 1 : result;
+ public int Compare(T x, T y)
+ {
+ var result = _inner.Compare(x, y);
+ return result == 0 ? 1 : result;
+ }
}
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/PlayerLoopHelper/IPlayerLoop.cs b/Arch.SystemGroups/PlayerLoopHelper/IPlayerLoop.cs
index 7d026fa..c15e5db 100644
--- a/Arch.SystemGroups/PlayerLoopHelper/IPlayerLoop.cs
+++ b/Arch.SystemGroups/PlayerLoopHelper/IPlayerLoop.cs
@@ -1,30 +1,31 @@
using System;
-namespace Arch.SystemGroups;
-
-///
-/// Abstraction needed for Mocking or providing a custom implementation of injection into the Player Loop
-///
-public interface IPlayerLoop
+namespace Arch.SystemGroups
{
///
- /// Called before all other methods once for each world
+ /// Abstraction needed for Mocking or providing a custom implementation of injection into the Player Loop
///
- void OnWorldStartAppending();
+ public interface IPlayerLoop
+ {
+ ///
+ /// Called before all other methods once for each world
+ ///
+ void OnWorldStartAppending();
- ///
- /// Called after all and
- ///
- void OnWorldEndAppending();
+ ///
+ /// Called after all and
+ ///
+ void OnWorldEndAppending();
- ///
- /// Adds an aggregate of system groups to the player loop. It is called only once upon the first mentioning of .
- ///
- void AddAggregate(Type systemGroupType, ISystemGroupAggregate aggregate);
+ ///
+ /// Adds an aggregate of system groups to the player loop. It is called only once upon the first mentioning of .
+ ///
+ void AddAggregate(Type systemGroupType, ISystemGroupAggregate aggregate);
- ///
- /// Removes the given system group from the Unity Player Loop.
- ///
- ///
- void RemoveAggregate(ISystemGroupAggregate aggregate);
+ ///
+ /// Removes the given system group from the Unity Player Loop.
+ ///
+ ///
+ void RemoveAggregate(ISystemGroupAggregate aggregate);
+ }
}
diff --git a/Arch.SystemGroups/PlayerLoopHelper/PlayerLoopAddMode.cs b/Arch.SystemGroups/PlayerLoopHelper/PlayerLoopAddMode.cs
index f46a246..c70a52e 100644
--- a/Arch.SystemGroups/PlayerLoopHelper/PlayerLoopAddMode.cs
+++ b/Arch.SystemGroups/PlayerLoopHelper/PlayerLoopAddMode.cs
@@ -1,17 +1,18 @@
-namespace Arch.SystemGroups;
-
-///
-/// Determines whether the system should be added to the beginning or the end of the step of the player loop
-///
-internal enum PlayerLoopAddMode : byte
+namespace Arch.SystemGroups
{
///
- /// Add the system to the beginning of the step
+ /// Determines whether the system should be added to the beginning or the end of the step of the player loop
///
- Prepend,
+ internal enum PlayerLoopAddMode : byte
+ {
+ ///
+ /// Add the system to the beginning of the step
+ ///
+ Prepend,
- ///
- /// Add the system to the end of the step
- ///
- Append
+ ///
+ /// Add the system to the end of the step
+ ///
+ Append
+ }
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/PlayerLoopHelper/PlayerLoopHelper.cs b/Arch.SystemGroups/PlayerLoopHelper/PlayerLoopHelper.cs
index e69ae2a..13af0fc 100644
--- a/Arch.SystemGroups/PlayerLoopHelper/PlayerLoopHelper.cs
+++ b/Arch.SystemGroups/PlayerLoopHelper/PlayerLoopHelper.cs
@@ -1,106 +1,107 @@
using System.Collections.Generic;
using Arch.SystemGroups.DefaultSystemGroups;
-namespace Arch.SystemGroups;
-
-///
-/// Provides utilities to inject systems into the Unity Player Loop
-///
-public static class PlayerLoopHelper
+namespace Arch.SystemGroups
{
- internal static readonly Dictionary AggregatesCache = new (10);
-
///
- /// Retrieve all aggregates created from the given factory
+ /// Provides utilities to inject systems into the Unity Player Loop
///
- ///
- public static void GetAggregates(ISystemGroupAggregateFactory factory, List results) where TAggregate : ISystemGroupAggregate
+ public static class PlayerLoopHelper
{
- results.Clear();
- if (AggregatesCache.TryGetValue(factory, out var cache))
- cache.GetAllAggregates(results);
- }
+ internal static readonly Dictionary AggregatesCache = new (10);
- ///
- /// Append ECS world to the provided player loop, supports custom system group aggregates
- ///
- public static void AppendWorldToCurrentPlayerLoop(
- this IPlayerLoop playerLoop,
- ISystemGroupAggregate.IFactory systemGroupAggregateFactory,
- T data,
- InitializationSystemGroup initializationSystemGroup,
- SimulationSystemGroup simulationSystemGroup,
- PresentationSystemGroup presentationSystemGroup,
- PostRenderingSystemGroup postRenderingSystemGroup,
- PhysicsSystemGroup physicsSystemGroup,
- PostPhysicsSystemGroup postPhysicsSystemGroup)
- {
- playerLoop.OnWorldStartAppending();
+ ///
+ /// Retrieve all aggregates created from the given factory
+ ///
+ ///
+ public static void GetAggregates(ISystemGroupAggregateFactory factory, List results) where TAggregate : ISystemGroupAggregate
+ {
+ results.Clear();
+ if (AggregatesCache.TryGetValue(factory, out var cache))
+ cache.GetAllAggregates(results);
+ }
- playerLoop.AddSystemToPlayerLoop(data, initializationSystemGroup, systemGroupAggregateFactory);
- playerLoop.AddSystemToPlayerLoop(data, simulationSystemGroup, systemGroupAggregateFactory);
- playerLoop.AddSystemToPlayerLoop(data, presentationSystemGroup, systemGroupAggregateFactory);
- playerLoop.AddSystemToPlayerLoop(data, postRenderingSystemGroup, systemGroupAggregateFactory);
- playerLoop.AddSystemToPlayerLoop(data, physicsSystemGroup, systemGroupAggregateFactory);
- playerLoop.AddSystemToPlayerLoop(data, postPhysicsSystemGroup, systemGroupAggregateFactory);
+ ///
+ /// Append ECS world to the provided player loop, supports custom system group aggregates
+ ///
+ public static void AppendWorldToCurrentPlayerLoop(
+ this IPlayerLoop playerLoop,
+ ISystemGroupAggregate.IFactory systemGroupAggregateFactory,
+ T data,
+ InitializationSystemGroup initializationSystemGroup,
+ SimulationSystemGroup simulationSystemGroup,
+ PresentationSystemGroup presentationSystemGroup,
+ PostRenderingSystemGroup postRenderingSystemGroup,
+ PhysicsSystemGroup physicsSystemGroup,
+ PostPhysicsSystemGroup postPhysicsSystemGroup)
+ {
+ playerLoop.OnWorldStartAppending();
+
+ playerLoop.AddSystemToPlayerLoop(data, initializationSystemGroup, systemGroupAggregateFactory);
+ playerLoop.AddSystemToPlayerLoop(data, simulationSystemGroup, systemGroupAggregateFactory);
+ playerLoop.AddSystemToPlayerLoop(data, presentationSystemGroup, systemGroupAggregateFactory);
+ playerLoop.AddSystemToPlayerLoop(data, postRenderingSystemGroup, systemGroupAggregateFactory);
+ playerLoop.AddSystemToPlayerLoop(data, physicsSystemGroup, systemGroupAggregateFactory);
+ playerLoop.AddSystemToPlayerLoop(data, postPhysicsSystemGroup, systemGroupAggregateFactory);
- playerLoop.OnWorldEndAppending();
- }
+ playerLoop.OnWorldEndAppending();
+ }
- ///
- /// Add an ECS system to a specific point in the Unity player loop, so that it is updated every frame.
- /// The system groups are being inserted into their corresponding aggregate that is unique for each group type,
- /// the execution order of the system groups inside the aggregate is not guaranteed and must be expected to be used for independent worlds
- ///
- ///
- /// This function does not change the currently active player loop. If this behavior is desired, it's necessary
- /// to call PlayerLoop.SetPlayerLoop(playerLoop) after the systems have been removed.
- ///
- /// Additional data per world
- /// The ECS system to add to the player loop.
- /// Existing player loop to modify (e.g. PlayerLoop.GetCurrentPlayerLoop())
- /// Factory of System Group Aggregates
- private static void AddSystemToPlayerLoop(this IPlayerLoop playerLoop, in T data, SystemGroup systemGroup,
- ISystemGroupAggregate.IFactory systemGroupAggregateFactory)
- {
- if (systemGroup == null) return;
+ ///
+ /// Add an ECS system to a specific point in the Unity player loop, so that it is updated every frame.
+ /// The system groups are being inserted into their corresponding aggregate that is unique for each group type,
+ /// the execution order of the system groups inside the aggregate is not guaranteed and must be expected to be used for independent worlds
+ ///
+ ///
+ /// This function does not change the currently active player loop. If this behavior is desired, it's necessary
+ /// to call PlayerLoop.SetPlayerLoop(playerLoop) after the systems have been removed.
+ ///
+ /// Additional data per world
+ /// The ECS system to add to the player loop.
+ /// Existing player loop to modify (e.g. PlayerLoop.GetCurrentPlayerLoop())
+ /// Factory of System Group Aggregates
+ private static void AddSystemToPlayerLoop(this IPlayerLoop playerLoop, in T data, SystemGroup systemGroup,
+ ISystemGroupAggregate.IFactory systemGroupAggregateFactory)
+ {
+ if (systemGroup == null) return;
- var systemGroupType = systemGroup.GetType();
+ var systemGroupType = systemGroup.GetType();
- var aggregateCache = GetOrCreateAggregateCache(systemGroupAggregateFactory);
+ var aggregateCache = GetOrCreateAggregateCache(systemGroupAggregateFactory);
- // If there is no aggregate yet, add it
- if (!aggregateCache.TryGetValue(systemGroupType, out ISystemGroupAggregate aggregate))
- {
- aggregate = aggregateCache.Add(systemGroupType, systemGroupAggregateFactory);
- playerLoop.AddAggregate(systemGroupType, aggregate);
- }
+ // If there is no aggregate yet, add it
+ if (!aggregateCache.TryGetValue(systemGroupType, out ISystemGroupAggregate aggregate))
+ {
+ aggregate = aggregateCache.Add(systemGroupType, systemGroupAggregateFactory);
+ playerLoop.AddAggregate(systemGroupType, aggregate);
+ }
- aggregate.Add(data, systemGroup);
- }
+ aggregate.Add(data, systemGroup);
+ }
- private static SystemGroupAggregateCache GetOrCreateAggregateCache(ISystemGroupAggregateFactory factory)
- {
- if (AggregatesCache.TryGetValue(factory, out var cache)) return cache;
- AggregatesCache[factory] = cache = new SystemGroupAggregateCache();
- return cache;
- }
+ private static SystemGroupAggregateCache GetOrCreateAggregateCache(ISystemGroupAggregateFactory factory)
+ {
+ if (AggregatesCache.TryGetValue(factory, out var cache)) return cache;
+ AggregatesCache[factory] = cache = new SystemGroupAggregateCache();
+ return cache;
+ }
- ///
- /// Remove the system group from the player loop
- ///
- public static void RemoveFromPlayerLoop(this IPlayerLoop playerLoop, ISystemGroupAggregateFactory systemGroupAggregateFactory, SystemGroup systemGroup)
- {
- if (!AggregatesCache.TryGetValue(systemGroupAggregateFactory, out var cache))
- return;
+ ///
+ /// Remove the system group from the player loop
+ ///
+ public static void RemoveFromPlayerLoop(this IPlayerLoop playerLoop, ISystemGroupAggregateFactory systemGroupAggregateFactory, SystemGroup systemGroup)
+ {
+ if (!AggregatesCache.TryGetValue(systemGroupAggregateFactory, out var cache))
+ return;
- var systemGroupType = systemGroup.GetType();
- cache.Remove(playerLoop, systemGroupType, systemGroup);
+ var systemGroupType = systemGroup.GetType();
+ cache.Remove(playerLoop, systemGroupType, systemGroup);
- if (cache.Count > 0)
- return;
+ if (cache.Count > 0)
+ return;
- // Clean-up if there are no more system groups in the aggregate
- AggregatesCache.Remove(systemGroupAggregateFactory);
+ // Clean-up if there are no more system groups in the aggregate
+ AggregatesCache.Remove(systemGroupAggregateFactory);
+ }
}
}
\ No newline at end of file
diff --git a/Arch.SystemGroups/PlayerLoopHelper/UnityPlayerLoop.cs b/Arch.SystemGroups/PlayerLoopHelper/UnityPlayerLoop.cs
index c1a1dda..17bdf75 100644
--- a/Arch.SystemGroups/PlayerLoopHelper/UnityPlayerLoop.cs
+++ b/Arch.SystemGroups/PlayerLoopHelper/UnityPlayerLoop.cs
@@ -4,165 +4,166 @@
using UnityEngine.LowLevel;
using UnityEngine.PlayerLoop;
-namespace Arch.SystemGroups;
-
-///
-/// Single-threaded wrapper over Unity's PlayerLoop
-///
-public class UnityPlayerLoop : IPlayerLoop
+namespace Arch.SystemGroups
{
///
- /// Singleton instance
- ///
- public static readonly UnityPlayerLoop Instance = new();
-
- private PlayerLoopSystem _playerLoop;
-
- ///
- ///
+ /// Single-threaded wrapper over Unity's PlayerLoop
///
- public void OnWorldStartAppending()
+ public class UnityPlayerLoop : IPlayerLoop
{
- _playerLoop = PlayerLoop.GetCurrentPlayerLoop();
- }
+ ///
+ /// Singleton instance
+ ///
+ public static readonly UnityPlayerLoop Instance = new();
- ///
- ///
- ///
- public void OnWorldEndAppending()
- {
- PlayerLoop.SetPlayerLoop(_playerLoop);
- }
+ private PlayerLoopSystem _playerLoop;
- ///
- ///
- ///
- public void AddAggregate(Type systemGroupType, ISystemGroupAggregate aggregate)
- {
- var (playerLoopSystemType, addMode) = GetPlayerLoopSystemType(systemGroupType);
+ ///
+ ///
+ ///
+ public void OnWorldStartAppending()
+ {
+ _playerLoop = PlayerLoop.GetCurrentPlayerLoop();
+ }
- if (!AppendToPlayerLoopList(systemGroupType, aggregate.TriggerUpdate, ref _playerLoop, playerLoopSystemType,
- addMode))
- throw new ArgumentException($"Could not find PlayerLoopSystem with type={playerLoopSystemType}");
- }
+ ///
+ ///
+ ///
+ public void OnWorldEndAppending()
+ {
+ PlayerLoop.SetPlayerLoop(_playerLoop);
+ }
- ///
- ///
- ///
- ///
- public void RemoveAggregate(ISystemGroupAggregate aggregate)
- {
- // If there are no more system groups in the aggregate remove the aggregate itself
- var playerLoop = PlayerLoop.GetCurrentPlayerLoop();
+ ///
+ ///
+ ///
+ public void AddAggregate(Type systemGroupType, ISystemGroupAggregate aggregate)
+ {
+ var (playerLoopSystemType, addMode) = GetPlayerLoopSystemType(systemGroupType);
- if (RemoveFromPlayerLoopList(aggregate, ref playerLoop))
- PlayerLoop.SetPlayerLoop(playerLoop);
- }
+ if (!AppendToPlayerLoopList(systemGroupType, aggregate.TriggerUpdate, ref _playerLoop, playerLoopSystemType,
+ addMode))
+ throw new ArgumentException($"Could not find PlayerLoopSystem with type={playerLoopSystemType}");
+ }
- private static (Type, PlayerLoopAddMode) GetPlayerLoopSystemType(Type systemGroupType)
- {
- if (systemGroupType == typeof(InitializationSystemGroup))
- return (typeof(Initialization), PlayerLoopAddMode.Append);
+ ///