UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE::Mass::FEntityCollection Struct Reference

#include <MassEntityCollection.h>

Public Member Functions

 FEntityCollection ()=default
 
MASSENTITY_API FEntityCollection (FMassArchetypeEntityCollection &&InEntityCollection)
 
MASSENTITY_API FEntityCollection (const FMassArchetypeEntityCollection &InEntityCollection)
 
MASSENTITY_API FEntityCollection (const TConstArrayView< FMassEntityHandle > InEntityHandles)
 
MASSENTITY_API FEntityCollection (const TConstArrayView< FMassEntityHandle > InEntityHandles, FMassArchetypeEntityCollection &&InEntityCollection)
 
MASSENTITY_API void AppendHandles (TConstArrayView< FMassEntityHandle > Handles)
 
MASSENTITY_API void AppendHandles (TConstArrayView< FMassEntityHandle > Handles, FMassArchetypeEntityCollection &&InEntityCollection)
 
MASSENTITY_API void AppendHandles (TArray< FMassEntityHandle > &&Handles)
 
MASSENTITY_API void AddHandle (FMassEntityHandle Handle)
 
template<typename T >
requires std::is_same_v<typename TDecay<T>::Type, FMassArchetypeEntityCollection>
void AppendCollection (T &&InEntityCollection)
 
MASSENTITY_API bool UpdateAndRemoveDuplicates (const FMassEntityManager &EntityManager, bool bForceOperation=false)
 
void MarkDirty ()
 
bool IsEmpty () const
 
MASSENTITY_API bool IsUpToDate () const
 
TConstArrayView< FMassEntityHandleGetEntityHandlesView () const
 
TConstArrayView< FMassArchetypeEntityCollectionGetCachedPerArchetypeCollections () const
 
TConstArrayView< FMassArchetypeEntityCollectionGetUpToDatePerArchetypeCollections (const FMassEntityManager &EntityManager) const
 
TArray< FMassArchetypeEntityCollectionConsumeArchetypeCollections (const FMassEntityManager &EntityManager) &&
 

Detailed Description

Type represents a collection of arbitrary EntityHandles. Under the hood the type stores also an array of FMassArchetypeEntityCollection instances. These cached collections can be tested for being up to date, and re-created on demand, based on stored entity handles.

The type is intended to be used to collect entities available through different means: individual handles, handle arrays and or FMassArchetypeEntityCollection instances. Such accumulated handles can at any moment be turned into an array of up-to-date FMassArchetypeEntityCollection instance, which in turn is how entity sets are provided to MassEntityManager's batched API.

The biggest win while using this type is that the user doesn't have to worry about FMassArchetypeEntityCollection instances going out of date (which happens whenever the target archetype is touched in a way that changes internal entity indices). The type automatically updates the collections and caches the result.

Constructor & Destructor Documentation

◆ FEntityCollection() [1/5]

UE::Mass::FEntityCollection::FEntityCollection ( )
default

◆ FEntityCollection() [2/5]

UE::Mass::FEntityCollection::FEntityCollection ( FMassArchetypeEntityCollection &&  InEntityCollection)
explicit

The following constructor are equivalent to using the default constructor and subsequently calling AppendCollection or AppendHandles.

◆ FEntityCollection() [3/5]

UE::Mass::FEntityCollection::FEntityCollection ( const FMassArchetypeEntityCollection InEntityCollection)
explicit

◆ FEntityCollection() [4/5]

UE::Mass::FEntityCollection::FEntityCollection ( const TConstArrayView< FMassEntityHandle InEntityHandles)
explicit

◆ FEntityCollection() [5/5]

UE::Mass::FEntityCollection::FEntityCollection ( const TConstArrayView< FMassEntityHandle InEntityHandles,
FMassArchetypeEntityCollection &&  InEntityCollection 
)

Member Function Documentation

◆ AddHandle()

void UE::Mass::FEntityCollection::AddHandle ( FMassEntityHandle  Handle)

Appends the Handle to stored EntityHandles. Results in marking cached FMassArchetypeEntityCollection as dirty.

◆ AppendCollection()

template<typename T >
requires std::is_same_v<typename TDecay<T>::Type, FMassArchetypeEntityCollection>
void UE::Mass::FEntityCollection::AppendCollection ( T &&  InEntityCollection)
inline

Based on the provided FMassArchetypeEntityCollection creates an array of entity handles and stores them. If up to this point the cached FMassArchetypeEntityCollection-s are consistent with stored EntityHandles then InEntityCollection gets stored as well, and stored collections are not marked as dirty.

◆ AppendHandles() [1/3]

void UE::Mass::FEntityCollection::AppendHandles ( TArray< FMassEntityHandle > &&  Handles)

Appends Handles to stored EntityHandles. Results in marking cached FMassArchetypeEntityCollection as dirty.

◆ AppendHandles() [2/3]

void UE::Mass::FEntityCollection::AppendHandles ( TConstArrayView< FMassEntityHandle Handles)

Appends Handles to stored EntityHandles. Results in marking cached FMassArchetypeEntityCollection as dirty.

◆ AppendHandles() [3/3]

void UE::Mass::FEntityCollection::AppendHandles ( TConstArrayView< FMassEntityHandle Handles,
FMassArchetypeEntityCollection &&  InEntityCollection 
)

Appends Handles to stored EntityHandles. The second parameter is relevant if, at the moment of calling, the cached FMassArchetypeEntityCollection instances are in sync with stored entity handles (meaning all entities stored in EntityHandles are also captured by one of FMassArchetypeEntityCollection). If that's the case then the InEntityCollection gets stored along with existing collections. Otherwise, InEntityCollection will be ignored.

◆ ConsumeArchetypeCollections()

TArray< FMassArchetypeEntityCollection > UE::Mass::FEntityCollection::ConsumeArchetypeCollections ( const FMassEntityManager EntityManager) &&
inline

Updates cached archetype collections and returns the container with move semantics

◆ GetCachedPerArchetypeCollections()

TConstArrayView< FMassArchetypeEntityCollection > UE::Mass::FEntityCollection::GetCachedPerArchetypeCollections ( ) const
inline

Retrieves the view to current contents of CachedCollections, which may be out of date. If you need valid, up-to-date collections call GetUpToDatePerArchetypeCollections instead.

◆ GetEntityHandlesView()

TConstArrayView< FMassEntityHandle > UE::Mass::FEntityCollection::GetEntityHandlesView ( ) const
inline

◆ GetUpToDatePerArchetypeCollections()

TConstArrayView< FMassArchetypeEntityCollection > UE::Mass::FEntityCollection::GetUpToDatePerArchetypeCollections ( const FMassEntityManager EntityManager) const
inline

Fetches up-to-date FMassArchetypeEntityCollection instances matching stored entity handles.

◆ IsEmpty()

bool UE::Mass::FEntityCollection::IsEmpty ( ) const
inline

◆ IsUpToDate()

bool UE::Mass::FEntityCollection::IsUpToDate ( ) const

Checks if cached collection data is up to date If CachedCollections are not up-to-date we reset them to cache the information (and make the subsequent tests cheaper) Note that, depending on the contents, the test might be non-trivial. Use responsibly.

◆ MarkDirty()

void UE::Mass::FEntityCollection::MarkDirty ( )
inline

◆ UpdateAndRemoveDuplicates()

bool UE::Mass::FEntityCollection::UpdateAndRemoveDuplicates ( const FMassEntityManager EntityManager,
bool  bForceOperation = false 
)

Results in duplicate handles being removed from EntityHandles, the cached collections being up-to-date and CollectionCreationDuplicatesHandling being set to FMassArchetypeEntityCollection::NoDuplicates

Parameters
bForceOperationby default the entity handles will be re-exported only if CollectionCreationDuplicatesHandling == FMassArchetypeEntityCollection::FoldDuplicates (which means we cannot rule out that there are duplicates). Using bForceOperation = true will perform the operation regardless.
Returns
whether any duplicates were detected

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