Component Registry
The component registry is a central lookup table mapping each registered component's ecs_id_t to its human-readable name, serialize/deserialize callbacks (for scene files), an inspector draw callback, and a default_init factory used by the editor's "+ Add Component" flow and by the entity-preset helpers.
The scene serializer, the MicroUI inspector, and the editor's "+ Add Component" menu all query this table.
Registering a component
Stock engine components are registered automatically during safi_register_builtin_components. To register a custom component:
API
SafiComponentInfo
Callback signatures
Change bus
Every component registered with serializable=true is observed by the engine's change bus. On any ecs_set, subscribers receive a SafiChange { entity, component, frame, group_id }. The M6 undo ring subscribes here; editor tools that coalesce a batch of edits into a single undo step wrap the batch in safi_change_bus_begin_group / _end_group (gizmo drags already do this automatically).
The bus is gated on editor mode: callbacks only fire when SafiEditorState.mode == EDIT. Engine-internal writes during Play — notably the physics sync that touches SafiTransform every fixed step on every rigid body — are swallowed before subscribers see them, so undo history and inspector dirty tracking don't flood during gameplay. Subscribers that need the Play-time stream can observe the raw flecs EcsOnSet event directly; the bus is intentionally editor-centric.
See also
- Scene Serialization — uses the registry to serialize entities
- Stock Components — all 15 built-in components are registered