Arch.System
Arch.System, a basis for nesting logic in systems.
With Arch.System
you can organize your queries in Systems
and call and reuse them at will.
Example
public class MovementSystem :
{
private QueryDescription _desc = new QueryDescription().WithAll<Position, Velocity>();
public MovementSystem(World world) : base(world) {}
// Can be called once per frame
public override void Update(in )
{
// Run query, can also run multiple queries inside the update method
World.Query(in _desc, (ref Position pos, ref Velocity vel) => {
pos.X += vel.X;
pos.Y += vel.Y;
});
}
}
Now we already have a MovementSystem
, a System
that groups everything that makes our Entities
move. But how do we integrate this now?
// Create a world and a group of systems which will be controlled
var world = World.Create();
var _systems = new Group<float>(
new MovementSystem(world),
new PhysicsSystem(world),
new DamageSystem(world),
new WorldGenerationSystem(world),
new OtherGroup(world)
);
_systems.Initialize(); // Inits all registered systems
_systems.BeforeUpdate(in deltaTime); // Calls .BeforeUpdate on all systems ( can be overriden )
_systems.Update(in deltaTime); // Calls .Update on all systems ( can be overriden )
_systems.AfterUpdate(in deltaTime); // Calls .AfterUpdate on all System ( can be overriden )
_systems.Dispose(); // Calls .Dispose on all systems ( can be overriden )
And we have already divided our Systems
into Group<T>
s to bring order into it. What more could you want?
Last updated
Was this helpful?