Navigation
API > API/Runtime > API/Runtime/MassEntity
Adds any mix of non-shared element types to entities. This is the preferred command for element addition. Types are template parameters — uses PushCommand for efficient cross-chunk batching (one Run() for all entities across all chunks that push into this command). Performs a single entity move for all non-sparse types. Shared/const shared fragments cannot be added — they require values (use AddSharedFragmentToEntity).
When to use: whenever you need to add fragments, tags, and/or sparse elements to entities and the types are known at compile time. Replaces FMassCommandAddFragments and FMassCommandAddTags.
Example: // All entities in chunk: Context.Defer().PushCommand
Supported types: FMassFragment, FMassTag, FMassSparseFragment, FMassSparseTag. Rejected types: FMassSharedFragment, FMassConstSharedFragment (compile-time static_assert), FMassChunkFragment (runtime). Breakpoint support: Yes — CheckFragmentAddBreakpoints called per entity at PushCommand time. Entity moves: 1 move for all non-sparse types combined. Sparse addition is in-place (no move).
| Name | FMassCommandAddElements |
| Type | struct |
| Header File | /Engine/Source/Runtime/MassEntity/Public/MassCommands.h |
| Include Path | #include "MassCommands.h" |
Syntax
template<typename... TTypes>
struct FMassCommandAddElements : public FMassBatchedEntityCommand
Inheritance Hierarchy
- FMassBatchedCommand → FMassBatchedEntityCommand → FMassCommandAddElements
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FMassCommandAddElements() |
MassCommands.h |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| Super | FMassBatchedEntityCommand | MassCommands.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| NonSparseTypes | FMassElementBitSet | MassCommands.h | ||
| SparseTypes | TArray< const UScriptStruct * > | MassCommands.h |
Functions
Public
Protected Virtual
Overridden from FMassBatchedCommand
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual SIZE_T GetAllocatedSize() |
MassCommands.h | ||
virtual void Run
(
FMassEntityManager& EntityManager |
MassCommands.h |