ConstructRegistry class

Public types

using TeardownFn = void(*)(void*)
using InitializedFn = void(*)(void*, WorldBase*)
using ShutdownFn = void(*)(void*)
using ReinitFn = void(*)(void*, WorldBase*)

Constructors, destructors, conversion operators

ConstructRegistry() defaulted
~ConstructRegistry()
ConstructRegistry(const ConstructRegistry&) deleted

Public functions

auto operator=(const ConstructRegistry&) -> ConstructRegistry& deleted
template<typename T, typename PreInit = std::nullptr_t>
auto Create(WorldBase* InWorld, PreInit&& preInit = nullptr) -> T*
auto WireNetRef(void* ptr, ConstructNetHandle serverHandle, ConstructNetManifest manifest, uint32_t typeHash, uint32_t spawnFrame) -> ConstructRef
auto AllocateNetRef(void* ptr, uint8_t ownerID, ConstructNetManifest manifest, uint32_t typeHash, int64_t prefabIDRaw, uint32_t spawnFrame = 0) -> ConstructRef
template<typename T>
auto CreateForReplication(WorldBase* InWorld, EntityHandle* viewHandles, uint8_t viewCount, Soul* ownerSoul) -> T*
void Destroy(uint32_t id)
void DestroyByNetHandle(ConstructNetHandle handle)
void SetNetDestroyHook(void* ptr, ConstructNetHandle handle, void(*)(void*, ConstructNetHandle) fn, void* ctx)
Called by ReplicationSystem after RegisterConstruct to auto-deregister on destruction.
void ClearNetDestroyHooks()
void ProcessDeferredDestructions()
Process deferred destructions. Called by LogicThread at frame top.
void DestroyByLifetime(ConstructLifetime minSurviving)
void NotifyWorldTeardown(ConstructLifetime minSurviving)
void NotifyWorldInitialized(ConstructLifetime minSurviving, WorldBase* newWorld)
Re-initialize surviving Constructs on a fresh World and call OnWorldInitialized.
void DestroyAll()
Destroy everything.
auto GetCount() const -> uint32_t
template<typename Func>
void ForEach(Func&& fn)
template<typename Func>
void ForEachWithMeta(Func&& fn)
Variant that also passes the raw typeid name for editor display.
auto GetRecord(ConstructNetHandle handle) const -> ConstructRecord
auto IsHandleValid(ConstructNetHandle handle) const -> bool
auto IsHandleValid(const ConstructRef& ref) const -> bool
auto GetEarliestSpawnFrame() const -> uint32_t

Function documentation

ConstructRef ConstructRegistry::WireNetRef(void* ptr, ConstructNetHandle serverHandle, ConstructNetManifest manifest, uint32_t typeHash, uint32_t spawnFrame)

Wire a client-side Construct to the server-assigned ConstructNetHandle. Called by ReplicationSystem::HandleConstructSpawn — the server's handle is in the payload. Does NOT allocate a new NetIndex; uses the one already assigned by the server.

ConstructRef ConstructRegistry::AllocateNetRef(void* ptr, uint8_t ownerID, ConstructNetManifest manifest, uint32_t typeHash, int64_t prefabIDRaw, uint32_t spawnFrame = 0)

Allocate a network identity for a Construct that has already been created. Called by ArenaMode (Standalone) and ReplicationSystem::RegisterConstruct (networked). Allocate a net identity for a Construct (server or standalone). Returns a valid ConstructRef with a non-zero NetIndex.

template<typename T>
T* ConstructRegistry::CreateForReplication(WorldBase* InWorld, EntityHandle* viewHandles, uint8_t viewCount, Soul* ownerSoul)

Create a Construct using the replication path (client-side). Calls InitializeForReplication(world, handles, count) instead of Initialize(world). ownerSoul is set on the Construct before InitializeForReplication so ownership checks (e.g. SetActiveCameraIfOwned) work correctly during initialization.

void ConstructRegistry::DestroyByNetHandle(ConstructNetHandle handle)

Destroy a Construct by its network handle. Searches Entry buckets for the matching pointer (same pattern as SetNetDestroyHook). Safe to call on Logic thread.

void ConstructRegistry::ClearNetDestroyHooks()

Clear all net destroy hooks — called by ReplicationSystem on destruction to prevent stale callbacks after the system is torn down.

void ConstructRegistry::DestroyByLifetime(ConstructLifetime minSurviving)

Destroy all Constructs with lifetime below minSurviving. e.g., DestroyByLifetime(Session) destroys Level + World Constructs. Destructors run Construct::Shutdown() which deregisters ticks.

void ConstructRegistry::NotifyWorldTeardown(ConstructLifetime minSurviving)

Call OnWorldTeardown on all surviving Constructs (lifetime >= minSurviving). Then call Shutdown to deregister ticks from the old World's LogicThread.

uint32_t ConstructRegistry::GetEarliestSpawnFrame() const

Returns the earliest SpawnFrame across all live Construct records. Used by LogicThread to clamp rollback targets — we must never roll back to before the oldest Construct was spawned, as there is no replay event to re-create it.