![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#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 } |
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 UGCObjectReferencer * | GGCObjectReferencer = nullptr |
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) |
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.
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.
| using FMassEntityManager::FStructInitializationCallback = TFunctionRef<void(void* Fragment, const UScriptStruct& FragmentType)> |
|
explicit |
|
delete |
|
virtual |
| 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.
| 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.
| 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.
| 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.
| void FMassEntityManager::AddFragmentInstanceListToEntity | ( | FMassEntityHandle | EntityHandle, |
| TConstArrayView< FInstancedStruct > | FragmentInstanceList | ||
| ) |
| void FMassEntityManager::AddFragmentListToEntity | ( | FMassEntityHandle | EntityHandle, |
| TConstArrayView< const UScriptStruct * > | FragmentList | ||
| ) |
Ensures that only unique fragments are added.
| void FMassEntityManager::AddFragmentToEntity | ( | FMassEntityHandle | EntityHandle, |
| const UScriptStruct * | FragmentType | ||
| ) |
| void FMassEntityManager::AddFragmentToEntity | ( | FMassEntityHandle | EntityHandle, |
| const UScriptStruct * | FragmentType, | ||
| const FStructInitializationCallback & | Initializer | ||
| ) |
|
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.
| Collector | The collector of referenced objects. |
Implements FGCObject.
| 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.
| void FMassEntityManager::AddTagToEntity | ( | FMassEntityHandle | EntityHandle, |
| const UScriptStruct * | TagType | ||
| ) |
| 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.
| void FMassEntityManager::BatchAddFragmentInstancesForEntities | ( | TConstArrayView< FMassArchetypeEntityCollectionWithPayload > | EntityCollections, |
| const FMassFragmentBitSet & | FragmentsAffected | ||
| ) |
| void FMassEntityManager::BatchAddSharedFragmentsForEntities | ( | TConstArrayView< FMassArchetypeEntityCollection > | EntityCollections, |
| const FMassArchetypeSharedFragmentValues & | AddedFragmentValues | ||
| ) |
Adds a new const and non-const shared fragments to all entities provided via EntityCollections
| TSharedRef< FMassEntityManager::FEntityCreationContext > FMassEntityManager::BatchBuildEntities | ( | const FMassArchetypeEntityCollectionWithPayload & | EncodedEntitiesWithPayload, |
| const FMassArchetypeCompositionDescriptor & | Composition, | ||
| const FMassArchetypeSharedFragmentValues & | SharedFragmentValues = {}, |
||
| const FMassArchetypeCreationParams & | CreationParams = FMassArchetypeCreationParams() |
||
| ) |
| TSharedRef< FMassEntityManager::FEntityCreationContext > FMassEntityManager::BatchBuildEntities | ( | const FMassArchetypeEntityCollectionWithPayload & | EncodedEntitiesWithPayload, |
| const FMassFragmentBitSet & | FragmentsAffected, | ||
| const FMassArchetypeSharedFragmentValues & | SharedFragmentValues = {}, |
||
| const FMassArchetypeCreationParams & | CreationParams = FMassArchetypeCreationParams() |
||
| ) |
| void FMassEntityManager::BatchChangeFragmentCompositionForEntities | ( | TConstArrayView< FMassArchetypeEntityCollection > | EntityCollections, |
| const FMassFragmentBitSet & | FragmentsToAdd, | ||
| const FMassFragmentBitSet & | FragmentsToRemove | ||
| ) |
| void FMassEntityManager::BatchChangeTagsForEntities | ( | TConstArrayView< FMassArchetypeEntityCollection > | EntityCollections, |
| const FMassTagBitSet & | TagsToAdd, | ||
| const FMassTagBitSet & | TagsToRemove | ||
| ) |
| 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
| ArchetypeHandle | you want this entity to be |
| SharedFragmentValues | to be associated with the entities |
| Count | number of entities to create |
| InOutEntities | the newly created entities are appended to given array, i.e. the pre-existing content of OutEntities won't be affected by the call |
|
inline |
| bool FMassEntityManager::BatchCreateRelations | ( | const UE::Mass::FTypeHandle | RelationTypeHandle, |
| TArrayView< FMassEntityHandle > | Subjects, | ||
| TArrayView< FMassEntityHandle > | Objects | ||
| ) |
| bool FMassEntityManager::BatchCreateRelations | ( | TArrayView< FMassEntityHandle > | Subjects, |
| TArrayView< FMassEntityHandle > | Objects | ||
| ) |
| 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
| ArchetypeHandle | you want this entity to be |
| SharedFragmentValues | to be associated with the entities |
| ReservedEntities | a list of reserved entities that have not yet been assigned to an archetype. |
|
inline |
| 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.
| InEntities | to destroy |
| 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.
| Collection | to destroy |
| void FMassEntityManager::BatchDestroyEntityChunks | ( | TConstArrayView< FMassArchetypeEntityCollection > | Collections | ) |
| 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.
| 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.
| TConstArrayView< FMassEntityHandle > FMassEntityManager::BatchReserveEntities | ( | const int32 | Count, |
| TArray< FMassEntityHandle > & | InOutEntities | ||
| ) |
Reserves Count number of entities and appends them to InOutEntities
| 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
|
static |
|
static |
| 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.
| void FMassEntityManager::BatchSetEntityFragmentValues | ( | TConstArrayView< FMassArchetypeEntityCollection > | EntityCollections, |
| TArrayView< const FInstancedStruct > | FragmentInstanceList | ||
| ) |
| 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
| EntityHandle | identifying the entity to build, which was retrieved with ReserveEntity() method |
| ArchetypeHandle | you want this entity to be |
| SharedFragmentValues | to be associated with the entity |
| 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
| EntityHandle | identifying the entity to build, which was retrieved with ReserveEntity() method |
| FragmentInstanceList | is the fragments to create the entity from and initialize values |
| SharedFragmentValues | to be associated with the entity |
|
inline |
Asserts that IsEntityBuilt
|
inline |
Asserts that IsEntityValid
| FMassArchetypeHandle FMassEntityManager::CreateArchetype | ( | const FMassArchetypeCompositionDescriptor & | Composition, |
| const FMassArchetypeCreationParams & | CreationParams = FMassArchetypeCreationParams() |
||
| ) |
CreateArchetype from a composition descriptor and initial values
| Composition | of fragment, tag and chunk fragment types |
| CreationParams | Parameters used during archetype construction |
| FMassArchetypeHandle FMassEntityManager::CreateArchetype | ( | const TSharedPtr< FMassArchetypeData > & | SourceArchetype, |
| const FMassFragmentBitSet & | InFragments | ||
| ) |
Creates an archetype like SourceArchetype + InFragments.
| SourceArchetype | the archetype used to initially populate the list of fragments of the archetype being created. |
| InFragments | list 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 |
| FMassArchetypeHandle FMassEntityManager::CreateArchetype | ( | const TSharedPtr< FMassArchetypeData > & | SourceArchetype, |
| const FMassFragmentBitSet & | InFragments, | ||
| const FMassArchetypeCreationParams & | CreationParams | ||
| ) |
Creates an archetype like SourceArchetype + InFragments.
| SourceArchetype | the archetype used to initially populate the list of fragments of the archetype being created. |
| InFragments | list 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 |
| CreationParams | Parameters used during archetype construction |
| 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.
| SourceArchetype | The archetype where the composition will be copied from. |
| FragmentsAndTagsList | The list of fragments and tags to add to the copied composition. |
| 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.
| SourceArchetype | The archetype where the composition will be copied from. |
| FragmentsAndTagsList | The list of fragments and tags to add to the copied composition. |
| CreationParams | Additional arguments used to create the new archetype. |
| 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.
| FMassEntityHandle FMassEntityManager::CreateEntity | ( | const FMassArchetypeHandle & | ArchetypeHandle, |
| const FMassArchetypeSharedFragmentValues & | SharedFragmentValues = {} |
||
| ) |
Creates fully built entity ready to be used by the subsystem
| ArchetypeHandle | you want this entity to be |
| SharedFragmentValues | to be associated with the entity |
| FMassEntityHandle FMassEntityManager::CreateEntity | ( | TConstArrayView< FInstancedStruct > | FragmentInstanceList, |
| const FMassArchetypeSharedFragmentValues & | SharedFragmentValues = {}, |
||
| const FMassArchetypeCreationParams & | CreationParams = FMassArchetypeCreationParams() |
||
| ) |
Creates fully built entity ready to be used by the subsystem
| FragmentInstanceList | is the fragments to create the entity from and initialize values |
| SharedFragmentValues | to be associated with the entity |
| FMassEntityHandle FMassEntityManager::CreateEntityIndexHandle | ( | const int32 | EntityIndex | ) | const |
Generate valid, up-to-date entity handle for the entity at given index.
| FMassExecutionContext FMassEntityManager::CreateExecutionContext | ( | const float | DeltaSeconds | ) |
Creates and initializes a FMassExecutionContext instance.
| FMassEntityManager::DECLARE_MULTICAST_DELEGATE_OneParam | ( | FOnNewArchetypeDelegate | , |
| const FMassArchetypeHandle & | |||
| ) |
|
inline |
| void FMassEntityManager::Deinitialize | ( | ) |
| void FMassEntityManager::DestroyEntity | ( | FMassEntityHandle | EntityHandle | ) |
Destroys a fully built entity, use ReleaseReservedEntity if entity was not yet built.
| EntityHandle | identifying the entity to destroy |
Go through all archetypes and compact entities
| TimeAllowed | to do entity compaction, once it reach that time it will stop and return |
| bool FMassEntityManager::DoesEntityHaveElement | ( | FMassEntityHandle | Entity, |
| TNotNull< const UScriptStruct * > | ElementType | ||
| ) | const |
| 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.
| void FMassEntityManager::FlushCommands | ( | ) |
| void FMassEntityManager::FlushCommands | ( | const TSharedPtr< FMassCommandBuffer > & | InCommandBuffer | ) |
| InCommandBuffer | if 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. |
|
static |
Method to iterate on all the fragment types of an archetype
| void FMassEntityManager::ForEachConstSharedFragment | ( | TFunctionRef< void(const T &) > | ExecuteFunction | ) |
| void FMassEntityManager::ForEachConstSharedFragmentConditional | ( | TFunctionRef< bool(const T &) > | ConditionFunction, |
| TFunctionRef< void(const T &) > | ExecuteFunction | ||
| ) |
| void FMassEntityManager::ForEachSharedFragment | ( | TFunctionRef< void(T &) > | ExecuteFunction | ) |
|
inline |
| void FMassEntityManager::ForEachSharedFragmentConditional | ( | TFunctionRef< bool(T &) > | ConditionFunction, |
| TFunctionRef< void(T &) > | ExecuteFunction | ||
| ) |
|
inline |
| const FMassArchetypeCompositionDescriptor & FMassEntityManager::GetArchetypeComposition | ( | const FMassArchetypeHandle & | ArchetypeHandle | ) | const |
|
inline |
| 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
| 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.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| UE::Mass::FArchetypeGroupHandle FMassEntityManager::GetGroupForEntity | ( | FMassEntityHandle | EntityHandle, |
| UE::Mass::FArchetypeGroupType | GroupType | ||
| ) | const |
| const UE::Mass::FArchetypeGroups & FMassEntityManager::GetGroupsForArchetype | ( | const FMassArchetypeHandle & | ArchetypeHandle | ) | const |
| 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.
| Requirements | The set of fragments and tags that need to be on available in the request form on an archetype before it's added. |
| OutValidArchetypes | Archetypes that pass the requirements test are added here. |
|
protected |
|
inline |
|
inline |
|
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
|
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
|
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
|
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
|
inline |
|
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
|
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
|
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
|
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
|
inline |
| 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
| ArchetypeHandle | that's the assumed target archetype. But we'll be making sure its composition matches SharedFragmentsBitSet |
| SharedFragmentBitSet | indicates which shared fragments we want the target archetype to have. If ArchetypeHandle doesn't have these a new archetype will be created. |
| 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" (
|
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).
|
inline |
|
inlineoverridevirtual |
Overload this method to report a name for your referencer
Implements FGCObject.
|
inline |
| void FMassEntityManager::GetResourceSizeEx | ( | FResourceSizeEx & | CumulativeResourceSize | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Fetches the world associated with the Owner.
| void FMassEntityManager::Initialize | ( | ) |
| void FMassEntityManager::Initialize | ( | const FMassEntityManagerStorageInitParams & | InitializationParams | ) |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
A "similar" archetype is an archetype exactly the same as SourceArchetype except for one composition aspect like Fragments or "Tags"
|
protected |
|
inline |
| bool FMassEntityManager::IsEntityActive | ( | FMassEntityHandle | EntityHandle | ) | const |
| bool FMassEntityManager::IsEntityBuilt | ( | FMassEntityHandle | EntityHandle | ) | const |
whether the entity handle represents an entity that has been fully built (expecting a valid EntityHandle)
| bool FMassEntityManager::IsEntityReserved | ( | FMassEntityHandle | EntityHandle | ) | const |
Reserved state (i.e. it will also fail if the entity has already been Created) | bool FMassEntityManager::IsEntityValid | ( | FMassEntityHandle | EntityHandle | ) | 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.
| UE::Mass::FEntityBuilder FMassEntityManager::MakeEntityBuilder | ( | ) |
| 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
| EntityHandle | idicates the entity to move |
| NewArchetypeHandle | the handle to the new archetype |
| SharedFragmentValuesOverride | if provided will override all given entity's shared fragment values |
|
inline |
| void FMassEntityManager::OnNewTypeRegistered | ( | UE::Mass::FTypeHandle | RegisteredTypeHandle | ) |
|
protected |
Called on the child process upon process's forking
|
protected |
| void FMassEntityManager::PostInitialize | ( | ) |
| void FMassEntityManager::ReleaseReservedEntity | ( | FMassEntityHandle | EntityHandle | ) |
| void FMassEntityManager::RemoveCompositionFromEntity | ( | FMassEntityHandle | EntityHandle, |
| const FMassArchetypeCompositionDescriptor & | InDescriptor | ||
| ) |
| 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.
| void FMassEntityManager::RemoveElementFromEntities | ( | TConstArrayView< FMassEntityHandle > | Entities, |
| TNotNull< const UScriptStruct * > | ElementType | ||
| ) |
| void FMassEntityManager::RemoveElementFromEntity | ( | FMassEntityHandle | Entity, |
| TNotNull< const UScriptStruct * > | ElementType | ||
| ) |
| 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.
| void FMassEntityManager::RemoveFragmentFromEntity | ( | FMassEntityHandle | EntityHandle, |
| const UScriptStruct * | FragmentType | ||
| ) |
| void FMassEntityManager::RemoveFragmentListFromEntity | ( | FMassEntityHandle | EntityHandle, |
| TConstArrayView< const UScriptStruct * > | FragmentList | ||
| ) |
| 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.
| void FMassEntityManager::RemoveTagFromEntity | ( | FMassEntityHandle | EntityHandle, |
| const UScriptStruct * | TagType | ||
| ) |
| 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()
| void FMassEntityManager::SetDebugName | ( | const FString & | NewDebugGame | ) |
| void FMassEntityManager::SetEntityFragmentsValues | ( | FMassEntityHandle | EntityHandle, |
| TArrayView< const FInstancedStruct > | FragmentInstanceList | ||
| ) |
| 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.
| EntityHandle | idicates the target entity |
| void FMassEntityManager::SwapTagsForEntity | ( | FMassEntityHandle | EntityHandle, |
| const UScriptStruct * | FromFragmentType, | ||
| const UScriptStruct * | ToFragmentType | ||
| ) |
| friend FMassEntityManager::FMassDebugger |
| friend FMassEntityManager::FMassEntityQuery |
|
static |