Navigation
API > API/Runtime > API/Runtime/MassEntity
Adds any mix of non-shared element types AND shared fragment values to existing entities. Types are template parameters for non-shared elements. Shared fragment values are provided at runtime. Entities are grouped by shared fragment value hash for efficient per-group archetype changes. Performs a single entity move per group (non-sparse composition + shared values combined).
When to use: when you need to add fragments/tags AND shared fragment values to existing entities in a single operation. Replaces separate AddElements + BatchAddSharedFragmentsForEntities calls.
Example: FMassArchetypeSharedFragmentValues SharedValues; SharedValues.Add(EntityManager->GetOrCreateConstSharedFragment(FMySharedFragment(42))); Context.Defer().PushCommand
Supported types (TTypes): FMassFragment + FMassTag (including sparse). Rejected types (TTypes): FMassSharedFragment, FMassConstSharedFragment (use shared values param instead), FMassChunkFragment. Breakpoint support: No (composition-only command). Entity moves: 1 move per shared-value group. Sparse addition is in-place.
| Name | FMassCommandAddElementsWithSharedFragments |
| Type | struct |
| Header File | /Engine/Source/Runtime/MassEntity/Public/MassCommands.h |
| Include Path | #include "MassCommands.h" |
Syntax
template<typename... TTypes>
struct FMassCommandAddElementsWithSharedFragments : public FMassBatchedCommand
Inheritance Hierarchy
- FMassBatchedCommand → FMassCommandAddElementsWithSharedFragments
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FMassCommandAddElementsWithSharedFragments() |
MassCommands.h |
Structs
| Name | Remarks |
|---|---|
| FPerSharedFragmentsHashData |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| Super | FMassBatchedCommand | MassCommands.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Data | TMap< uint32, FPerSharedFragmentsHashData > | MassCommands.h | ||
| NonSparseTypes | FMassElementBitSet | MassCommands.h | ||
| SparseTypes | TArray< const UScriptStruct * > | MassCommands.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void Add
(
FMassEntityHandle Entity, |
Callers must not Add() the same entity with different shared values — it would end up in two hash groups, and the second group's archetype move would overwrite the first group's without merging fragment values. | MassCommands.h |
Protected Virtual
Overridden from FMassBatchedCommand
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual SIZE_T GetAllocatedSize() |
MassCommands.h | ||
virtual void Reset() |
MassCommands.h | ||
virtual void Run
(
FMassEntityManager& EntityManager |
MassCommands.h |