ECS Overview
SafiEngine's ECS is flecs. flecs is a pure-C archetype ECS with components, queries, systems, pipelines, observers, hierarchies, and prefabs. If you know Bevy, you already know flecs.
Bevy → flecs concept map
Pipeline phases
SafiEngine runs three pipelines per frame:
Use EcsOnUpdate for gameplay, SafiFixedUpdate for physics and deterministic simulation, and EcsOnStore for rendering. See Scheduler & Stages for the details and the accumulator model.
:::warning WIP — Scheduling gaps
- Startup stage — no one-shot startup system registration API
- System ordering API — only raw flecs
ecs_dependsonphase ordering; no explicit before/after dependencies :::
Minimal example
Parent/child hierarchy
flecs models hierarchy via the built-in EcsChildOf relationship. SafiEngine wraps that with cycle-rejecting helpers in safi/ecs/hierarchy.h so hand-edited scene files, future drag-reparent UI, and tests all go through one code path:
Passing parent = 0 is equivalent to safi_entity_detach_from_parent. The transform propagation system traverses EcsChildOf in topological order so a legal reparent mid-frame picks up the correct world matrix the next frame.