-
-
Notifications
You must be signed in to change notification settings - Fork 95
Home
Arch is a C# based Archetype Entity Component System (ECS).
Each Archetype stores its entities within 16 KB-sized chunks perfectly fitting into L1 Caches for maximum iteration performance.
This technique has two main advantages, first of all, it provides a great entity allocation speed and second, it lowers the cache misses to the best possible minimum.
It's incredibly fast, especially for well-architectured component structures.
Supports .NetStandard 2.1, .Net Core 6 and 7.
Since .NetStandard is supported, you may also use it with Unity.
Enough spoken, let's take a look at some code. Arch is bare minimum, easy to use, and efficient. Let's say we want to create some game entities and make them move based on their velocity, sounds complicated?
It's not! Arch does everything for you, you only need to define the entities and the logic.
public class Game {
public struct Position { public float x, y; }
public struct Velocity { public float dx, dy; }
public static void Main(string[] args) {
var world = World.Create();
var query = new QueryDescription{ All = new ComponentType[]{ typeof(Position), typeof(Velocity) }}; // Query all entities with Position AND Velocity components
// Create entities
for (var index = 0; index < 1000; index++)
var entity = world.Create(new Position{ x = 0, y = 0}, new Velocity{ dx = 1, dy = 1});
// Query and modify entities ( There also alternatives without lambdas ;) )
world.Query(in query, (ref Position pos, ref Velocity vel) => {
pos.x += vel.dx;
pos.y += vel.dy;
});
}
}
Just start with the quickstart guide to get a first insight into the API, from there you can freely decide where to move next :)
- https://github.com/genaray/Arch/wiki/Quickstart
- https://github.com/genaray/Arch/wiki/Performance-tipps
- https://github.com/genaray/Arch/wiki/Advanced-usage
There's still a lot to come! https://github.com/users/genaray/projects/1
- Templates
- Entity events
- Systems ...