Simple ECS (Entity Component System)
Composition over Inheritance: Entities are collections of components
Data-Oriented: Components are pure data, Systems contain logic
Template-Based: Type-safe generic component storage
Unique uint32_t identifier
Can have multiple components of different types
Pure data (no logic)
Example: Position {x, y}, Velocity {vx, vy}
Operates on entities with specific components
Example: MovementSystem updates Position based on Velocity
Find all entities with a specific set of components
world.Query<Position, Velocity>() returns entities with both
World world;
uint32_t player = world.CreateEntity();
world.AddComponent<Position>(player, {0 , 0 });
world.AddComponent<Velocity>(player, {1 , 0 });
// Update all moving entities
auto movingEntities = world.Query<Position, Velocity>();
for (uint32_t id : movingEntities) {
auto & pos = world.GetComponent <Position>(id);
auto & vel = world.GetComponent <Velocity>(id);
pos.x += vel.vx ;
pos.y += vel.vy ;
}
Template metaprogramming and static maps
Generic container design
How engines separate data from behavior