This chapter is about the metadata layer that lets component and resource state stay descriptive at runtime. It connects constructors, component ids, and snapshot-friendly type information.
The Two Type Layers
The storage side and the reflection side solve different problems:
TypeStorein World maps constructors to compact component ids and storesComponentInfoTypeRegistrymaps type ids to richerTypeEntryrecords andTypeInfoshapes
TypeStore is about component bookkeeping. TypeRegistry is about describing the type itself.
Runtime Identity
The type layer is the bridge between constructors and type ids. typeid() turns a constructor into a stable TypeId, typeidGeneric() builds generic-looking ids from constructor lists, and setTypeId() exists for synthetic cases where no runtime constructor exists.
That is why the engine can talk about EntityHandle, Array<Field>, or Map<TypeId, MethodEntry> at runtime without falling back to ad hoc strings.
TypeInfo Shapes
The reflection layer provides the actual metadata forms:
OpaqueInfofor values that are treated as atomicStructInfofor named fieldsEnumInfofor named numeric variantsFunctionInfofor callable signaturesArrayInfo,SetInfo,MapInfo, andTupleInfofor container and tuple shapes
registry.register(EntityHandle, new StructInfo({
index: new Field(typeid(Number)),
generation: new Field(typeid(Number))
}))
That is the pattern used by registerCoreTypes() in the core package: register the type, describe its shape, and attach methods when the type needs custom runtime behavior.
Why Snapshots Depend On This
Snapshot code and scene loading need a way to ask, “what is this value?” without hard-coding every package’s classes. Reflection metadata gives them that answer.
When a type entry also exposes methods like serialize, deserialize, toSnapshot, fromSnapshot, clone, or patch, higher-level systems can move data between live component/resource state and serialized data without guessing at the value’s shape.
That is the connection to Snapshots: reflection tells snapshot code how to read and rebuild state.
