diff --git a/examples/TicTacToe/Systems/RenderSystem.cs b/examples/TicTacToe/Systems/RenderSystem.cs index a20b454..ad061da 100644 --- a/examples/TicTacToe/Systems/RenderSystem.cs +++ b/examples/TicTacToe/Systems/RenderSystem.cs @@ -7,13 +7,6 @@ namespace TicTacToe; /// public class RenderSystem : ISystem { - public QueryDescriptor Query { get; } - - public RenderSystem(World world) - { - Query = world.Query().With().Build(); - } - public void Run(World world) { var state = world.ReadSingleton(); @@ -66,4 +59,4 @@ public class RenderSystem : ISystem Console.WriteLine(); Console.Write(" Enter row col (e.g. \"1 2\"): "); } -} +} \ No newline at end of file diff --git a/examples/TicTacToe/Systems/WinCheckSystem.cs b/examples/TicTacToe/Systems/WinCheckSystem.cs index 185d2d1..cb56ec1 100644 --- a/examples/TicTacToe/Systems/WinCheckSystem.cs +++ b/examples/TicTacToe/Systems/WinCheckSystem.cs @@ -8,13 +8,6 @@ namespace TicTacToe; /// public class WinCheckSystem : ISystem { - public QueryDescriptor Query { get; } - - public WinCheckSystem(World world) - { - Query = world.Query().With().With().Build(); - } - public void Run(World world) { ref var state = ref world.GetSingleton(); @@ -25,7 +18,8 @@ public class WinCheckSystem : ISystem // Build a 3×3 grid of marks using the iterator API. var grid = new Player[3, 3]; - using var iter = world.Select(Query); + var query = world.Query().With().With().Build(); + using var iter = world.Select(query); while (iter.MoveNext()) { grid[iter.Current1.Row, iter.Current1.Col] = iter.Current2.Player; @@ -87,4 +81,4 @@ public class WinCheckSystem : ISystem state.Status = winner == Player.X ? GameStatus.XWon : GameStatus.OWon; world.MarkModified(World.SingletonEntity); } -} +} \ No newline at end of file diff --git a/src/OECS/ISystem.cs b/src/OECS/ISystem.cs index 0aab965..4ed3d14 100644 --- a/src/OECS/ISystem.cs +++ b/src/OECS/ISystem.cs @@ -2,15 +2,10 @@ namespace OECS; /// /// A system that runs on every tick. -/// Systems declare a query and receive the world in their method. +/// Systems receive the world in their method. /// public interface ISystem { - /// - /// The query that defines which entities this system operates on. - /// - QueryDescriptor Query { get; } - /// /// Executes the system logic for this tick. /// diff --git a/tests/OECS.Tests/CommandTests.cs b/tests/OECS.Tests/CommandTests.cs index 2f55293..f5371a0 100644 --- a/tests/OECS.Tests/CommandTests.cs +++ b/tests/OECS.Tests/CommandTests.cs @@ -249,13 +249,10 @@ public class CommandTests private readonly World _world; private readonly SpawnCommand _command; - public QueryDescriptor Query { get; } - public CommandEnqueueSystem(World world, SpawnCommand command) { _world = world; _command = command; - Query = world.Query().With().Build(); } public void Run(World world) @@ -266,18 +263,17 @@ public class CommandTests private class EntityCountObserver : ISystem { + private readonly QueryDescriptor _query; public int SeenCount { get; private set; } - public QueryDescriptor Query { get; } - public EntityCountObserver(World world) { - Query = world.Query().With().Build(); + _query = world.Query().With().Build(); } public void Run(World world) { - world.ForEach(Query, (Entity e, ref TestPosition pos) => + world.ForEach(_query, (Entity e, ref TestPosition pos) => { SeenCount++; }); diff --git a/tests/OECS.Tests/QueryAndSystemTests.cs b/tests/OECS.Tests/QueryAndSystemTests.cs index 832273f..eb437d0 100644 --- a/tests/OECS.Tests/QueryAndSystemTests.cs +++ b/tests/OECS.Tests/QueryAndSystemTests.cs @@ -175,11 +175,11 @@ public class SystemTests private class MovementSystem : ITickedSystem { - public QueryDescriptor Query { get; } + private readonly QueryDescriptor _query; public MovementSystem(World world) { - Query = world.Query().With().With().Build(); + _query = world.Query().With().With().Build(); } public void Run(World world) => Run(world, Tick.Logical()); @@ -187,7 +187,7 @@ public class SystemTests public void Run(World world, Tick tick) { float dt = tick.DeltaTime; - world.ForEach(Query, (Entity entity, ref Position pos, ref Velocity vel) => + world.ForEach(_query, (Entity entity, ref Position pos, ref Velocity vel) => { pos.X += vel.X * dt; pos.Y += vel.Y * dt; @@ -232,13 +232,11 @@ public class SystemTests private class TestLogicalSystem : ITickedSystem { - public QueryDescriptor Query { get; } public bool WasCalled { get; private set; } public Tick ReceivedTick { get; private set; } public TestLogicalSystem(World world) { - Query = world.Query().With().Build(); } public void Run(World world) => Run(world, Tick.Logical()); @@ -272,13 +270,10 @@ public class SystemTests private readonly int _id; private readonly List _order; - public QueryDescriptor Query { get; } - public OrderTrackingSystem(World world, int id, List order) { _id = id; _order = order; - Query = world.Query().With().Build(); } public void Run(World world) diff --git a/tests/OECS.Tests/ReactivityTests.cs b/tests/OECS.Tests/ReactivityTests.cs index 66eebe7..bae31be 100644 --- a/tests/OECS.Tests/ReactivityTests.cs +++ b/tests/OECS.Tests/ReactivityTests.cs @@ -268,12 +268,9 @@ public class ReactivityTests { private readonly World _world; - public QueryDescriptor Query { get; } - public EntityCreatorSystem(World world) { _world = world; - Query = world.Query().With().Build(); } public void Run(World world) diff --git a/tests/OECS.Tests/SingletonTests.cs b/tests/OECS.Tests/SingletonTests.cs index 11fc1c9..0e258c7 100644 --- a/tests/OECS.Tests/SingletonTests.cs +++ b/tests/OECS.Tests/SingletonTests.cs @@ -148,12 +148,9 @@ public class SingletonTests { private readonly World _world; - public QueryDescriptor Query { get; } - public TimeSystem(World world) { _world = world; - Query = world.Query().With().Build(); } public void Run(World world) => Run(world, Tick.Logical());