Sparse-set storage
O(1) component access and dense arrays for cache-friendly iteration. 8-byte generational entities protect against stale handles.
Components
Lightweight Entity Component System with O(1) component access, reactive filters and zero-allocation iteration.
Components are plain structs. Systems declare what they need with attributes, and the source generator writes their Init.
partial class MoveSystem : IRunSystem {
[Inc(typeof(Position), typeof(Velocity))] [Exc(typeof(Frozen))]
Filter _moving;
[Pool] ComponentPool<Position> _positions;
[Pool] ComponentPool<Velocity> _velocities;
public void Run(World world) {
foreach (int e in _moving) {
ref var pos = ref _positions.Get(e);
ref var vel = ref _velocities.Get(e);
pos.X += vel.X;
pos.Y += vel.Y;
}
}
}struct Position : IComponent { public float X, Y; }
struct Velocity : IComponent { public float X, Y; }
struct Frozen : IComponent { }var world = new World();
var systems = new SystemsRunner(world)
.Add(new MoveSystem());
systems.Init(); // generated Init fills the fields
var entity = world.CreateEntity(new Position());
world.Add(entity, new Velocity { X = 1, Y = 2 });
systems.Run(); // once per frameWalk through a complete program in the Quick Start, see how it compares in the benchmarks and against other ECS frameworks, or browse the API reference.

Horde is a survivors-like game built on KenseiECS that runs in your browser on .NET WebAssembly. The horde grows to thousands of enemies; the stress slider pushes the world past 20,000 live entities.