Registry class

Central entity management system.

Manages three independent handle spaces:

  • GlobalEntityHandle (GHandle) — internal record identity; indexes Records[].
  • EntityHandle (LHandle) — OOP / Construct-facing handle; indexes LocalToRecord[].
  • EntityNetHandle (NetHandle) — network replication handle; indexes NetToRecord[].

Index 0 is reserved / invalid in all three spaces.

Creation flow:

  1. CreateInternal(classID, span<GHandle>) — allocates records and archetype slots.
  2. MakeEntityHandle(GHandle, classID) — allocates a local index, wires LocalToRecord.
  3. Public API (Create<T>, CreateByClassID) — wraps the above, returns EntityHandle.

Destruction flow:

  1. Destroy(LHandle) — defers GHandle to PendingDestructions.
  2. ProcessDeferredDestructions — removes from archetype, calls FreeGlobalHandle.
  3. FreeGlobalHandle — reclaims record index, queues local / net handle recycling.
  4. ConfirmLocalRecycles / ConfirmNetRecycles — moves pending → free after the safety window.

Public types

struct ServerEventEntry

Public static functions

static void WriteEntityTransformFields(void*const* fieldArrayTable, const Archetype* arch, uint32_t localIdx, SimFloat posX, SimFloat posY, SimFloat posZ, SimFloat rotQx, SimFloat rotQy, SimFloat rotQz, SimFloat rotQw)

Constructors, destructors, conversion operators

Registry()
Registry(const EngineConfig* config)
~Registry()

Public functions

template<typename T>
auto Create() -> EntityHandle
template<typename T, std::invocable<T&> Fn>
auto Create(Fn&& fn) -> EntityHandle
template<typename T>
auto Create(size_t count) -> std::vector<EntityHandle>
template<std::invocable<EntityRecord&, void**> Fn>
auto CreateByClassID(ClassID classID, Fn&& fn) -> EntityHandle
void Recreate(EntityHandle& inHandle)
template<typename T>
void RecreateAs(EntityHandle& inHandle)
void RecreateAs(EntityHandle& inHandle, const EntityHandle& asHandle)
void Destroy(EntityHandle lHandle)
void DestroyByGlobalHandle(GlobalEntityHandle gHandle)
void ForceDestroyByGlobalHandle(GlobalEntityHandle gHandle)
void ProcessDeferredDestructions()
void ConfirmTombstone(uint32_t recordIndex)
auto IsTombstoned(uint32_t recordIndex) const -> bool
template<typename T>
auto HasComponent(EntityHandle lHandle) -> bool
template<typename... Components>
auto ComponentQuery() -> std::vector<Archetype*>
template<typename... Classes>
auto ClassQuery() -> std::vector<Archetype*>
void InvokeScalarUpdate(SimFloat dt)
void InvokePrePhys(SimFloat dt)
void InvokePostPhys(SimFloat dt)
void TickDefrag(TrinyxJobs::WorldQueueHandle wq)
void ForceDefragSync()
auto GetVolatileCache() -> ComponentCache<CacheTier::Volatile>*
auto GetTemporalCache() -> ComponentCache<CacheTier::Temporal>*
auto SweepAliveFlagsToActive() -> int
auto CheckAndCorrectEntityTransform(const EntityTransformCorrection& correction) -> bool
void PushServerEvent(ServerEventEntry entry)
void ReplayServerEventsAt(uint32_t frame)
void PruneServerEvents(uint32_t oldestFrame)
void PushEntityReinitEvent(GlobalEntityHandle gHandle, uint32_t frame)
auto GetTotalChunkCount() const -> uint32_t
auto GetTotalEntityCount() const -> uint32_t
auto GetArchetypes() const -> const auto&
auto GetRecordByCache(EntityCacheHandle cacheHandle) const -> EntityRecord
auto GetRecord(EntityHandle handle) const -> EntityRecord
template<typename T, void(T::*)(uint32_t, uint32_t) MemFn>
void BindOnCacheSlotChange(EntityHandle handle, T* obj)
template<typename T, void(T::*)(uint32_t, uint32_t) MemFn>
void UnbindOnCacheSlotChange(EntityHandle handle, T* obj)
auto FindEntityByLocation(EntityCacheHandle cacheHandle) const -> GlobalEntityHandle

Public variables

std::atomic<uint32_t> RenderAck
uint32_t LastPublishedFrame
bool RenderHasAcked
bool ReplicationActive