Sein Entity Pool
Struct · FSeinEntityPool
#include "Core/SeinEntityPool.h"
Dense, slot-indexed entity pool with generational handles.
Entities live in a flat array indexed by slot. Each slot has a generation counter that is incremented on every Release, invalidating any outstanding handles that still reference the old occupant.
C++ members (18)
void Initialize(int32 InitialCapacity);Pre-allocate arrays for the given capacity. Slot 0 is reserved.FSeinEntityHandle Acquire(const FFixedTransform& Transform, FSeinPlayerID OwnerID);Acquire a new entity from the pool. Pops a free slot (or grows the pool if none available), sets up the entity, and returns a valid generational handle.void Release(FSeinEntityHandle Handle);Release an entity back to the pool. The slot’s generation is incremented, invalidating existing handles. A slot at the maximum generation is retired instead of wrapping into ABA.FSeinEntity* Get(FSeinEntityHandle Handle);Get a mutable pointer to the entity at Handle, or nullptr if the handle is stale/invalid.FSeinEntity* GetForDeferredMutation(FSeinEntityHandle Handle);Mutable access that does not count as a change until CommitDeferredMutation is called serially, for disjoint-write parallel kernels.void CommitDeferredMutation(FSeinEntityHandle Handle);Publish an actual write obtained through GetForDeferredMutation.const FSeinEntity* Get(FSeinEntityHandle Handle) const;Get a const pointer to the entity at Handle, or nullptr if the handle is stale/invalid.bool IsValid(FSeinEntityHandle Handle) const;Check whether a handle still refers to a live entity.bool IsOccupied(FSeinEntityHandle Handle) const;True for a live entity, or a destroyed one whose slot and components wait for the next destroy pass.FSeinPlayerID GetOwner(FSeinEntityHandle Handle) const;Get the owner player ID for an entity.void SetOwner(FSeinEntityHandle Handle, FSeinPlayerID NewOwner);Set the owner player ID for an entity.int32 GetActiveCount() const;int32 GetCapacity() const;uint64 GetLatestMutationRevision() const;Counters derived caches use to notice changes. Not simulation state.uint64 GetTopologyRevision() const;int32 GetSlotGeneration(int32 SlotIndex) const;Current generation for a slot index, or 0 if the slot is out of range.void Reset();Reset pool to a clean state (keeps no allocations).bool Validate(TConstArrayView<FSeinEntityHandle> PendingDestroy, FString& OutError) const;Structural checks for a pool read from a save or the network. PendingDestroy lists the destroyed entities whose slots stay occupied until the next destroy pass.