Skip to main content

Clutch

Clutch is an entity component system (ECS) for Zig, inspired by bevy_ecs. It's named after a group of eggs, and it's the ECS behind the eggy engine.

An entity is just an id. Its data lives in components, which are plain Zig values of any type. Systems are functions that work on every entity with a given set of components, and schedules run them in order.

What's in the box​

AreaTypes and functions
WorldWorld: spawn, despawn, addComponent, removeComponent, get
QueriesQuery, with the filters With, Without, Added, Changed and Removed
SystemsSchedule, Stages, Commands, Res and ResMut
Resources and eventsinsertResource, getResource, sendEvent, EventReader
HierarchysetParent, getParent, children, despawnRecursive
HooksonAdd, onRemove
Bulk workspawnBatch, addComponents, removeComponents, despawnBatch, reserve

How it stores data​

Each component type gets its own sparse set, the design EnTT and pico_ecs use. Looking up, adding or removing a component is a couple of array operations, and a query walks the packed values of the smallest component storage it needs. Performance covers what that means for your code.

Where to go next​