Navigation
API > API/Runtime > API/Runtime/MassEntity
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.
| Name | FEntityCollection |
| Type | struct |
| Header File | /Engine/Source/Runtime/MassEntity/Public/MassEntityCollection.h |
| Include Path | #include "MassEntityCollection.h" |
Syntax
struct FEntityCollection
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FEntityCollection
(
const FMassArchetypeEntityCollection& InEntityCollection |
MassEntityCollection.h | ||
FEntityCollection
(
FMassArchetypeEntityCollection&& InEntityCollection |
The following constructor are equivalent to using the default constructor and subsequently calling AppendCollection or AppendHandles. | MassEntityCollection.h | |
| MassEntityCollection.h | |||
FEntityCollection
(
const TConstArrayView< FMassEntityHandle > InEntityHandles, |
MassEntityCollection.h | ||
FEntityCollection
(
const TConstArrayView< FMassEntityHandle > InEntityHandles |
MassEntityCollection.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| CachedCollections | TArray< FMassArchetypeEntityCollection > | Cached per-archetype collections of entities. | MassEntityCollection.h | |
| CollectionCreationDuplicatesHandling | FMassArchetypeEntityCollection::EDuplicatesHandling | Stores information whether we can expect duplicates in EntityHandles when building CachedCollections | MassEntityCollection.h | |
| EntityHandles | TArray< FMassEntityHandle > | These are the entities represented by given instance of FEntityCollection. | MassEntityCollection.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void AddHandle
(
FMassEntityHandle Handle |
Appends the Handle to stored EntityHandles. | MassEntityCollection.h | |
void AppendCollection
(
T&& InEntityCollection |
Based on the provided FMassArchetypeEntityCollection creates an array of entity handles and stores them. | MassEntityCollection.h | |
void AppendHandles
(
TConstArrayView< FMassEntityHandle > Handles, |
Appends Handles to stored EntityHandles. | MassEntityCollection.h | |
void AppendHandles
(
TArray< FMassEntityHandle >&& Handles |
Appends Handles to stored EntityHandles. | MassEntityCollection.h | |
void AppendHandles
(
TConstArrayView< FMassEntityHandle > Handles |
Mutating API | MassEntityCollection.h | |
TArray< FMassArchetypeEntityCollection > ConsumeArchetypeCollections
(
const FMassEntityManager& EntityManager |
Updates cached archetype collections and returns the container with move semantics | MassEntityCollection.h | |
TConstArrayView< FMassArchetypeEntityCollection > GetCachedPerArchetypeCollections () |
Retrieves the view to current contents of CachedCollections, which may be out of date. | MassEntityCollection.h | |
TConstArrayView< FMassEntityHandle > GetEntityHandlesView() |
Data reading API | MassEntityCollection.h | |
TConstArrayView< FMassArchetypeEntityCollection > GetUpToDatePerArchetypeCollections
(
const FMassEntityManager& EntityManager |
Fetches up-to-date FMassArchetypeEntityCollection instances matching stored entity handles. | MassEntityCollection.h | |
bool IsEmpty() |
MassEntityCollection.h | ||
bool IsUpToDate () |
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. | MassEntityCollection.h | |
void MarkDirty() |
State-querying API | MassEntityCollection.h | |
bool UpdateAndRemoveDuplicates
(
const FMassEntityManager& EntityManager, |
Results in duplicate handles being removed from EntityHandles, the cached collections being up-to-date and CollectionCreationDuplicatesHandling being set to FMassArchetypeEntityCollection::NoDuplicates | MassEntityCollection.h |