ReflectionRegistry class
Singleton registry for all type metadata. The single source of truth.
Merges entity type metadata (signatures, lifecycle function pointers), component field decomposition, FlowState / GameMode factory registrations, ModeMixin IDs, and SoulRPC dispatch tables into one place.
Populated at static-init time by registration macros (TNX_REGISTER_ENTITY, TNX_REGISTER_COMPONENT, TNX_REGISTER_STATE, TNX_REGISTER_MODE). Read-only after TrinyxEngine::.
Supports baking to a file for deterministic IDs across builds. When a baked snapshot is loaded, its IDs are authoritative and function pointers / factories are merged by name.
Public types
- struct ConstructEntry
- struct MixinEntry
- struct ModeEntry
- struct RPCEntry
- struct StateEntry
- using StateFactory = std::function<std::unique_ptr<FlowState>()>
- using ModeFactory = std::function<std::unique_ptr<GameMode>()>
- using ConstructClientFactory = void*(*)(ConstructRegistry*, WorldBase*, EntityHandle*, uint8_t viewCount, Soul*ownerSoul)
Public static variables
- static uint8_t MixinUserBandStart constexpr
- static uint8_t MixinUserBandEnd constexpr
Public static functions
- static auto Get() -> ReflectionRegistry&
- static auto UUIDFromName(const char* name) -> int64_t
- Compute a deterministic UUID from a type + name (FNV-1a hash).
- static auto ConstructTypeHashFromName(const char* name) -> uint16_t
Public functions
-
template<typename T>void RegisterPrefab()
-
template<typename C, typename T>void RegisterPrefabComponent()
- void RegisterFields(ComponentTypeID typeID, const char* name, std::vector<FieldMeta>&& fields, CacheTier tier, uint8_t slot)
- auto GetEntityByName(std::string_view name) const -> ClassID
- auto GetFields(ComponentTypeID typeID) const -> const std::vector<FieldMeta>*
- auto IsDecomposed(ComponentTypeID typeID) const -> bool
- auto GetFieldCount(ComponentTypeID typeID) const -> size_t
- auto GetTemporalTier(ComponentTypeID typeID) const -> CacheTier
- auto GetCacheSlotIndex(ComponentTypeID typeID) const -> uint8_t
- auto GetComponentMeta(ComponentTypeID typeID) const -> const ComponentMetaEx&
- auto GetComponentByName(std::string_view name) const -> ComponentTypeID
- auto GetAllComponents() const -> const std::unordered_map<ComponentTypeID, ComponentMetaEx>&
- void SetCacheSlotIndex(ComponentTypeID typeID, uint8_t slot)
- void RegisterState(const char* name, StateFactory factory)
- void RegisterMode(const char* name, ModeFactory factory)
- auto FindStateFactory(const char* name) const -> StateFactory
- auto FindModeFactory(const char* name) const -> ModeFactory
- auto FindStateByUUID(int64_t uuid) const -> StateFactory
- auto FindModeByUUID(int64_t uuid) const -> ModeFactory
- void RegisterMixin(const char* name, uint8_t baseTypeID, bool isUserDefined)
- auto FindMixin(const char* name) const -> const MixinEntry*
- auto FindMixinByID(uint8_t baseTypeID) const -> const MixinEntry*
- void RegisterServerRPC(uint16_t methodID, uint16_t paramSize, SoulRPCHandler handler)
- void RegisterClientRPC(uint16_t methodID, uint16_t paramSize, SoulRPCHandler handler)
- auto DispatchServerRPC(Soul* soul, const RPCContext& ctx, const RPCHeader& hdr, const uint8_t* params) const -> bool
- auto DispatchClientRPC(Soul* soul, const RPCContext& ctx, const RPCHeader& hdr, const uint8_t* params) const -> bool
- void PublishToAssetRegistry() const
- Publish code-registered types (states, modes, entities) into AssetRegistry.
- void RegisterConstruct(const char* name, uint16_t typeHash, ConstructClientFactory factory)
- auto FindConstructClientFactory(uint16_t typeHash) const -> ConstructClientFactory
Public variables
- std::unordered_map<ClassID, ComponentSignature> ClassToArchetype
- std::unordered_map<ClassID, std::vector<ComponentTypeID>> ClassToComponentList
- std::unordered_map<Signature, std::vector<ClassID>> ArchetypeToClass
- std::unordered_map<ClassID, SystemID> ClassSystemID
- EntityMeta EntityGetters
- std::unordered_map<ComponentTypeID, ComponentMetaEx> ComponentData
- std::unordered_map<std::string, ClassID> NameToClassID
- std::unordered_map<std::string, ComponentTypeID> NameToComponentID
- std::vector<StateEntry> RegisteredStates
- std::vector<ModeEntry> RegisteredModes
- std::unordered_map<int64_t, size_t> StateUUIDIndex
- std::unordered_map<int64_t, size_t> ModeUUIDIndex
- std::vector<MixinEntry> RegisteredMixins
- std::unordered_map<uint8_t, size_t> MixinIDIndex
- std::vector<ConstructEntry> RegisteredConstructs
Function documentation
static uint16_t ReflectionRegistry:: ConstructTypeHashFromName(const char* name)
Compute a 16-bit type hash from a Construct type name. Used as ConstructNetManifest::PrefabIndex to identify the type on the client.