Home

Awesome

Arch.Extended

Maintenance Nuget License C#

Extensions for Arch with some useful features like Systems, Source Generator and Utils.

Download the packages and get started today!

dotnet add package Arch.System --version 1.0.5
dotnet add package Arch.System.SourceGenerator --version 1.2.1
dotnet add package Arch.EventBus --version 1.0.2
dotnet add package Arch.LowLevel --version 1.1.2
dotnet add package Arch.Relationships --version 1.0.0
dotnet add package Arch.Persistence --version 1.0.4
dotnet add package Arch.AOT.SourceGenerator --version 1.0.1

Features & Tools

Check the links and the Wiki!

Full code sample

With this package you are able to write and group queries and systems for Arch automatically. And all this with the best possible performance.

The tools can be used independently of each other.

// Components ( ignore the formatting, this saves space )
public struct Position{ float X, Y };
public struct Velocity{ float Dx, Dy };

// BaseSystem provides several useful methods for interacting and structuring systems
public class MovementSystem : BaseSystem<World, float>
{
    public MovementSystem(World world) : base(world) {}
    
    // Generates a query and calls that one automatically on BaseSystem.Update
    [Query]
    public void Move([Data] in float time, ref Position pos, ref Velocity vel)
    {
        pos.X += time * vel.X;
        pos.Y += time * vel.Y;
    }
    
    // Generates and filters a query and calls that one automatically on BaseSystem.Update in order
    [Query]
    [All<Player, Mob>, Any<Idle, Moving>, None<Alive>]  // Attributes also accept non generics :) 
    public void ResetVelocity(ref Velocity vel)
    {
        vel = new Velocity{ X = 0, Y = 0 };
    }
}

public class Game 
{
    public static void Main(string[] args) 
    {     
        var deltaTime = 0.05f; // This is mostly given by engines, frameworks
        
        // Create a world and a group of systems which will be controlled 
        var world = World.Create();
        var _systems = new Group<float>(
            new MovementSystem(world),   // Run in order
            new MyOtherSystem(...),
            ...
        );
      
        _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 )
    }
}