Arch icon indicating copy to clipboard operation
Arch copied to clipboard

Better systems

Open Shadowblitz16 opened this issue 1 year ago • 2 comments

var world = World.Create();
world.AddSystem(PlayerMoveSystem)

public static void PlayerMoveSystem((Transform Transform,  PlayerMovement Movement)[] components)
{
    foreach (var component in components)
    { 
        component.Transform.Position += component.Movement.Velocity;
    }
}

Shadowblitz16 avatar Sep 09 '24 01:09 Shadowblitz16

Have you looked at https://github.com/genaray/Arch.Extended/wiki/Source-Generator ? I would argue that its way better than bevy like systems tho :)

genaray avatar Sep 10 '24 10:09 genaray

Does it really require a constructor?

Shadowblitz16 avatar Sep 10 '24 21:09 Shadowblitz16

The suggestion doesn't seem to be actually even possible.

(Transform Transform, PlayerMovement Movement)[] is an array of a tuple of two components, in other words a reference (an array) to values (tuples) with two values (Transform and PlayerMovement). Any manipulation with component.Transform.Position changes only the tuple. And a tuple can't contain other references, because it's not a ref struct. So, the following is also not possible: (ref Transform Transform, ref PlayerMovement Movement)[].

stanoddly avatar Feb 25 '25 09:02 stanoddly

ok

Shadowblitz16 avatar Feb 27 '25 04:02 Shadowblitz16