Navigation
API > API/Runtime > API/Runtime/MassEntity
Inheritance Hierarchy
- TSharedFromThis< FMassEntityManager >
- FGCObject
- FMassEntityManager
References
| Module | MassEntity |
| Header | /Engine/Source/Runtime/MassEntity/Public/MassEntityManager.h |
| Include | #include "MassEntityManager.h" |
Syntax
struct FMassEntityManager :
public TSharedFromThis< FMassEntityManager >,
public FGCObject
Remarks
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
Variables
| Type | Name | Description | |
|---|---|---|---|
| friend | FMassDebugger | ||
| friend | FMassEntityQuery |
Constructors
| Type | Name | Description | |
|---|---|---|---|
FMassEntityManager
(
UObject* InOwner |
|||
FMassEntityManager
(
const FMassEntityManager& Other |
Destructors
| Type | Name | Description | |
|---|---|---|---|
Functions
| Type | Name | Description | |
|---|---|---|---|
| void | AddCompositionToEntity_GetDelta
(
FMassEntityHandle Entity, |
Adds fragments and tags indicated by InOutDescriptor to the Entity. | |
| bool | AddConstSharedFragmentToEntity
(
const FMassEntityHandle Entity, |
Adds a new const shared fragment to the given entity. | |
| void | AddFragmentInstanceListToEntity
(
FMassEntityHandle Entity, |
||
| void | AddFragmentListToEntity
(
FMassEntityHandle Entity, |
Ensures that only unique fragments are added. | |
| void | AddFragmentToEntity
(
FMassEntityHandle Entity, |
||
| void | AddFragmentToEntity
(
FMassEntityHandle Entity, |
||
| void | AddReferencedObjects
(
FReferenceCollector& Collector |
||
| void | AddTagToEntity
(
FMassEntityHandle Entity, |
||
| void | AppendCommands
(
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 | BatchAddFragmentInstancesForEntities
(
TConstArrayView< FMassArchetypeEntityCollectionWithPayload > EntityCollections, |
||
| void | BatchAddSharedFragmentsForEntities
(
TConstArrayView< FMassArchetypeEntityCollection > EntityCollections, |
Adds a new const and non-const shared fragments to all entities provided via EntityCollections | |
| TSharedRef< FEntityCreationContext > | BatchBuildEntities
(
const FMassArchetypeEntityCollectionWithPayload& EncodedEntitiesWithPayload, |
||
| TSharedRef< FEntityCreationContext > | BatchBuildEntities
(
const FMassArchetypeEntityCollectionWithPayload& EncodedEntitiesWithPayload, |
||
| void | BatchChangeFragmentCompositionForEntities
(
TConstArrayView< FMassArchetypeEntityCollection > EntityCollections, |
||
| void | BatchChangeTagsForEntities
(
TConstArrayView< FMassArchetypeEntityCollection > EntityCollections, |
||
| TSharedRef< FEntityCreationContext > | BatchCreateEntities
(
const FMassArchetypeHandle& ArchetypeHandle, |
||
| TSharedRef< FEntityCreationContext > | BatchCreateEntities
(
const FMassArchetypeHandle& ArchetypeHandle, |
A version of CreateEntity that's creating a number of entities (Count) in one go | |
| TSharedRef< FEntityCreationContext > | BatchCreateReservedEntities
(
const FMassArchetypeHandle& ArchetypeHandle, |
A version of CreateEntity that's creating a number of entities (Count) in one go | |
| TSharedRef< FEntityCreationContext > | BatchCreateReservedEntities
(
const FMassArchetypeHandle& ArchetypeHandle, |
||
| void | BatchDestroyEntities
(
TConstArrayView< FMassEntityHandle > InEntities |
Destroys all the entities in the provided array of entities. | |
| void | BatchDestroyEntityChunks
(
TConstArrayView< FMassArchetypeEntityCollection > Collections |
||
| void | BatchDestroyEntityChunks
(
const FMassArchetypeEntityCollection& Collection |
Destroys all the entities provided via the Collection. | |
| TConstArrayView< FMassEntityHandle > | BatchReserveEntities
(
const int32 Count, |
Reserves Count number of entities and appends them to InOutEntities | |
| int32 | BatchReserveEntities
(
TArrayView< FMassEntityHandle > InOutEntities |
Reserves number of entities corresponding to number of entries in the provided array view InOutEntities. | |
| void | BatchSetEntityFragmentsValues
(
TConstArrayView< FMassArchetypeEntityCollection > EntityCollections, |
||
| void | BatchSetEntityFragmentsValues
(
const FMassArchetypeEntityCollection& SparseEntities, |
Copies values from FragmentInstanceList over to fragments of given entities collection. | |
| void | BuildEntity
(
FMassEntityHandle Entity, |
Builds an entity for it to be ready to be used by the subsystem | |
| void | BuildEntity
(
FMassEntityHandle Entity, |
Builds an entity for it to be ready to be used by the subsystem | |
| void | CheckIfEntityIsActive
(
FMassEntityHandle Entity |
Asserts that IsEntityBuilt. | |
| void | CheckIfEntityIsValid
(
FMassEntityHandle Entity |
Asserts that IsEntityValid. | |
| FMassArchetypeHandle | CreateArchetype
(
const FMassArchetypeCompositionDescriptor& Composition, |
CreateArchetype from a composition descriptor and initial values | |
| FMassArchetypeHandle | CreateArchetype
(
FMassArchetypeHandle SourceArchetype, |
A special, relaxed but slower version of CreateArchetype functions that allows FragmentAngTagsList to contain both fragments and tags. | |
| FMassArchetypeHandle | CreateArchetype
(
const TSharedPtr< FMassArchetypeData >& SourceArchetype, |
Creates an archetype like SourceArchetype + InFragments. | |
| FMassArchetypeHandle | CreateArchetype
(
FMassArchetypeHandle SourceArchetype, |
A special, relaxed but slower version of CreateArchetype functions that allows FragmentAngTagsList to contain both fragments and tags. | |
| FMassArchetypeHandle | CreateArchetype
(
const TSharedPtr< FMassArchetypeData >& SourceArchetype, |
Creates an archetype like SourceArchetype + InFragments. | |
| FMassArchetypeHandle | CreateArchetype
(
TConstArrayView< const UScriptStruct* > FragmentsAndTagsList, |
A special, relaxed but slower version of CreateArchetype functions that allows FragmentAngTagsList to contain both fragments and tags. | |
| FMassEntityHandle | CreateEntity
(
const FMassArchetypeHandle& ArchetypeHandle, |
Creates fully built entity ready to be used by the subsystem | |
| FMassEntityHandle | CreateEntity
(
TConstArrayView< FInstancedStruct > FragmentInstanceList, |
Creates fully built entity ready to be used by the subsystem | |
| FMassExecutionContext | CreateExecutionContext
(
const float DeltaSeconds |
Creates and initializes a FMassExecutionContext instance. | |
| FMassCommandBuffer & | Defer () |
||
| void | Deinitialize () |
||
| void | DestroyEntity
(
FMassEntityHandle Entity |
Destroys a fully built entity, use ReleaseReservedEntity if entity was not yet built. | |
| void | DoEntityCompaction
(
const double TimeAllowed |
Go through all archetypes and compact entities | |
| void | |||
| void | FlushCommands
(
TSharedPtr< FMassCommandBuffer >& InCommandBuffer |
||
| void | ForEachArchetypeFragmentType
(
const FMassArchetypeHandle& ArchetypeHandle, |
Method to iterate on all the fragment types of an archetype | |
| void | ForEachSharedFragment
(
TFunctionRef< void(T&) > ExecuteFunction |
||
| void | ForEachSharedFragmentConditional
(
TFunctionRef< bool(T&) > ConditionFunction, |
||
| const FMassArchetypeCompositionDescriptor & | GetArchetypeComposition
(
const FMassArchetypeHandle& ArchetypeHandle |
||
| uint32 | |||
| FMassArchetypeHandle | GetArchetypeForEntity
(
FMassEntityHandle Entity |
Fetches the archetype for a given Entity. | |
| FMassArchetypeHandle | GetArchetypeForEntityUnsafe
(
FMassEntityHandle Entity |
Fetches the archetype for a given Entity. | |
| ConstSharedFragmentType & | |||
| ConstSharedFragmentType * | GetConstSharedFragmentDataPtr
(
FMassEntityHandle Entity |
||
| FConstStructView | GetConstSharedFragmentDataStruct
(
FMassEntityHandle Entity, |
||
| FragmentType & | GetFragmentDataChecked
(
FMassEntityHandle Entity |
||
| FragmentType * | GetFragmentDataPtr
(
FMassEntityHandle Entity |
||
| FStructView | GetFragmentDataStruct
(
FMassEntityHandle Entity, |
||
| void | GetMatchingArchetypes
(
const FMassFragmentRequirements& Requirements, |
||
| FMassObserverManager & | |||
| FOnNewArchetypeDelegate & | |||
| const FConstSharedStruct & | GetOrCreateConstSharedFragment
(
const T& Fragment |
Returns or creates a shared struct associated to a given shared fragment set of values identified internally by a CRC. | |
| const FConstSharedStruct & | GetOrCreateConstSharedFragment
(
const UScriptStruct& InScriptStruct, |
Returns or creates a shared struct associated to a given shared fragment set of values identified internally by a CRC. | |
| const FConstSharedStruct & | GetOrCreateConstSharedFragment
(
const FConstStructView HashingHelperStruct, |
Returns or creates a shared struct associated to a given shared fragment set of values identified internally by a CRC. | |
| const FConstSharedStruct & | GetOrCreateConstSharedFragment
(
TArgs&&... InArgs |
Returns or creates a shared struct associated to a given shared fragment set of values identified internally by a CRC. | |
| const FConstSharedStruct & | GetOrCreateConstSharedFragmentByHash
(
const uint32 Hash, |
||
| const FSharedStruct & | GetOrCreateSharedFragment
(
const UScriptStruct& InScriptStruct, |
Returns or creates a shared struct associated to a given shared fragment set of values identified internally by a CRC. | |
| const FSharedStruct & | GetOrCreateSharedFragment
(
const T& Fragment |
Returns or creates a shared struct associated to a given shared fragment set of values identified internally by a CRC. | |
| const FSharedStruct & | GetOrCreateSharedFragment
(
TArgs&&... InArgs |
Returns or creates a shared struct associated to a given shared fragment set of values identified internally by a CRC. | |
| const FSharedStruct & | GetOrCreateSharedFragment
(
const FConstStructView HashingHelperStruct, |
Returns or creates a shared struct associated to a given shared fragment set of values identified internally by a CRC. | |
| const FSharedStruct & | GetOrCreateSharedFragmentByHash
(
const uint32 Hash, |
||
| FMassArchetypeHandle | GetOrCreateSuitableArchetype
(
const FMassArchetypeHandle& ArchetypeHandle, |
A helper function to be used when creating entities with shared fragments provided, or when adding shared fragments to existing entities | |
| TSharedRef< FEntityCreationContext > | 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. | ||
| UObject * | GetOwner () |
||
| FString | |||
| void | GetResourceSizeEx
(
FResourceSizeEx& CumulativeResourceSize |
||
| SharedFragmentType & | GetSharedFragmentDataChecked
(
FMassEntityHandle Entity |
||
| SharedFragmentType * | GetSharedFragmentDataPtr
(
FMassEntityHandle Entity |
||
| FConstStructView | GetSharedFragmentDataStruct
(
FMassEntityHandle Entity, |
||
| TConstArrayView< FSharedStruct > | |||
| UWorld * | GetWorld () |
Fetches the world associated with the Owner. | |
| void | Initialize
(
const FMassEntityManagerStorageInitParams& InitializationParams |
||
| void | Initialize () |
Default to use single threaded implementation. | |
| void | InternalAppendFragmentsAndTagsToArchetypeCompositionDescriptor
(
FMassArchetypeCompositionDescriptor& InOutComposition, |
||
| FMassArchetypeHandle | InternalCreateSimilarArchetype
(
const TSharedPtr< FMassArchetypeData >& SourceArchetype, |
A "similar" archetype is an archetype exactly the same as SourceArchetype except for one composition aspect like Fragments or "Tags" | |
| FMassArchetypeHandle | InternalCreateSimilarArchetype
(
const FMassArchetypeData& SourceArchetypeRef, |
||
| FMassArchetypeHandle | InternalCreateSimilarArchetype
(
const TSharedPtr< FMassArchetypeData >& SourceArchetype, |
||
| bool | IsEntityActive
(
FMassEntityHandle Entity |
Return true if it is an valid built entity. | |
| bool | IsEntityBuilt
(
FMassEntityHandle Entity |
Returns true if Entity is has been fully built (expecting a valid Entity) | |
| bool | IsEntityValid
(
FMassEntityHandle Entity |
Returns true if Entity is valid. | |
| bool | IsProcessing () |
Indicates whether there are processors out there performing operations on this instance of MassEntityManager. | |
| void | MoveEntityToAnotherArchetype
(
FMassEntityHandle Entity, |
Moves an entity over to a new archetype by copying over fragments common to both archetypes | |
| FScopedProcessing | |||
| void | OnPostFork
(
EForkProcessRole Role |
Called on the child process upon process's forking | |
| void | |||
| void | ReleaseReservedEntity
(
FMassEntityHandle Entity |
Releases a previously reserved entity that was not yet built, otherwise call DestroyEntity | |
| void | RemoveCompositionFromEntity
(
FMassEntityHandle Entity, |
||
| bool | RemoveConstSharedFragmentFromEntity
(
const FMassEntityHandle Entity, |
Removes a const shared fragment of the given type from the entity. | |
| void | RemoveFragmentFromEntity
(
FMassEntityHandle Entity, |
||
| void | RemoveFragmentListFromEntity
(
FMassEntityHandle Entity, |
||
| void | RemoveTagFromEntity
(
FMassEntityHandle Entity, |
||
| FMassEntityHandle | Reserves an entity in the subsystem, the entity is still not ready to be used by the subsystem, need to call BuildEntity() | ||
| void | SetDebugName
(
const FString& NewDebugGame |
||
| void | SetEntityFragmentsValues
(
FMassEntityHandle Entity, |
Copies values from FragmentInstanceList over to Entity's fragment. | |
| void | SwapTagsForEntity
(
FMassEntityHandle Entity, |
Classes
| Type | Name | Description | |
|---|---|---|---|
| FEntityCreationContext | A dedicated structure for ensuring the "on entities creation" observers get notified only once all other initialization operations are done and this creation context instance gets released. | ||
| FScopedProcessing |
Typedefs
Constants
| Name | Description |
|---|---|
| InvalidEntity | |
| NumReservedEntities | Index 0 is reserved so we can treat that index as an invalid entity handle. |
See Also
FMassCommandBuffer for more details.