ARCHITECTURE Signal 410
Odin-based ECS library moecs simplifies entity-component registration and deferred mutations
A new Entity Component System written in Odin offers explicit element registration and deferred structural changes during world updates
Engineers building real-time simulations or games can adopt a simpler ECS workflow without sacrificing archetype safety. The library’s explicit registration and deferred mutation model reduces runtime surprises but requires upfront setup.
Written by elseif from the cluster below · every claim links back to a sourceThe three things worth knowing
Worlds, components, tags, resources, systems and relations must be registered before use
Structural changes (spawn/despawn, add/remove components) are deferred until the next world progress step
Immediate writes are allowed for resource and component values, but not for entity composition
THE READ
What the cluster adds up to.
The library moecs is an Entity Component System implemented in Odin. It requires explicit registration of every element type, components, tags, resources, systems and relations, before the world can run. This upfront declaration trades some boilerplate for predictable memory layout and clear ownership. Engineers must decide at design time which elements exist, reducing the risk of runtime typos or forgotten types.
Structural mutations such as spawning or despawning entities, adding or removing components, and setting or unsetting tags are deferred until the end of the current world progress step. This deferral keeps archetype iterators stable during a step, preventing iterator invalidation bugs. However, it means that queries inside systems will not see the changes until the next step, so engineers must plan game logic accordingly.
In contrast to deferred structural changes, writes to the values of resources, components and relations happen immediately. This distinction lets systems update velocities or game state without waiting for the next step, but it also means that engineers must avoid reading stale values if they rely on deferred changes. The library provides separate get() and get_mut() procedures to encourage read-only access where possible, improving performance.
Resources in moecs are singletons stored outside the entity-component graph. They are registered like other elements but live in their own storage. This design keeps global data such as physics parameters or sprite atlases accessible without attaching them to a dummy entity. Engineers must ensure resources are registered and set before use, and they are limited to a compile-time constant MAX_RESOURCES_COUNT unless the source is edited.
The library’s memory model is built around archetypes that group entities with identical component sets. Deferred structural changes ensure that archetypes are only updated between progress steps, maintaining iterator safety. Engineers gain predictable performance at the cost of a one-step delay in structural updates, a trade-off that simplifies debugging and profiling in real-time applications.
Written by elseif from the cluster below · checked for specifics the sources never containedTHE CLUSTER