UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FMassEntityManager Struct Reference

#include <MassEntityManager.h>

+ Inheritance diagram for FMassEntityManager:

Classes

struct  FScopedProcessing
 

Public Types

using FStructInitializationCallback = TFunctionRef< void(void *Fragment, const UScriptStruct &FragmentType)>
 
using FEntityCreationContext = UE::Mass::ObserverManager::FCreationContext
 
- Public Types inherited from FGCObject
enum class  EFlags : uint32 { None = 0 , RegisterLater = 1 << 0 , AddStableNativeReferencesOnly = 1 << 1 }
 

Public Member Functions

 DECLARE_MULTICAST_DELEGATE_OneParam (FOnNewArchetypeDelegate, const FMassArchetypeHandle &)
 
UE_API FMassEntityManager (UObject *InOwner=nullptr)
 
 FMassEntityManager (const FMassEntityManager &Other)=delete
 
virtual UE_API ~FMassEntityManager ()
 
virtual UE_API void AddReferencedObjects (FReferenceCollector &Collector) override
 
virtual FString GetReferencerName () const override
 
UE_API void GetResourceSizeEx (FResourceSizeEx &CumulativeResourceSize)
 
UE_API void Initialize ()
 
UE_API void Initialize (const FMassEntityManagerStorageInitParams &InitializationParams)
 
UE_API void PostInitialize ()
 
UE_API void Deinitialize ()
 
UE_API FMassArchetypeHandle CreateArchetype (TConstArrayView< const UScriptStruct * > FragmentsAndTagsList, const FMassArchetypeCreationParams &CreationParams=FMassArchetypeCreationParams())
 
UE_API FMassArchetypeHandle CreateArchetype (FMassArchetypeHandle SourceArchetype, TConstArrayView< const UScriptStruct * > FragmentsAndTagsList)
 
UE_API FMassArchetypeHandle CreateArchetype (FMassArchetypeHandle SourceArchetype, TConstArrayView< const UScriptStruct * > FragmentsAndTagsList, const FMassArchetypeCreationParams &CreationParams)
 
UE_API FMassArchetypeHandle CreateArchetype (const FMassArchetypeCompositionDescriptor &Composition, const FMassArchetypeCreationParams &CreationParams=FMassArchetypeCreationParams())
 
UE_API FMassArchetypeHandle CreateArchetype (const TSharedPtr< FMassArchetypeData > &SourceArchetype, const FMassFragmentBitSet &InFragments)
 
UE_API FMassArchetypeHandle CreateArchetype (const TSharedPtr< FMassArchetypeData > &SourceArchetype, const FMassFragmentBitSet &InFragments, const FMassArchetypeCreationParams &CreationParams)
 
UE_API FMassArchetypeHandle GetOrCreateSuitableArchetype (const FMassArchetypeHandle &ArchetypeHandle, const FMassSharedFragmentBitSet &SharedFragmentBitSet, const FMassConstSharedFragmentBitSet &ConstSharedFragmentBitSet, const FMassArchetypeCreationParams &CreationParams=FMassArchetypeCreationParams())
 
UE_API FMassArchetypeHandle GetArchetypeForEntity (FMassEntityHandle EntityHandle) const
 
UE_API FMassArchetypeHandle GetArchetypeForEntityUnsafe (FMassEntityHandle EntityHandle) const
 
UE_API void GetMatchingArchetypes (const FMassFragmentRequirements &Requirements, TArray< FMassArchetypeHandle > &OutValidArchetypes) const
 
UE_API void DoEntityCompaction (const double TimeAllowed)
 
UE_API FMassEntityHandle CreateEntity (const FMassArchetypeHandle &ArchetypeHandle, const FMassArchetypeSharedFragmentValues &SharedFragmentValues={})
 
UE_API FMassEntityHandle CreateEntity (TConstArrayView< FInstancedStruct > FragmentInstanceList, const FMassArchetypeSharedFragmentValues &SharedFragmentValues={}, const FMassArchetypeCreationParams &CreationParams=FMassArchetypeCreationParams())
 
UE_API TSharedRef< FEntityCreationContextGetOrMakeCreationContext ()
 
TSharedRef< UE::Mass::ObserverManager::FObserverLockGetOrMakeObserversLock ()
 
UE_API TSharedRef< FEntityCreationContextBatchCreateReservedEntities (const FMassArchetypeHandle &ArchetypeHandle, const FMassArchetypeSharedFragmentValues &SharedFragmentValues, TConstArrayView< FMassEntityHandle > ReservedEntities)
 
TSharedRef< FEntityCreationContextBatchCreateReservedEntities (const FMassArchetypeHandle &ArchetypeHandle, TConstArrayView< FMassEntityHandle > OutEntities)
 
UE_API TSharedRef< FEntityCreationContextBatchCreateEntities (const FMassArchetypeHandle &ArchetypeHandle, const FMassArchetypeSharedFragmentValues &SharedFragmentValues, const int32 Count, TArray< FMassEntityHandle > &InOutEntities)
 
TSharedRef< FEntityCreationContextBatchCreateEntities (const FMassArchetypeHandle &ArchetypeHandle, const int32 Count, TArray< FMassEntityHandle > &InOutEntities)
 
UE_API void DestroyEntity (FMassEntityHandle EntityHandle)
 
UE_API FMassEntityHandle ReserveEntity ()
 
UE_API void BuildEntity (FMassEntityHandle EntityHandle, const FMassArchetypeHandle &ArchetypeHandle, const FMassArchetypeSharedFragmentValues &SharedFragmentValues={})
 
UE_API void BuildEntity (FMassEntityHandle EntityHandle, TConstArrayView< FInstancedStruct > FragmentInstanceList, const FMassArchetypeSharedFragmentValues &SharedFragmentValues={})
 
UE_API void ReleaseReservedEntity (FMassEntityHandle EntityHandle)
 
UE_API void BatchDestroyEntities (TConstArrayView< FMassEntityHandle > InEntities)
 
UE_API void BatchDestroyEntityChunks (const FMassArchetypeEntityCollection &Collection)
 
UE_API void BatchDestroyEntityChunks (TConstArrayView< FMassArchetypeEntityCollection > Collections)
 
UE_API void BatchGroupEntities (const UE::Mass::FArchetypeGroupHandle GroupHandle, TConstArrayView< FMassArchetypeEntityCollection > Collections)
 
UE_API void BatchGroupEntities (const UE::Mass::FArchetypeGroupHandle GroupHandle, TConstArrayView< FMassEntityHandle > InEntities)
 
UE_API UE::Mass::FArchetypeGroupType FindOrAddArchetypeGroupType (const FName GroupName)
 
UE_API const UE::Mass::FArchetypeGroupsGetGroupsForArchetype (const FMassArchetypeHandle &ArchetypeHandle) const
 
UE_API void AddFragmentToEntity (FMassEntityHandle EntityHandle, const UScriptStruct *FragmentType)
 
UE_API void AddFragmentToEntity (FMassEntityHandle EntityHandle, const UScriptStruct *FragmentType, const FStructInitializationCallback &Initializer)
 
UE_API void AddFragmentListToEntity (FMassEntityHandle EntityHandle, TConstArrayView< const UScriptStruct * > FragmentList)
 
UE_API void AddFragmentInstanceListToEntity (FMassEntityHandle EntityHandle, TConstArrayView< FInstancedStruct > FragmentInstanceList)
 
UE_API void RemoveFragmentFromEntity (FMassEntityHandle EntityHandle, const UScriptStruct *FragmentType)
 
UE_API void RemoveFragmentListFromEntity (FMassEntityHandle EntityHandle, TConstArrayView< const UScriptStruct * > FragmentList)
 
UE_API void AddTagToEntity (FMassEntityHandle EntityHandle, const UScriptStruct *TagType)
 
UE_API void RemoveTagFromEntity (FMassEntityHandle EntityHandle, const UScriptStruct *TagType)
 
UE_API void SwapTagsForEntity (FMassEntityHandle EntityHandle, const UScriptStruct *FromFragmentType, const UScriptStruct *ToFragmentType)
 
void AddElementToEntities (TConstArrayView< FMassEntityHandle > Entities, TNotNull< const UScriptStruct * > ElementType)
 
void AddElementToEntity (FMassEntityHandle Entity, TNotNull< const UScriptStruct * > ElementType)
 
void RemoveElementFromEntities (TConstArrayView< FMassEntityHandle > Entities, TNotNull< const UScriptStruct * > ElementType)
 
void RemoveElementFromEntity (FMassEntityHandle Entity, TNotNull< const UScriptStruct * > ElementType)
 
bool DoesEntityHaveElement (FMassEntityHandle Entity, TNotNull< const UScriptStruct * > ElementType) const
 
UE_API bool AddConstSharedFragmentToEntity (const FMassEntityHandle EntityHandle, const FConstSharedStruct &InConstSharedFragment)
 
UE_API bool RemoveConstSharedFragmentFromEntity (const FMassEntityHandle EntityHandle, const UScriptStruct &ConstSharedFragmentType)
 
UE_API bool AddSharedFragmentToEntity (const FMassEntityHandle EntityHandle, const FSharedStruct &InSharedFragment)
 
UE_API bool RemoveSharedFragmentFromEntity (const FMassEntityHandle EntityHandle, const UScriptStruct &SharedFragmentType)
 
UE_API void RemoveEntityFromGroupType (FMassEntityHandle EntityHandle, UE::Mass::FArchetypeGroupType GroupType)
 
UE_API UE::Mass::FArchetypeGroupHandle GetGroupForEntity (FMassEntityHandle EntityHandle, UE::Mass::FArchetypeGroupType GroupType) const
 
UE_API TConstArrayView< FMassEntityHandleBatchReserveEntities (const int32 Count, TArray< FMassEntityHandle > &InOutEntities)
 
UE_API int32 BatchReserveEntities (TArrayView< FMassEntityHandle > InOutEntities)
 
UE_API TSharedRef< FEntityCreationContextBatchBuildEntities (const FMassArchetypeEntityCollectionWithPayload &EncodedEntitiesWithPayload, const FMassFragmentBitSet &FragmentsAffected, const FMassArchetypeSharedFragmentValues &SharedFragmentValues={}, const FMassArchetypeCreationParams &CreationParams=FMassArchetypeCreationParams())
 
UE_API TSharedRef< FEntityCreationContextBatchBuildEntities (const FMassArchetypeEntityCollectionWithPayload &EncodedEntitiesWithPayload, const FMassArchetypeCompositionDescriptor &Composition, const FMassArchetypeSharedFragmentValues &SharedFragmentValues={}, const FMassArchetypeCreationParams &CreationParams=FMassArchetypeCreationParams())
 
UE_API void BatchChangeTagsForEntities (TConstArrayView< FMassArchetypeEntityCollection > EntityCollections, const FMassTagBitSet &TagsToAdd, const FMassTagBitSet &TagsToRemove)
 
UE_API void BatchChangeFragmentCompositionForEntities (TConstArrayView< FMassArchetypeEntityCollection > EntityCollections, const FMassFragmentBitSet &FragmentsToAdd, const FMassFragmentBitSet &FragmentsToRemove)
 
UE_API void BatchAddFragmentInstancesForEntities (TConstArrayView< FMassArchetypeEntityCollectionWithPayload > EntityCollections, const FMassFragmentBitSet &FragmentsAffected)
 
UE_API void BatchAddSharedFragmentsForEntities (TConstArrayView< FMassArchetypeEntityCollection > EntityCollections, const FMassArchetypeSharedFragmentValues &AddedFragmentValues)
 
UE_API void AddCompositionToEntity_GetDelta (FMassEntityHandle EntityHandle, FMassArchetypeCompositionDescriptor &InOutDescriptor, const FMassArchetypeSharedFragmentValues *AddedSharedFragmentValues=nullptr)
 
UE_API void RemoveCompositionFromEntity (FMassEntityHandle EntityHandle, const FMassArchetypeCompositionDescriptor &InDescriptor)
 
UE_API const FMassArchetypeCompositionDescriptorGetArchetypeComposition (const FMassArchetypeHandle &ArchetypeHandle) const
 
UE_API void MoveEntityToAnotherArchetype (FMassEntityHandle EntityHandle, FMassArchetypeHandle NewArchetypeHandle, const FMassArchetypeSharedFragmentValues *SharedFragmentValuesOverride=nullptr)
 
UE_API void SetEntityFragmentValues (FMassEntityHandle EntityHandle, TArrayView< const FInstancedStruct > FragmentInstanceList)
 
UE_API void BatchSetEntityFragmentValues (const FMassArchetypeEntityCollection &SparseEntities, TArrayView< const FInstancedStruct > FragmentInstanceList)
 
UE_API void BatchSetEntityFragmentValues (TConstArrayView< FMassArchetypeEntityCollection > EntityCollections, TArrayView< const FInstancedStruct > FragmentInstanceList)
 
UE_API bool IsEntityActive (FMassEntityHandle EntityHandle) const
 
UE_API bool IsEntityValid (FMassEntityHandle EntityHandle) const
 
UE_API bool IsEntityBuilt (FMassEntityHandle EntityHandle) const
 
UE_API bool IsEntityReserved (FMassEntityHandle EntityHandle) const
 
void CheckIfEntityIsValid (FMassEntityHandle EntityHandle) const
 
void CheckIfEntityIsActive (FMassEntityHandle EntityHandle) const
 
UE_API FMassEntityHandle CreateEntityIndexHandle (const int32 EntityIndex) const
 
template<typename FragmentType >
FragmentType & GetFragmentDataChecked (FMassEntityHandle EntityHandle) const
 
template<typename FragmentType >
FragmentType * GetFragmentDataPtr (FMassEntityHandle EntityHandle) const
 
FStructView GetFragmentDataStruct (FMassEntityHandle EntityHandle, const UScriptStruct *FragmentType) const
 
template<typename ConstSharedFragmentType >
ConstSharedFragmentTypeGetConstSharedFragmentDataPtr (FMassEntityHandle EntityHandle) const
 
template<typename ConstSharedFragmentType >
ConstSharedFragmentTypeGetConstSharedFragmentDataChecked (FMassEntityHandle EntityHandle) const
 
FConstStructView GetConstSharedFragmentDataStruct (FMassEntityHandle EntityHandle, const UScriptStruct *ConstSharedFragmentType) const
 
template<typename SharedFragmentType >
TConstArrayView< FSharedStructGetSharedFragmentsOfType ()
 
template<typename SharedFragmentType >
SharedFragmentTypeGetSharedFragmentDataPtr (FMassEntityHandle EntityHandle) const
 
template<typename SharedFragmentType >
SharedFragmentTypeGetSharedFragmentDataChecked (FMassEntityHandle EntityHandle) const
 
FConstStructView GetSharedFragmentDataStruct (FMassEntityHandle EntityHandle, const UScriptStruct *SharedFragmentType) const
 
template<typename T >
FConstStructView GetElementDataStruct (FMassEntityHandle EntityHandle, TNotNull< const UScriptStruct * > FragmentType) const
 
uint32 GetArchetypeDataVersion () const
 
UE_API FMassExecutionContext CreateExecutionContext (const float DeltaSeconds)
 
FScopedProcessing NewProcessingScope ()
 
bool IsProcessing () const
 
FMassCommandBufferDefer () const
 
UE_API void FlushCommands (const TSharedPtr< FMassCommandBuffer > &InCommandBuffer)
 
UE_API void FlushCommands ()
 
UE_API void AppendCommands (const TSharedPtr< FMassCommandBuffer > &InOutCommandBuffer)
 
template<typename T >
const FConstSharedStructGetOrCreateConstSharedFragmentByHash (const uint32 Hash, const T &Fragment)
 
template<typename T , typename... TArgs>
const FSharedStructGetOrCreateSharedFragmentByHash (const uint32 Hash, TArgs &&... InArgs)
 
template<typename T >
const FConstSharedStructGetOrCreateConstSharedFragment (const T &Fragment)
 
template<typename T >
const FSharedStructGetOrCreateSharedFragment (const T &Fragment)
 
template<typename T , typename... TArgs>
const FConstSharedStructGetOrCreateConstSharedFragment (TArgs &&... InArgs)
 
template<typename T , typename... TArgs>
const FSharedStructGetOrCreateSharedFragment (TArgs &&... InArgs)
 
const FConstSharedStructGetOrCreateConstSharedFragment (const UScriptStruct &InScriptStruct, const uint8 *InStructMemory)
 
const FSharedStructGetOrCreateSharedFragment (const UScriptStruct &InScriptStruct, const uint8 *InStructMemory)
 
template<typename T , typename... TArgs>
const FConstSharedStructGetOrCreateConstSharedFragment (const FConstStructView HashingHelperStruct, TArgs &&... InArgs)
 
template<typename T , typename... TArgs>
const FSharedStructGetOrCreateSharedFragment (const FConstStructView HashingHelperStruct, TArgs &&... InArgs)
 
template<UE::Mass::CSharedFragment T>
void ForEachSharedFragment (TFunctionRef< void(T &) > ExecuteFunction)
 
template<UE::Mass::CSharedFragment T>
void ForEachSharedFragmentConditional (TFunctionRef< bool(T &) > ConditionFunction, TFunctionRef< void(T &) > ExecuteFunction)
 
template<UE::Mass::CConstSharedFragment T>
void ForEachConstSharedFragment (TFunctionRef< void(const T &) > ExecuteFunction)
 
template<UE::Mass::CConstSharedFragment T>
void ForEachConstSharedFragmentConditional (TFunctionRef< bool(const T &) > ConditionFunction, TFunctionRef< void(const T &) > ExecuteFunction)
 
UE::Mass::FRelationManagerGetRelationManager ()
 
template<UE::Mass::CRelation T>
bool BatchCreateRelations (TArrayView< FMassEntityHandle > Subjects, TArrayView< FMassEntityHandle > Objects)
 
UE_API bool BatchCreateRelations (const UE::Mass::FTypeHandle RelationTypeHandle, TArrayView< FMassEntityHandle > Subjects, TArrayView< FMassEntityHandle > Objects)
 
void OnNewTypeRegistered (UE::Mass::FTypeHandle RegisteredTypeHandle)
 
UE_API UE::Mass::FEntityBuilder MakeEntityBuilder ()
 
const UE::Mass::FTypeManagerGetTypeManager () const
 
UE::Mass::FTypeManagerGetTypeManager ()
 
FMassObserverManagerGetObserverManager ()
 
FOnNewArchetypeDelegateGetOnNewArchetypeEvent ()
 
UWorldGetWorld () const
 
UObjectGetOwner () const
 
bool IsDuringEntityCreation () const
 
UE_API void SetDebugName (const FString &NewDebugGame)
 
UE_API void SetEntityFragmentsValues (FMassEntityHandle EntityHandle, TArrayView< const FInstancedStruct > FragmentInstanceList)
 
template<UE::Mass::CConstSharedFragment T>
void ForEachSharedFragment (TFunctionRef< void(T &) > ExecuteFunction)
 
template<UE::Mass::CConstSharedFragment T>
void ForEachSharedFragmentConditional (TFunctionRef< bool(T &) > ConditionFunction, TFunctionRef< void(T &) > ExecuteFunction)
 
- Public Member Functions inherited from TSharedFromThis< FMassEntityManager >
TSharedRef< FMassEntityManager, Mode > AsShared ()
 
TSharedRef< FMassEntityManager const, Mode > AsShared () const
 
TSharedRef< SubobjectType, Mode > AsSharedSubobject (SubobjectType *SubobjectPtr) const
 
TWeakPtr< FMassEntityManager, Mode > AsWeak ()
 
TWeakPtr< FMassEntityManager const, Mode > AsWeak () const
 
TWeakPtr< SubobjectType, Mode > AsWeakSubobject (SubobjectType *SubobjectPtr) const
 
void UpdateWeakReferenceInternal (TSharedPtr< SharedPtrType, SharedPtrMode > const *InSharedPtr, OtherType *InObject) const
 
void UpdateWeakReferenceInternal (TSharedRef< SharedRefType, SharedPtrMode > const *InSharedRef, OtherType *InObject) const
 
UE_FORCEINLINE_HINT bool DoesSharedInstanceExist () const
 
- Public Member Functions inherited from FGCObject
 FGCObject ()
 
 FGCObject (const FGCObject &Other)
 
 FGCObject (FGCObject &&Other)
 
 FGCObject (EFlags Flags)
 
virtual ~FGCObject ()
 
FGCObjectoperator= (const FGCObject &)
 
FGCObjectoperator= (FGCObject &&)
 
COREUOBJECT_API void RegisterGCObject ()
 
COREUOBJECT_API void UnregisterGCObject ()
 
virtual bool GetReferencerPropertyName (UObject *Object, FString &OutPropertyName) const
 

Static Public Member Functions

static UE_API void ForEachArchetypeFragmentType (const FMassArchetypeHandle &ArchetypeHandle, TFunction< void(const UScriptStruct *)> Function)
 
static UE_API void BatchSetEntityFragmentsValues (const FMassArchetypeEntityCollection &SparseEntities, TArrayView< const FInstancedStruct > FragmentInstanceList)
 
static UE_API void BatchSetEntityFragmentsValues (TConstArrayView< FMassArchetypeEntityCollection > EntityCollections, TArrayView< const FInstancedStruct > FragmentInstanceList)
 
- Static Public Member Functions inherited from FGCObject
static COREUOBJECT_API void StaticInit ()
 

Public Attributes

friend FMassEntityQuery
 
friend FMassDebugger
 

Static Public Attributes

const static UE_API FMassEntityHandle InvalidEntity
 
- Static Public Attributes inherited from FGCObject
static COREUOBJECT_API UGCObjectReferencerGGCObjectReferencer = nullptr
 

Protected Member Functions

void OnRelationTypeRegistered (UE::Mass::FTypeHandle RegisteredTypeHandle, const UE::Mass::FRelationTypeTraits &RelationTypeTraits)
 
UE_API void OnPostFork (EForkProcessRole Role)
 
UE_API void GetMatchingArchetypes (const FMassFragmentRequirements &Requirements, TArray< FMassArchetypeHandle > &OutValidArchetypes, const uint32 FromArchetypeDataVersion) const
 
UE_API FMassArchetypeHandle InternalCreateSimilarArchetype (const TSharedPtr< FMassArchetypeData > &SourceArchetype, const FMassTagBitSet &OverrideTags)
 
UE_API FMassArchetypeHandle InternalCreateSimilarArchetype (const TSharedPtr< FMassArchetypeData > &SourceArchetype, const FMassFragmentBitSet &OverrideFragments)
 
UE_API FMassArchetypeHandle InternalCreateSimilarArchetype (const TSharedPtr< FMassArchetypeData > &SourceArchetype, const UE::Mass::FArchetypeGroups &GroupsOverride)
 
UE_API FMassArchetypeHandle InternalCreateSimilarArchetype (const FMassArchetypeData &SourceArchetypeRef, FMassArchetypeCompositionDescriptor &&NewComposition, const UE::Mass::FArchetypeGroups &GroupsOverride)
 
UE_API void InternalAppendFragmentsAndTagsToArchetypeCompositionDescriptor (FMassArchetypeCompositionDescriptor &InOutComposition, TConstArrayView< const UScriptStruct * > FragmentsAndTagsList) const
 
UE_API FMassArchetypeHandle InternalCreateSimilarArchetype (const FMassArchetypeData &SourceArchetypeRef, FMassArchetypeCompositionDescriptor &&NewComposition)
 
- Protected Member Functions inherited from TSharedFromThis< FMassEntityManager >
 TSharedFromThis ()
 
 TSharedFromThis (TSharedFromThis const &)
 
UE_FORCEINLINE_HINT TSharedFromThisoperator= (TSharedFromThis const &)
 
 ~TSharedFromThis ()
 

Friends

struct UE::Mass::Private::FEntityStorageInitializer
 

Additional Inherited Members

- Static Protected Member Functions inherited from TSharedFromThis< FMassEntityManager >
static UE_FORCEINLINE_HINT TSharedRef< OtherType, Mode > SharedThis (OtherType *ThisPtr)
 
static UE_FORCEINLINE_HINT TSharedRef< OtherType const, Mode > SharedThis (const OtherType *ThisPtr)
 

Detailed Description

The type responsible for hosting Entities managing Archetypes. Entities are stored as FEntityData entries in a chunked array. Each valid entity is assigned to an Archetype that stored fragments associated with a given entity at the moment.

FMassEntityManager supplies API for entity creation (that can result in archetype creation) and entity manipulation. Even though synchronized manipulation methods are available in most cases the entity operations are performed via a command buffer. The default command buffer can be obtained with a Defer() call.

See also
FMassCommandBuffer for more details.

FMassEntityManager are meant to be stored with a TSharedPtr or TSharedRef. Some of Mass API pass around FMassEntityManager& but programmers can always use AsShared() call to obtain a shared ref for a given manager instance (as supplied by deriving from TSharedFromThis<FMassEntityManager>). IMPORTANT: if you create your own FMassEntityManager instance remember to call Initialize() before using it.

Member Typedef Documentation

◆ FEntityCreationContext

◆ FStructInitializationCallback

Constructor & Destructor Documentation

◆ FMassEntityManager() [1/2]

FMassEntityManager::FMassEntityManager ( UObject InOwner = nullptr)
explicit

◆ FMassEntityManager() [2/2]

FMassEntityManager::FMassEntityManager ( const FMassEntityManager Other)
delete

◆ ~FMassEntityManager()

FMassEntityManager::~FMassEntityManager ( )
virtual

Member Function Documentation

◆ AddCompositionToEntity_GetDelta()

void FMassEntityManager::AddCompositionToEntity_GetDelta ( FMassEntityHandle  EntityHandle,
FMassArchetypeCompositionDescriptor InOutDescriptor,
const FMassArchetypeSharedFragmentValues AddedSharedFragmentValues = nullptr 
)

Adds elements indicated by InOutDescriptor to the entity indicated by EntityHandle. The function also figures out which elements in InOutDescriptor are missing from the current composition of the given entity and then returns the resulting delta via InOutDescriptor. If InOutDescriptor indicates shared fragments to be added the caller is required to provide matching values for the indicated shared fragment types, via AddedSharedFragmentValues.

◆ AddConstSharedFragmentToEntity()

bool FMassEntityManager::AddConstSharedFragmentToEntity ( const FMassEntityHandle  EntityHandle,
const FConstSharedStruct InConstSharedFragment 
)

Adds a new const shared fragment to the given entity. Note that it only works if the given entity doesn't have a shared fragment of the given type. The function will give a soft "pass" if the entity has the shared fragment of the same value. Setting shared fragment value (i.e. changing) is not supported and the function will log a warning if that's attempted.

Returns
whether the entity has the Fragment value assigned to it, regardless of its original state (i.e. the function will return true also if the entity already had the same values associated with it)

◆ AddElementToEntities()

void FMassEntityManager::AddElementToEntities ( TConstArrayView< FMassEntityHandle Entities,
TNotNull< const UScriptStruct * >  ElementType 
)

Adds ElementType to the entities, treating it accordingly based on which element type it represents (i.e. Fragment or Tag). The function will assert on unhandled types.

◆ AddElementToEntity()

void FMassEntityManager::AddElementToEntity ( FMassEntityHandle  Entity,
TNotNull< const UScriptStruct * >  ElementType 
)

Adds ElementType to the entity, treating it accordingly based on which element type it represents (i.e. Fragment or Tag). The function will assert on unhandled types.

◆ AddFragmentInstanceListToEntity()

void FMassEntityManager::AddFragmentInstanceListToEntity ( FMassEntityHandle  EntityHandle,
TConstArrayView< FInstancedStruct FragmentInstanceList 
)

◆ AddFragmentListToEntity()

void FMassEntityManager::AddFragmentListToEntity ( FMassEntityHandle  EntityHandle,
TConstArrayView< const UScriptStruct * >  FragmentList 
)

Ensures that only unique fragments are added.

Note
It's caller's responsibility to ensure EntityHandle's and FragmentList's validity.

◆ AddFragmentToEntity() [1/2]

void FMassEntityManager::AddFragmentToEntity ( FMassEntityHandle  EntityHandle,
const UScriptStruct FragmentType 
)

◆ AddFragmentToEntity() [2/2]

void FMassEntityManager::AddFragmentToEntity ( FMassEntityHandle  EntityHandle,
const UScriptStruct FragmentType,
const FStructInitializationCallback Initializer 
)

◆ AddReferencedObjects()

void FMassEntityManager::AddReferencedObjects ( FReferenceCollector Collector)
overridevirtual

Pure virtual that must be overloaded by the inheriting class. Use this method to serialize any UObjects contained that you wish to keep around.

Parameters
CollectorThe collector of referenced objects.

Implements FGCObject.

◆ AddSharedFragmentToEntity()

bool FMassEntityManager::AddSharedFragmentToEntity ( const FMassEntityHandle  EntityHandle,
const FSharedStruct InSharedFragment 
)

Adds a new shared fragment to the given entity. Note that it only works if the given entity doesn't have a shared fragment of the given type. The function will give a soft "pass" if the entity has the shared fragment of the same value. Setting shared fragment value (i.e. changing) is not supported and the function will log a warning if that's attempted.

Returns
whether the entity has the Fragment value assigned to it, regardless of its original state (i.e. the function will return true also if the entity already had the same values associated with it)

◆ AddTagToEntity()

void FMassEntityManager::AddTagToEntity ( FMassEntityHandle  EntityHandle,
const UScriptStruct TagType 
)

◆ AppendCommands()

void FMassEntityManager::AppendCommands ( const TSharedPtr< FMassCommandBuffer > &  InOutCommandBuffer)

Depending on the current state of Manager's command buffer the function will either move all the commands out of InOutCommandBuffer into the main command buffer or append it to the list of command buffers waiting to be flushed.

Note
as a consequence of the call InOutCommandBuffer can get its contents emptied due some of the underlying code using Move semantics

◆ BatchAddFragmentInstancesForEntities()

void FMassEntityManager::BatchAddFragmentInstancesForEntities ( TConstArrayView< FMassArchetypeEntityCollectionWithPayload EntityCollections,
const FMassFragmentBitSet FragmentsAffected 
)

◆ BatchAddSharedFragmentsForEntities()

void FMassEntityManager::BatchAddSharedFragmentsForEntities ( TConstArrayView< FMassArchetypeEntityCollection EntityCollections,
const FMassArchetypeSharedFragmentValues AddedFragmentValues 
)

Adds a new const and non-const shared fragments to all entities provided via EntityCollections

◆ BatchBuildEntities() [1/2]

TSharedRef< FMassEntityManager::FEntityCreationContext > FMassEntityManager::BatchBuildEntities ( const FMassArchetypeEntityCollectionWithPayload EncodedEntitiesWithPayload,
const FMassArchetypeCompositionDescriptor Composition,
const FMassArchetypeSharedFragmentValues SharedFragmentValues = {},
const FMassArchetypeCreationParams CreationParams = FMassArchetypeCreationParams() 
)

◆ BatchBuildEntities() [2/2]

TSharedRef< FMassEntityManager::FEntityCreationContext > FMassEntityManager::BatchBuildEntities ( const FMassArchetypeEntityCollectionWithPayload EncodedEntitiesWithPayload,
const FMassFragmentBitSet FragmentsAffected,
const FMassArchetypeSharedFragmentValues SharedFragmentValues = {},
const FMassArchetypeCreationParams CreationParams = FMassArchetypeCreationParams() 
)

◆ BatchChangeFragmentCompositionForEntities()

void FMassEntityManager::BatchChangeFragmentCompositionForEntities ( TConstArrayView< FMassArchetypeEntityCollection EntityCollections,
const FMassFragmentBitSet FragmentsToAdd,
const FMassFragmentBitSet FragmentsToRemove 
)

◆ BatchChangeTagsForEntities()

void FMassEntityManager::BatchChangeTagsForEntities ( TConstArrayView< FMassArchetypeEntityCollection EntityCollections,
const FMassTagBitSet TagsToAdd,
const FMassTagBitSet TagsToRemove 
)

◆ BatchCreateEntities() [1/2]

TSharedRef< FMassEntityManager::FEntityCreationContext > FMassEntityManager::BatchCreateEntities ( const FMassArchetypeHandle ArchetypeHandle,
const FMassArchetypeSharedFragmentValues SharedFragmentValues,
const int32  Count,
TArray< FMassEntityHandle > &  InOutEntities 
)

A version of CreateEntity that's creating a number of entities (Count) in one go

Parameters
ArchetypeHandleyou want this entity to be
SharedFragmentValuesto be associated with the entities
Countnumber of entities to create
InOutEntitiesthe newly created entities are appended to given array, i.e. the pre-existing content of OutEntities won't be affected by the call
Returns
a creation context that will notify all the interested observers about newly created fragments once the context is released

◆ BatchCreateEntities() [2/2]

TSharedRef< FEntityCreationContext > FMassEntityManager::BatchCreateEntities ( const FMassArchetypeHandle ArchetypeHandle,
const int32  Count,
TArray< FMassEntityHandle > &  InOutEntities 
)
inline

◆ BatchCreateRelations() [1/2]

bool FMassEntityManager::BatchCreateRelations ( const UE::Mass::FTypeHandle  RelationTypeHandle,
TArrayView< FMassEntityHandle Subjects,
TArrayView< FMassEntityHandle Objects 
)

◆ BatchCreateRelations() [2/2]

template<UE::Mass::CRelation T>
bool FMassEntityManager::BatchCreateRelations ( TArrayView< FMassEntityHandle Subjects,
TArrayView< FMassEntityHandle Objects 
)

◆ BatchCreateReservedEntities() [1/2]

TSharedRef< FMassEntityManager::FEntityCreationContext > FMassEntityManager::BatchCreateReservedEntities ( const FMassArchetypeHandle ArchetypeHandle,
const FMassArchetypeSharedFragmentValues SharedFragmentValues,
TConstArrayView< FMassEntityHandle ReservedEntities 
)

A version of CreateEntity that's creating a number of entities (Count) in one go

Parameters
ArchetypeHandleyou want this entity to be
SharedFragmentValuesto be associated with the entities
ReservedEntitiesa list of reserved entities that have not yet been assigned to an archetype.
Returns
a creation context that will notify all the interested observers about newly created fragments once the context is released

◆ BatchCreateReservedEntities() [2/2]

TSharedRef< FEntityCreationContext > FMassEntityManager::BatchCreateReservedEntities ( const FMassArchetypeHandle ArchetypeHandle,
TConstArrayView< FMassEntityHandle OutEntities 
)
inline

◆ BatchDestroyEntities()

void FMassEntityManager::BatchDestroyEntities ( TConstArrayView< FMassEntityHandle InEntities)

Destroys all the entities in the provided array of entities. The function will also gracefully handle entities that have been reserved but not created yet.

Note
the function doesn't handle duplicates in InEntities.
Parameters
InEntitiesto destroy

◆ BatchDestroyEntityChunks() [1/2]

void FMassEntityManager::BatchDestroyEntityChunks ( const FMassArchetypeEntityCollection Collection)

Destroys all the entities provided via the Collection. The function will also gracefully handle entities that have been reserved but not created yet.

Parameters
Collectionto destroy

◆ BatchDestroyEntityChunks() [2/2]

void FMassEntityManager::BatchDestroyEntityChunks ( TConstArrayView< FMassArchetypeEntityCollection Collections)

◆ BatchGroupEntities() [1/2]

void FMassEntityManager::BatchGroupEntities ( const UE::Mass::FArchetypeGroupHandle  GroupHandle,
TConstArrayView< FMassArchetypeEntityCollection Collections 
)

Assigns all entities indicated by Collections to a given archetype group. Note that depending on their individual composition each entity can end up in a different archetype. @paramm GroupHandle indicates the target group. Passing an invalid group handle will get logged as warning and ignored.

◆ BatchGroupEntities() [2/2]

void FMassEntityManager::BatchGroupEntities ( const UE::Mass::FArchetypeGroupHandle  GroupHandle,
TConstArrayView< FMassEntityHandle InEntities 
)

Assigns all entities indicated by InEntities to a given archetype group. Note that depending on their individual composition each entity can end up in a different archetype. @paramm GroupHandle indicates the target group. Passing an invalid group handle will get logged as warning and ignored.

◆ BatchReserveEntities() [1/2]

TConstArrayView< FMassEntityHandle > FMassEntityManager::BatchReserveEntities ( const int32  Count,
TArray< FMassEntityHandle > &  InOutEntities 
)

Reserves Count number of entities and appends them to InOutEntities

Returns
a view into InOutEntities containing only the freshly reserved entities

◆ BatchReserveEntities() [2/2]

int32 FMassEntityManager::BatchReserveEntities ( TArrayView< FMassEntityHandle InOutEntities)

Reserves number of entities corresponding to number of entries in the provided array view InOutEntities. As a result InOutEntities gets filled with handles of reserved entities

Returns
the number of entities reserved

◆ BatchSetEntityFragmentsValues() [1/2]

void FMassEntityManager::BatchSetEntityFragmentsValues ( const FMassArchetypeEntityCollection SparseEntities,
TArrayView< const FInstancedStruct FragmentInstanceList 
)
static

◆ BatchSetEntityFragmentsValues() [2/2]

void FMassEntityManager::BatchSetEntityFragmentsValues ( TConstArrayView< FMassArchetypeEntityCollection EntityCollections,
TArrayView< const FInstancedStruct FragmentInstanceList 
)
static

◆ BatchSetEntityFragmentValues() [1/2]

void FMassEntityManager::BatchSetEntityFragmentValues ( const FMassArchetypeEntityCollection SparseEntities,
TArrayView< const FInstancedStruct FragmentInstanceList 
)

Copies values from FragmentInstanceList over to fragments of given entities collection. The caller is responsible for ensuring that the given entity archetype (FMassArchetypeEntityCollection .Archetype) does have given fragments. Failing this assumption will cause a check-fail.

◆ BatchSetEntityFragmentValues() [2/2]

void FMassEntityManager::BatchSetEntityFragmentValues ( TConstArrayView< FMassArchetypeEntityCollection EntityCollections,
TArrayView< const FInstancedStruct FragmentInstanceList 
)

◆ BuildEntity() [1/2]

void FMassEntityManager::BuildEntity ( FMassEntityHandle  EntityHandle,
const FMassArchetypeHandle ArchetypeHandle,
const FMassArchetypeSharedFragmentValues SharedFragmentValues = {} 
)

Builds an entity for it to be ready to be used by the subsystem

Parameters
EntityHandleidentifying the entity to build, which was retrieved with ReserveEntity() method
ArchetypeHandleyou want this entity to be
SharedFragmentValuesto be associated with the entity

◆ BuildEntity() [2/2]

void FMassEntityManager::BuildEntity ( FMassEntityHandle  EntityHandle,
TConstArrayView< FInstancedStruct FragmentInstanceList,
const FMassArchetypeSharedFragmentValues SharedFragmentValues = {} 
)

Builds an entity for it to be ready to be used by the subsystem

Parameters
EntityHandleidentifying the entity to build, which was retrieved with ReserveEntity() method
FragmentInstanceListis the fragments to create the entity from and initialize values
SharedFragmentValuesto be associated with the entity

◆ CheckIfEntityIsActive()

void FMassEntityManager::CheckIfEntityIsActive ( FMassEntityHandle  EntityHandle) const
inline

Asserts that IsEntityBuilt

◆ CheckIfEntityIsValid()

void FMassEntityManager::CheckIfEntityIsValid ( FMassEntityHandle  EntityHandle) const
inline

Asserts that IsEntityValid

◆ CreateArchetype() [1/6]

FMassArchetypeHandle FMassEntityManager::CreateArchetype ( const FMassArchetypeCompositionDescriptor Composition,
const FMassArchetypeCreationParams CreationParams = FMassArchetypeCreationParams() 
)

CreateArchetype from a composition descriptor and initial values

Parameters
Compositionof fragment, tag and chunk fragment types
CreationParamsParameters used during archetype construction
Returns
a handle of a new archetype

◆ CreateArchetype() [2/6]

FMassArchetypeHandle FMassEntityManager::CreateArchetype ( const TSharedPtr< FMassArchetypeData > &  SourceArchetype,
const FMassFragmentBitSet InFragments 
)

Creates an archetype like SourceArchetype + InFragments.

Parameters
SourceArchetypethe archetype used to initially populate the list of fragments of the archetype being created.
InFragmentslist of unique fragments to add to fragments fetched from SourceArchetype. Note that adding an empty list is not supported and doing so will result in failing a check
Returns
a handle of a new archetype
Note
it's caller's responsibility to ensure that NewFragmentList is not empty and contains only fragment types that SourceArchetype doesn't already have. If the caller cannot guarantee it use of AddFragment functions family is recommended.

◆ CreateArchetype() [3/6]

FMassArchetypeHandle FMassEntityManager::CreateArchetype ( const TSharedPtr< FMassArchetypeData > &  SourceArchetype,
const FMassFragmentBitSet InFragments,
const FMassArchetypeCreationParams CreationParams 
)

Creates an archetype like SourceArchetype + InFragments.

Parameters
SourceArchetypethe archetype used to initially populate the list of fragments of the archetype being created.
InFragmentslist of unique fragments to add to fragments fetched from SourceArchetype. Note that adding an empty list is not supported and doing so will result in failing a check
CreationParamsParameters used during archetype construction
Returns
a handle of a new archetype
Note
it's caller's responsibility to ensure that NewFragmentList is not empty and contains only fragment types that SourceArchetype doesn't already have. If the caller cannot guarantee it use of AddFragment functions family is recommended.

◆ CreateArchetype() [4/6]

FMassArchetypeHandle FMassEntityManager::CreateArchetype ( FMassArchetypeHandle  SourceArchetype,
TConstArrayView< const UScriptStruct * >  FragmentsAndTagsList 
)

A special, relaxed but slower version of CreateArchetype functions that allows FragmentAngTagsList to contain both fragments and tags. This version takes an original archetype and copies it layout, then appends any fragments and tags from the provided list if they're not already in the original archetype.

Parameters
SourceArchetypeThe archetype where the composition will be copied from.
FragmentsAndTagsListThe list of fragments and tags to add to the copied composition.

◆ CreateArchetype() [5/6]

FMassArchetypeHandle FMassEntityManager::CreateArchetype ( FMassArchetypeHandle  SourceArchetype,
TConstArrayView< const UScriptStruct * >  FragmentsAndTagsList,
const FMassArchetypeCreationParams CreationParams 
)

A special, relaxed but slower version of CreateArchetype functions that allows FragmentAngTagsList to contain both fragments and tags. This version takes an original archetype and copies it layout, then appends any fragments and tags from the provided list if they're not already in the original archetype.

Parameters
SourceArchetypeThe archetype where the composition will be copied from.
FragmentsAndTagsListThe list of fragments and tags to add to the copied composition.
CreationParamsAdditional arguments used to create the new archetype.

◆ CreateArchetype() [6/6]

FMassArchetypeHandle FMassEntityManager::CreateArchetype ( TConstArrayView< const UScriptStruct * >  FragmentsAndTagsList,
const FMassArchetypeCreationParams CreationParams = FMassArchetypeCreationParams() 
)

A special, relaxed but slower version of CreateArchetype functions that allows FragmentAngTagsList to contain both fragments and tags.

◆ CreateEntity() [1/2]

FMassEntityHandle FMassEntityManager::CreateEntity ( const FMassArchetypeHandle ArchetypeHandle,
const FMassArchetypeSharedFragmentValues SharedFragmentValues = {} 
)

Creates fully built entity ready to be used by the subsystem

Parameters
ArchetypeHandleyou want this entity to be
SharedFragmentValuesto be associated with the entity
Returns
FMassEntityHandle id of the newly created entity

◆ CreateEntity() [2/2]

FMassEntityHandle FMassEntityManager::CreateEntity ( TConstArrayView< FInstancedStruct FragmentInstanceList,
const FMassArchetypeSharedFragmentValues SharedFragmentValues = {},
const FMassArchetypeCreationParams CreationParams = FMassArchetypeCreationParams() 
)

Creates fully built entity ready to be used by the subsystem

Parameters
FragmentInstanceListis the fragments to create the entity from and initialize values
SharedFragmentValuesto be associated with the entity
Returns
FMassEntityHandle id of the newly created entity

◆ CreateEntityIndexHandle()

FMassEntityHandle FMassEntityManager::CreateEntityIndexHandle ( const int32  EntityIndex) const

Generate valid, up-to-date entity handle for the entity at given index.

◆ CreateExecutionContext()

FMassExecutionContext FMassEntityManager::CreateExecutionContext ( const float  DeltaSeconds)

Creates and initializes a FMassExecutionContext instance.

◆ DECLARE_MULTICAST_DELEGATE_OneParam()

FMassEntityManager::DECLARE_MULTICAST_DELEGATE_OneParam ( FOnNewArchetypeDelegate  ,
const FMassArchetypeHandle  
)

◆ Defer()

FMassCommandBuffer & FMassEntityManager::Defer ( ) const
inline

◆ Deinitialize()

void FMassEntityManager::Deinitialize ( )

◆ DestroyEntity()

void FMassEntityManager::DestroyEntity ( FMassEntityHandle  EntityHandle)

Destroys a fully built entity, use ReleaseReservedEntity if entity was not yet built.

Parameters
EntityHandleidentifying the entity to destroy

◆ DoEntityCompaction()

void FMassEntityManager::DoEntityCompaction ( const double  TimeAllowed)

Go through all archetypes and compact entities

Parameters
TimeAllowedto do entity compaction, once it reach that time it will stop and return

◆ DoesEntityHaveElement()

bool FMassEntityManager::DoesEntityHaveElement ( FMassEntityHandle  Entity,
TNotNull< const UScriptStruct * >  ElementType 
) const
Returns
whether Entity has an element of ElementType

◆ FindOrAddArchetypeGroupType()

UE::Mass::FArchetypeGroupType FMassEntityManager::FindOrAddArchetypeGroupType ( const FName  GroupName)

Fetches FArchetypeGroupType instance (copy) associated with the given GroupName. A new group type is created if GroupName has not been used in the past.

◆ FlushCommands() [1/2]

void FMassEntityManager::FlushCommands ( )

◆ FlushCommands() [2/2]

void FMassEntityManager::FlushCommands ( const TSharedPtr< FMassCommandBuffer > &  InCommandBuffer)
Parameters
InCommandBufferif not set then the default command buffer will be flushed. If set and there's already a command buffer being flushed (be it the main one or a previously requested one) then this command buffer will be queued itself.

◆ ForEachArchetypeFragmentType()

void FMassEntityManager::ForEachArchetypeFragmentType ( const FMassArchetypeHandle ArchetypeHandle,
TFunction< void(const UScriptStruct *)>  Function 
)
static

Method to iterate on all the fragment types of an archetype

◆ ForEachConstSharedFragment()

void FMassEntityManager::ForEachConstSharedFragment ( TFunctionRef< void(const T &) >  ExecuteFunction)

◆ ForEachConstSharedFragmentConditional()

void FMassEntityManager::ForEachConstSharedFragmentConditional ( TFunctionRef< bool(const T &) >  ConditionFunction,
TFunctionRef< void(const T &) >  ExecuteFunction 
)

◆ ForEachSharedFragment() [1/2]

void FMassEntityManager::ForEachSharedFragment ( TFunctionRef< void(T &) >  ExecuteFunction)

◆ ForEachSharedFragment() [2/2]

void FMassEntityManager::ForEachSharedFragment ( TFunctionRef< void(T &) >  ExecuteFunction)
inline

◆ ForEachSharedFragmentConditional() [1/2]

void FMassEntityManager::ForEachSharedFragmentConditional ( TFunctionRef< bool(T &) >  ConditionFunction,
TFunctionRef< void(T &) >  ExecuteFunction 
)

◆ ForEachSharedFragmentConditional() [2/2]

void FMassEntityManager::ForEachSharedFragmentConditional ( TFunctionRef< bool(T &) >  ConditionFunction,
TFunctionRef< void(T &) >  ExecuteFunction 
)
inline

◆ GetArchetypeComposition()

const FMassArchetypeCompositionDescriptor & FMassEntityManager::GetArchetypeComposition ( const FMassArchetypeHandle ArchetypeHandle) const

◆ GetArchetypeDataVersion()

uint32 FMassEntityManager::GetArchetypeDataVersion ( ) const
inline

◆ GetArchetypeForEntity()

FMassArchetypeHandle FMassEntityManager::GetArchetypeForEntity ( FMassEntityHandle  EntityHandle) const

Fetches the archetype for a given EntityHandle. If EntityHandle is not valid it will still return a handle, just with an invalid archetype

◆ GetArchetypeForEntityUnsafe()

FMassArchetypeHandle FMassEntityManager::GetArchetypeForEntityUnsafe ( FMassEntityHandle  EntityHandle) const

Fetches the archetype for a given EntityHandle. Note that it's callers responsibility the given EntityHandle handle is valid. If you can't ensure that call GetArchetypeForEntity.

◆ GetConstSharedFragmentDataChecked()

ConstSharedFragmentType & FMassEntityManager::GetConstSharedFragmentDataChecked ( FMassEntityHandle  EntityHandle) const
inline

◆ GetConstSharedFragmentDataPtr()

ConstSharedFragmentType * FMassEntityManager::GetConstSharedFragmentDataPtr ( FMassEntityHandle  EntityHandle) const
inline

◆ GetConstSharedFragmentDataStruct()

FConstStructView FMassEntityManager::GetConstSharedFragmentDataStruct ( FMassEntityHandle  EntityHandle,
const UScriptStruct ConstSharedFragmentType 
) const
inline

◆ GetElementDataStruct()

template<typename T >
FConstStructView FMassEntityManager::GetElementDataStruct ( FMassEntityHandle  EntityHandle,
TNotNull< const UScriptStruct * >  FragmentType 
) const
inline

◆ GetFragmentDataChecked()

template<typename FragmentType >
FragmentType & FMassEntityManager::GetFragmentDataChecked ( FMassEntityHandle  EntityHandle) const
inline

◆ GetFragmentDataPtr()

template<typename FragmentType >
FragmentType * FMassEntityManager::GetFragmentDataPtr ( FMassEntityHandle  EntityHandle) const
inline

◆ GetFragmentDataStruct()

FStructView FMassEntityManager::GetFragmentDataStruct ( FMassEntityHandle  EntityHandle,
const UScriptStruct FragmentType 
) const
inline

◆ GetGroupForEntity()

UE::Mass::FArchetypeGroupHandle FMassEntityManager::GetGroupForEntity ( FMassEntityHandle  EntityHandle,
UE::Mass::FArchetypeGroupType  GroupType 
) const
Returns
the group handle of the specific group of type GroupType that the entity belongs to

◆ GetGroupsForArchetype()

const UE::Mass::FArchetypeGroups & FMassEntityManager::GetGroupsForArchetype ( const FMassArchetypeHandle ArchetypeHandle) const

◆ GetMatchingArchetypes() [1/2]

void FMassEntityManager::GetMatchingArchetypes ( const FMassFragmentRequirements Requirements,
TArray< FMassArchetypeHandle > &  OutValidArchetypes 
) const

Searches through all known archetypes and matches them to the provided requirements. All archetypes that pass the requirement check are returned.

Parameters
RequirementsThe set of fragments and tags that need to be on available in the request form on an archetype before it's added.
OutValidArchetypesArchetypes that pass the requirements test are added here.

◆ GetMatchingArchetypes() [2/2]

void FMassEntityManager::GetMatchingArchetypes ( const FMassFragmentRequirements Requirements,
TArray< FMassArchetypeHandle > &  OutValidArchetypes,
const uint32  FromArchetypeDataVersion 
) const
protected

◆ GetObserverManager()

FMassObserverManager & FMassEntityManager::GetObserverManager ( )
inline

◆ GetOnNewArchetypeEvent()

FOnNewArchetypeDelegate & FMassEntityManager::GetOnNewArchetypeEvent ( )
inline

◆ GetOrCreateConstSharedFragment() [1/4]

template<typename T , typename... TArgs>
const FConstSharedStruct & FMassEntityManager::GetOrCreateConstSharedFragment ( const FConstStructView  HashingHelperStruct,
TArgs &&...  InArgs 
)
inline

Returns or creates a shared struct associated to a given shared fragment set of values identified internally by a CRC. Use this overload when a different struct should be used to compute a CRC (i.e., UE::StructUtils::GetStructInstanceCrc32) and values can be provided as constructor arguments for the desired const shared fragment type e.g.,

USTRUCT() struct FIntConstSharedFragmentParams { GENERATED_BODY()

FIntConstSharedFragmentParams(const int32 InValue) : Value(InValue) {}

UPROPERTY() int32 Value = 0; };

USTRUCT() struct FIntConstSharedFragment : public FMassConstSharedFragment { GENERATED_BODY()

FIntConstSharedFragment(const FIntConstSharedFragmentParams& InParams) : Value(InParams.Value) {}

int32 Value = 0; };

FIntConstSharedFragmentParams Params(123); const FConstSharedStruct SharedStruct = EntityManager.GetOrCreateConstSharedFragment<FIntConstSharedFragment>(FConstStructView::Make(Params), Params);

@params HashingHelperStruct Struct view passed to UE::StructUtils::GetStructInstanceCrc32 to compute the CRC @params InArgs List of arguments provided to the constructor of the desired fragment type

Returns
FConstSharedStruct to the matching, or newly created shared fragment

◆ GetOrCreateConstSharedFragment() [2/4]

template<typename T >
const FConstSharedStruct & FMassEntityManager::GetOrCreateConstSharedFragment ( const T &  Fragment)
inline

Returns or creates a shared struct associated to a given shared fragment set of values identified internally by a CRC. Use this overload when an instance of the desired const shared fragment type is available and that can be used directly to compute a CRC (i.e., UE::StructUtils::GetStructInstanceCrc32) e.g., USTRUCT() struct FIntConstSharedFragment : public FMassConstSharedFragment { GENERATED_BODY()

UPROPERTY() int32 Value = 0; };

FIntConstSharedFragment Fragment; Fragment.Value = 123; const FConstSharedStruct SharedStruct = EntityManager.GetOrCreateConstSharedFragment(Fragment);

@params Fragment Instance of the desired fragment type

Returns
FConstSharedStruct to the matching, or newly created shared fragment

◆ GetOrCreateConstSharedFragment() [3/4]

const FConstSharedStruct & FMassEntityManager::GetOrCreateConstSharedFragment ( const UScriptStruct InScriptStruct,
const uint8 InStructMemory 
)
inline

Returns or creates a shared struct associated to a given shared fragment set of values identified internally by a CRC. Use this overload when the reflection data and the memory of an instance of the desired const shared fragment type is available and that can be used directly to compute a CRC (i.e., UE::StructUtils::GetStructInstanceCrc32) e.g., FSharedStruct SharedStruct = EntityManager.GetOrCreateConstSharedFragment(*StructView.GetScriptStruct(), StructView.GetMemory());

@params InScriptStruct Reflection data structure associated to the desired fragment type @params InStructMemory Actual data of the desired fragment type

Returns
FConstSharedStruct to the matching, or newly created shared fragment

◆ GetOrCreateConstSharedFragment() [4/4]

template<typename T , typename... TArgs>
const FConstSharedStruct & FMassEntityManager::GetOrCreateConstSharedFragment ( TArgs &&...  InArgs)
inline

Returns or creates a shared struct associated to a given shared fragment set of values identified internally by a CRC. Use this overload when values can be provided as constructor arguments for the desired const shared fragment type and that can be used directly to compute a CRC (i.e., UE::StructUtils::GetStructInstanceCrc32) e.g., USTRUCT() struct FIntConstSharedFragment : public FMassConstSharedFragment { GENERATED_BODY()

FIntConstSharedFragment(const int32 InValue) : Value(InValue) {}

UPROPERTY() int32 Value = 0; };

const FConstSharedStruct SharedStruct = EntityManager.GetOrCreateConstSharedFragment<FIntConstSharedFragment>(123);

@params InArgs List of arguments provided to the constructor of the desired fragment type

Returns
FConstSharedStruct to the matching, or newly created shared fragment

◆ GetOrCreateConstSharedFragmentByHash()

template<typename T >
const FConstSharedStruct & FMassEntityManager::GetOrCreateConstSharedFragmentByHash ( const uint32  Hash,
const T &  Fragment 
)
inline

◆ GetOrCreateSharedFragment() [1/4]

template<typename T , typename... TArgs>
const FSharedStruct & FMassEntityManager::GetOrCreateSharedFragment ( const FConstStructView  HashingHelperStruct,
TArgs &&...  InArgs 
)
inline

Returns or creates a shared struct associated to a given shared fragment set of values identified internally by a CRC. Use this overload when a different struct should be used to compute a CRC (i.e., UE::StructUtils::GetStructInstanceCrc32) and values can be provided as constructor arguments for the desired shared fragment type e.g.,

USTRUCT() struct FIntSharedFragmentParams { GENERATED_BODY()

FInSharedFragmentParams(const int32 InValue) : Value(InValue) {}

UPROPERTY() int32 Value = 0; };

USTRUCT() struct FIntSharedFragment : public FMassSharedFragment { GENERATED_BODY()

FIntSharedFragment(const FIntConstSharedFragmentParams& InParams) : Value(InParams.Value) {}

int32 Value = 0; };

FIntSharedFragmentParams Params(123); const FSharedStruct SharedStruct = EntityManager.GetOrCreateSharedFragment<FIntSharedFragment>(FConstStructView::Make(Params), Params);

@params HashingHelperStruct Struct view passed to UE::StructUtils::GetStructInstanceCrc32 to compute the CRC @params InArgs List of arguments provided to the constructor of the desired fragment type

Returns
FSharedStruct to the matching, or newly created shared fragment

◆ GetOrCreateSharedFragment() [2/4]

template<typename T >
const FSharedStruct & FMassEntityManager::GetOrCreateSharedFragment ( const T &  Fragment)
inline

Returns or creates a shared struct associated to a given shared fragment set of values identified internally by a CRC. Use this overload when an instance of the desired shared fragment type is available and that can be used directly to compute a CRC (i.e., UE::StructUtils::GetStructInstanceCrc32) e.g., USTRUCT() struct FIntSharedFragment : public FMassSharedFragment { GENERATED_BODY()

UPROPERTY() int32 Value = 0; };

FIntSharedFragment Fragment; Fragment.Value = 123; const FSharedStruct SharedStruct = EntityManager.GetOrCreateSharedFragment(Fragment);

@params Fragment Instance of the desired fragment type

Returns
FSharedStruct to the matching, or newly created shared fragment

◆ GetOrCreateSharedFragment() [3/4]

const FSharedStruct & FMassEntityManager::GetOrCreateSharedFragment ( const UScriptStruct InScriptStruct,
const uint8 InStructMemory 
)
inline

Returns or creates a shared struct associated to a given shared fragment set of values identified internally by a CRC. Use this overload when the reflection data and the memory of an instance of the desired shared fragment type is available and that can be used directly to compute a CRC (i.e., UE::StructUtils::GetStructInstanceCrc32) e.g., FSharedStruct SharedStruct = EntityManager.GetOrCreateSharedFragment(*StructView.GetScriptStruct(), StructView.GetMemory());

@params InScriptStruct Reflection data structure associated to the desired fragment type @params InStructMemory Actual data of the desired fragment type

Returns
FSharedStruct to the matching, or newly created shared fragment

◆ GetOrCreateSharedFragment() [4/4]

template<typename T , typename... TArgs>
const FSharedStruct & FMassEntityManager::GetOrCreateSharedFragment ( TArgs &&...  InArgs)
inline

Returns or creates a shared struct associated to a given shared fragment set of values identified internally by a CRC. Use this overload when values can be provided as constructor arguments for the desired shared fragment type and that can be used directly to compute a CRC (i.e., UE::StructUtils::GetStructInstanceCrc32) e.g., USTRUCT() struct FIntSharedFragment : public FMassSharedFragment { GENERATED_BODY()

FIntSharedFragment(const int32 InValue) : Value(InValue) {}

UPROPERTY() int32 Value = 0; };

const FSharedStruct SharedStruct = EntityManager.GetOrCreateSharedFragment<FIntSharedFragment>(123);

@params InArgs List of arguments provided to the constructor of the desired fragment type

Returns
FSharedStruct to the matching, or newly created shared fragment

◆ GetOrCreateSharedFragmentByHash()

template<typename T , typename... TArgs>
const FSharedStruct & FMassEntityManager::GetOrCreateSharedFragmentByHash ( const uint32  Hash,
TArgs &&...  InArgs 
)
inline

◆ GetOrCreateSuitableArchetype()

FMassArchetypeHandle FMassEntityManager::GetOrCreateSuitableArchetype ( const FMassArchetypeHandle ArchetypeHandle,
const FMassSharedFragmentBitSet SharedFragmentBitSet,
const FMassConstSharedFragmentBitSet ConstSharedFragmentBitSet,
const FMassArchetypeCreationParams CreationParams = FMassArchetypeCreationParams() 
)

A helper function to be used when creating entities with shared fragments provided, or when adding shared fragments to existing entities

Parameters
ArchetypeHandlethat's the assumed target archetype. But we'll be making sure its composition matches SharedFragmentsBitSet
SharedFragmentBitSetindicates which shared fragments we want the target archetype to have. If ArchetypeHandle doesn't have these a new archetype will be created.

◆ GetOrMakeCreationContext()

TSharedRef< FMassEntityManager::FEntityCreationContext > FMassEntityManager::GetOrMakeCreationContext ( )

The main use-case for this function is to create a blank FEntityCreationContext and hold on to it while creating a bunch of entities (with multiple calls to BatchCreate* and/or BatchBuild*) and modifying them (with mutating batched API) while not causing multiple Observers to trigger. All the observers will be triggered at one go, once the FEntityCreationContext instance gets destroyed.

!Important note: the "Creation Context" is a specialized wrapper for an "Observers Lock" (

See also
GetOrMakeObserversLock). As long as the creation context is alive all the operations will be assumed to affect the newly created entities. The consequence of that is operations performed on already existing entities won't be tracked, as long as the creation context is alive. Note that you can hold a FMassObserverManager::FObserverLock instance while the creation lock gets destroyed, the observers lock is a lower-level concept than the creation context.
Returns
the existing (if valid) or a newly created creation context

◆ GetOrMakeObserversLock()

TSharedRef< FMassObserverManager::FObserverLock > FMassEntityManager::GetOrMakeObserversLock ( )
inline

Fetches the observers lock (as hosted by FMassObserverManager). If one is not currently active, one will be created. While the lock is active all the observers notifications are suspended, and will be sent out when FMassObserverManager::FObserverLock instance gets destroyed. Locking observers needs to be used when entities are being configured with multiple operations, and we want observers to be triggered only once all the operations are executed.

Note that while the observers are locked we're unable to send "Remove" notifications, so once the lock is released and the observers get notified, the data being removed won't be available anymore (which is a difference in behavior as compared to removal notifications while the observers are not locked).

◆ GetOwner()

UObject * FMassEntityManager::GetOwner ( ) const
inline

◆ GetReferencerName()

virtual FString FMassEntityManager::GetReferencerName ( ) const
inlineoverridevirtual

Overload this method to report a name for your referencer

Implements FGCObject.

◆ GetRelationManager()

UE::Mass::FRelationManager & FMassEntityManager::GetRelationManager ( )
inline

◆ GetResourceSizeEx()

void FMassEntityManager::GetResourceSizeEx ( FResourceSizeEx CumulativeResourceSize)

◆ GetSharedFragmentDataChecked()

SharedFragmentType & FMassEntityManager::GetSharedFragmentDataChecked ( FMassEntityHandle  EntityHandle) const
inline

◆ GetSharedFragmentDataPtr()

SharedFragmentType * FMassEntityManager::GetSharedFragmentDataPtr ( FMassEntityHandle  EntityHandle) const
inline

◆ GetSharedFragmentDataStruct()

FConstStructView FMassEntityManager::GetSharedFragmentDataStruct ( FMassEntityHandle  EntityHandle,
const UScriptStruct SharedFragmentType 
) const
inline

◆ GetSharedFragmentsOfType()

TConstArrayView< FSharedStruct > FMassEntityManager::GetSharedFragmentsOfType ( )
inline

◆ GetTypeManager() [1/2]

UE::Mass::FTypeManager & FMassEntityManager::GetTypeManager ( )
inline

◆ GetTypeManager() [2/2]

const UE::Mass::FTypeManager & FMassEntityManager::GetTypeManager ( ) const
inline

◆ GetWorld()

UWorld * FMassEntityManager::GetWorld ( ) const
inline

Fetches the world associated with the Owner.

Note
that it's ok for a given EntityManager to not have an owner or the owner not being part of a UWorld, depending on the use case

◆ Initialize() [1/2]

void FMassEntityManager::Initialize ( )

◆ Initialize() [2/2]

void FMassEntityManager::Initialize ( const FMassEntityManagerStorageInitParams InitializationParams)

◆ InternalAppendFragmentsAndTagsToArchetypeCompositionDescriptor()

void FMassEntityManager::InternalAppendFragmentsAndTagsToArchetypeCompositionDescriptor ( FMassArchetypeCompositionDescriptor InOutComposition,
TConstArrayView< const UScriptStruct * >  FragmentsAndTagsList 
) const
protected

◆ InternalCreateSimilarArchetype() [1/5]

FMassArchetypeHandle FMassEntityManager::InternalCreateSimilarArchetype ( const FMassArchetypeData SourceArchetypeRef,
FMassArchetypeCompositionDescriptor &&  NewComposition 
)
protected

◆ InternalCreateSimilarArchetype() [2/5]

FMassArchetypeHandle FMassEntityManager::InternalCreateSimilarArchetype ( const FMassArchetypeData SourceArchetypeRef,
FMassArchetypeCompositionDescriptor &&  NewComposition,
const UE::Mass::FArchetypeGroups GroupsOverride 
)
protected

◆ InternalCreateSimilarArchetype() [3/5]

FMassArchetypeHandle FMassEntityManager::InternalCreateSimilarArchetype ( const TSharedPtr< FMassArchetypeData > &  SourceArchetype,
const FMassFragmentBitSet OverrideFragments 
)
protected

◆ InternalCreateSimilarArchetype() [4/5]

FMassArchetypeHandle FMassEntityManager::InternalCreateSimilarArchetype ( const TSharedPtr< FMassArchetypeData > &  SourceArchetype,
const FMassTagBitSet OverrideTags 
)
protected

A "similar" archetype is an archetype exactly the same as SourceArchetype except for one composition aspect like Fragments or "Tags"

◆ InternalCreateSimilarArchetype() [5/5]

FMassArchetypeHandle FMassEntityManager::InternalCreateSimilarArchetype ( const TSharedPtr< FMassArchetypeData > &  SourceArchetype,
const UE::Mass::FArchetypeGroups GroupsOverride 
)
protected

◆ IsDuringEntityCreation()

bool FMassEntityManager::IsDuringEntityCreation ( ) const
inline

◆ IsEntityActive()

bool FMassEntityManager::IsEntityActive ( FMassEntityHandle  EntityHandle) const
Returns
whether the given handle represents a valid and built entity (i.e., the handle is valid and the entity represent has been constructed already)

◆ IsEntityBuilt()

bool FMassEntityManager::IsEntityBuilt ( FMassEntityHandle  EntityHandle) const

whether the entity handle represents an entity that has been fully built (expecting a valid EntityHandle)

◆ IsEntityReserved()

bool FMassEntityManager::IsEntityReserved ( FMassEntityHandle  EntityHandle) const
Returns
whether the given EntityHandle is valid and the entity it represents is in Reserved state (i.e. it will also fail if the entity has already been Created)

◆ IsEntityValid()

bool FMassEntityManager::IsEntityValid ( FMassEntityHandle  EntityHandle) const
Returns
whether the given entity handle is valid, i.e. it points to a valid spot in the entity storage and the handle's serial number is up to date

◆ IsProcessing()

bool FMassEntityManager::IsProcessing ( ) const
inline

Indicates whether there are processors out there performing operations on this instance of MassEntityManager. Used to ensure that mutating operations (like entity destruction) are not performed while processors are running, which rely on the assumption that the data layout doesn't change during calculations.

◆ MakeEntityBuilder()

UE::Mass::FEntityBuilder FMassEntityManager::MakeEntityBuilder ( )

◆ MoveEntityToAnotherArchetype()

void FMassEntityManager::MoveEntityToAnotherArchetype ( FMassEntityHandle  EntityHandle,
FMassArchetypeHandle  NewArchetypeHandle,
const FMassArchetypeSharedFragmentValues SharedFragmentValuesOverride = nullptr 
)

Moves an entity over to a new archetype by copying over fragments common to both archetypes

Parameters
EntityHandleidicates the entity to move
NewArchetypeHandlethe handle to the new archetype
SharedFragmentValuesOverrideif provided will override all given entity's shared fragment values

◆ NewProcessingScope()

FScopedProcessing FMassEntityManager::NewProcessingScope ( )
inline

◆ OnNewTypeRegistered()

void FMassEntityManager::OnNewTypeRegistered ( UE::Mass::FTypeHandle  RegisteredTypeHandle)

◆ OnPostFork()

void FMassEntityManager::OnPostFork ( EForkProcessRole  Role)
protected

Called on the child process upon process's forking

◆ OnRelationTypeRegistered()

void FMassEntityManager::OnRelationTypeRegistered ( UE::Mass::FTypeHandle  RegisteredTypeHandle,
const UE::Mass::FRelationTypeTraits RelationTypeTraits 
)
protected

◆ PostInitialize()

void FMassEntityManager::PostInitialize ( )

◆ ReleaseReservedEntity()

void FMassEntityManager::ReleaseReservedEntity ( FMassEntityHandle  EntityHandle)

◆ RemoveCompositionFromEntity()

void FMassEntityManager::RemoveCompositionFromEntity ( FMassEntityHandle  EntityHandle,
const FMassArchetypeCompositionDescriptor InDescriptor 
)

◆ RemoveConstSharedFragmentFromEntity()

bool FMassEntityManager::RemoveConstSharedFragmentFromEntity ( const FMassEntityHandle  EntityHandle,
const UScriptStruct ConstSharedFragmentType 
)

Removes a const shared fragment of the given type from the entity. Will do nothing if entity did not have the shared fragment.

Returns
True if fragment removed from entity, false otherwise.

◆ RemoveElementFromEntities()

void FMassEntityManager::RemoveElementFromEntities ( TConstArrayView< FMassEntityHandle Entities,
TNotNull< const UScriptStruct * >  ElementType 
)

◆ RemoveElementFromEntity()

void FMassEntityManager::RemoveElementFromEntity ( FMassEntityHandle  Entity,
TNotNull< const UScriptStruct * >  ElementType 
)

◆ RemoveEntityFromGroupType()

void FMassEntityManager::RemoveEntityFromGroupType ( FMassEntityHandle  EntityHandle,
UE::Mass::FArchetypeGroupType  GroupType 
)

Removes EntityHandle from any-and-all groups of given type - i.e. the entity will be moved to an archetype not in any of the groups of the given type.

◆ RemoveFragmentFromEntity()

void FMassEntityManager::RemoveFragmentFromEntity ( FMassEntityHandle  EntityHandle,
const UScriptStruct FragmentType 
)

◆ RemoveFragmentListFromEntity()

void FMassEntityManager::RemoveFragmentListFromEntity ( FMassEntityHandle  EntityHandle,
TConstArrayView< const UScriptStruct * >  FragmentList 
)

◆ RemoveSharedFragmentFromEntity()

bool FMassEntityManager::RemoveSharedFragmentFromEntity ( const FMassEntityHandle  EntityHandle,
const UScriptStruct SharedFragmentType 
)

Removes a shared fragment of the given type from the entity. Will do nothing if entity did not have the shared fragment.

Returns
True if fragment removed from entity, false otherwise.

◆ RemoveTagFromEntity()

void FMassEntityManager::RemoveTagFromEntity ( FMassEntityHandle  EntityHandle,
const UScriptStruct TagType 
)

◆ ReserveEntity()

FMassEntityHandle FMassEntityManager::ReserveEntity ( )

Reserves an entity in the subsystem, the entity is still not ready to be used by the subsystem, need to call BuildEntity()

Returns
FMassEntityHandle id of the reserved entity

◆ SetDebugName()

void FMassEntityManager::SetDebugName ( const FString &  NewDebugGame)

◆ SetEntityFragmentsValues()

void FMassEntityManager::SetEntityFragmentsValues ( FMassEntityHandle  EntityHandle,
TArrayView< const FInstancedStruct FragmentInstanceList 
)

◆ SetEntityFragmentValues()

void FMassEntityManager::SetEntityFragmentValues ( FMassEntityHandle  EntityHandle,
TArrayView< const FInstancedStruct FragmentInstanceList 
)

Copies values from FragmentInstanceList over to target entity's fragment. Caller is responsible for ensuring that the given entity does have given fragments. Failing this assumption will cause a check-fail.

Parameters
EntityHandleidicates the target entity

◆ SwapTagsForEntity()

void FMassEntityManager::SwapTagsForEntity ( FMassEntityHandle  EntityHandle,
const UScriptStruct FromFragmentType,
const UScriptStruct ToFragmentType 
)

Friends And Related Symbol Documentation

◆ UE::Mass::Private::FEntityStorageInitializer

Member Data Documentation

◆ FMassDebugger

friend FMassEntityManager::FMassDebugger

◆ FMassEntityQuery

friend FMassEntityManager::FMassEntityQuery

◆ InvalidEntity

const FMassEntityHandle FMassEntityManager::InvalidEntity
static

The documentation for this struct was generated from the following files: