How hecs ECS architecture works
masterThe hecs architecture is a minimalist Entity-Component-System (ECS) designed for high performance and loose coupling.
- Entities: Represent distinct objects in your world.
- Components: Data associated with entities. An entity can have at most one component of any specific type.
- Systems: Instead of a formal 'System' abstraction, you implement behavior by querying the
Worldfor entities that match a specific set of component types. This allows you to organize your application logic however you prefer.
Internally, hecs uses an archetypal memory layout. It tracks groups of entities that share the same component types and stores them in dense, contiguous arrays. This provides excellent cache locality and allows for fast linear traversals during queries, similar to a columnar database.