Navigation
API > API/Runtime > API/Runtime/MassEntity
Adds fragment types with per-entity values AND shared fragment values to existing entities in a single entity move. Extends FMassCommandAddFragmentInstances with shared fragment value support; entities are partitioned by shared fragment value hash at Add() time and dispatched in one BatchAddFragmentInstancesForEntities call per group. When no shared fragment values are needed, prefer FMassCommandAddFragmentInstances — its flat single-batch storage avoids the per-Add hash computation and TMap overhead. Uses PushCommand for cross-chunk batching.
Note: TSharedFragmentValues is always FMassArchetypeSharedFragmentValues but is a template param to maintain uniform PushCommand interface (all params in one typename... list).
When to use: when you need to add fragments with initial values AND shared fragment values to existing entities in one operation. Replaces separate AddFragmentInstances + deferred lambda AddConstSharedFragmentToEntity calls.
Example: FMassArchetypeSharedFragmentValues SharedValues; SharedValues.Add(EntityManager->GetOrCreateConstSharedFragment(FMySharedFragment(42))); Context.Defer().PushCommand
Supported types (TTypes): FMassFragment + FMassTag (including sparse). Tags are included in composition but excluded from value payload (zero-size storage). Shared fragments via FMassArchetypeSharedFragmentValues. Breakpoint support: Yes CheckFragmentAddBreakpoints called at PushCommand time. Entity moves: 1 move per shared-value group. Fragment values set in-place after move.
| Name | FMassCommandAddFragmentInstancesWithSharedFragments |
| Type | struct |
| Header File | /Engine/Source/Runtime/MassEntity/Public/MassCommands.h |
| Include Path | #include "MassCommands.h" |
Syntax
template<typename TSharedFragmentValues, typename... TTypes>
struct FMassCommandAddFragmentInstancesWithSharedFragments : public FMassBatchedCommand
Inheritance Hierarchy
- FMassBatchedCommand → FMassCommandAddFragmentInstancesWithSharedFragments
Derived Classes
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FMassCommandAddFragmentInstancesWithSharedFragments
(
EMassCommandOperationType OperationType |
MassCommands.h |
Structs
| Name | Remarks |
|---|---|
| FPerSharedFragmentsHashData |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| Super | FMassBatchedCommand | 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 |