Navigation
API > API/Runtime > API/Runtime/MassEntity
Storage type for hosting instances of sparse elements.
Sparse elements are optional tags and fragments that can be added to an entity without causing it to change archetypes. Sparse elements are not part of Archetype's composition - instead, data on which entity has which elements is stored per archetype chunk. Sparse tags live there (since they don't contain any data per instance). Sparse fragment instances live in FSparseElementsStorage.
FSparseElementsStorage provides a way iterate through all instances of a given sparse element type, using UE::Mass::FSparseElementIterator. To create one call FMassEntityManager::CreateSparseElementsIterator
Sparse fragment instances are stored in per-type pools (FSparseElementsStorage::FTypePool) which store data in chunks (FSparseElementsStorage::FPackedStructDataChunk), and each chunk contains uniform array of instances of the hosted struct type, along with a bitset indicating which elements are valid (i.e. "set").
Do not use directly. The storage is to be accessed via FMassEntityManager and other means that forward their calls to the entity manager.
| Name | FSparseElementsStorage |
| Type | struct |
| Header File | /Engine/Source/Runtime/MassEntity/Public/MassSparseElementsStorage.h |
| Include Path | #include "MassSparseElementsStorage.h" |
Syntax
struct FSparseElementsStorage
Structs
| Name | Remarks |
|---|---|
| FPackedStructDataChunk | |
| FTypeConfig | |
| FTypePool |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| FSparseElementIterator | friend | MassSparseElementsStorage.h | ||
| TypePools | TSparseArray< FTypePool > | MassSparseElementsStorage.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FStructView AddElementInstanceToEntity
(
FMassEntityHandle EntityHandle, |
MassSparseElementsStorage.h | ||
FStructView AddElementToEntity
(
FMassEntityHandle EntityHandle, |
MassSparseElementsStorage.h | ||
T & AddElementToEntity
(
FMassEntityHandle EntityHandle |
MassSparseElementsStorage.h | ||
void BatchAddElementInstancesToEntities
(
TArrayView< const FMassEntityHandle > InEntityHandles, |
Adds FragmentInstance (type and values) to each entity indicated by InEntityHandles | MassSparseElementsStorage.h | |
void BatchAddElementInstancesToEntities
(
TArrayView< const FMassEntityHandle > InEntityHandles, |
MassSparseElementsStorage.h | ||
void BatchAddElementToEntities
(
TArrayView< const FMassEntityHandle > InEntityHandles, |
MassSparseElementsStorage.h | ||
void BatchAddElementToEntities
(
TArray< FMassEntityHandle >& InOutEntityHandles, |
MassSparseElementsStorage.h | ||
void BatchAddElementToEntities
(
TArray< FMassEntityHandle >& InOutEntityHandles, |
MassSparseElementsStorage.h | ||
int32 BatchRemoveElementFromEntities
(
TArray< FMassEntityHandle >& InOutEntityHandles, |
MassSparseElementsStorage.h | ||
int32 BatchRemoveElementFromEntities
(
TArray< FMassEntityHandle >& InOutEntityHandles |
MassSparseElementsStorage.h | ||
int32 BatchRemoveElementFromEntities
(
TArrayView< const FMassEntityHandle > InEntityHandles, |
MassSparseElementsStorage.h | ||
void ConfigureType
(
TNotNull< const UScriptStruct* > ElementType, |
MassSparseElementsStorage.h | ||
FSparseElementIterator CreateElementIterator
(
TNotNull< const UScriptStruct* > ElementType |
INLINES. | MassSparseElementsStorage.h | |
void Deinitialize() |
MassSparseElementsStorage.h | ||
FConstStructView GetElementDataForEntity
(
const FMassEntityHandle EntityHandle, |
MassSparseElementsStorage.h | ||
FStructView GetMutableElementDataForEntity
(
const FMassEntityHandle EntityHandle, |
MassSparseElementsStorage.h | ||
uint32 GetNumElementsOfType
(
TNotNull< const UScriptStruct* > ElementType |
Returns the total number of instances of the given sparse element type | MassSparseElementsStorage.h | |
uint32 GetNumElementsOfType () |
MassSparseElementsStorage.h | ||
bool HasAnyElementsOfType () |
MassSparseElementsStorage.h | ||
bool HasAnyElementsOfType
(
TNotNull< const UScriptStruct* > ElementType |
Checks whether there are any instances of the given sparse element type | MassSparseElementsStorage.h | |
bool RemoveElementFromEntity
(
FMassEntityHandle EntityHandle |
MassSparseElementsStorage.h | ||
bool RemoveElementFromEntity
(
FMassEntityHandle EntityHandle, |
MassSparseElementsStorage.h | ||
void RemoveEntity
(
FMassEntityHandle EntityHandle, |
Clears sparse elements instances belonging to entities indicated by EntityHandles | MassSparseElementsStorage.h |