UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MassArchetypeData.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "MassEntityHandle.h"
8#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_6
9#include "MassEntityManager.h"
10#endif // UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_6
12
13struct FMassEntityQuery;
15class FOutputDevice;
19
20namespace UE::Mass
21{
23}
24
25// This is one chunk within an archetype
27{
28private:
29 uint8* RawMemory = nullptr;
30 SIZE_T AllocSize = 0;
31 int32 NumInstances = 0;
32 int32 SerialModificationNumber = 0;
33 TArray<FInstancedStruct> ChunkFragmentData;
34 FMassArchetypeSharedFragmentValues SharedFragmentValues;
35
36public:
38 : AllocSize(InAllocSize)
39 , ChunkFragmentData(InChunkFragmentTemplates)
40 , SharedFragmentValues(InSharedFragmentValues)
41 {
42
43 LLM_SCOPE_BYNAME(TEXT("Mass/ArchetypeChunk"));
44 RawMemory = (uint8*)FMemory::Malloc(AllocSize);
45 }
46
48 {
49 // Only release memory if it was not done already.
50 if (RawMemory != nullptr)
51 {
52 FMemory::Free(RawMemory);
53 RawMemory = nullptr;
54 }
55 }
56
57 // Returns the Entity array element at the specified index
59 {
60 uint8* RawMemoryChunkBase = RawMemory + ChunkBase;
61 checkSlow(ChunkBase + IndexWithinChunk * sizeof(FMassEntityHandle) < AllocSize
62 && (reinterpret_cast<SIZE_T>(RawMemoryChunkBase) % alignof(FMassEntityHandle)) == 0);
63 return reinterpret_cast<FMassEntityHandle*>(RawMemoryChunkBase)[IndexWithinChunk];
64 }
65
67 {
68 uint8* RawMemoryChunkBase = RawMemory + ChunkBase;
69 checkSlow(ChunkBase < AllocSize
70 && (reinterpret_cast<SIZE_T>(RawMemoryChunkBase) % alignof(FMassEntityHandle)) == 0);
71 return reinterpret_cast<const FMassEntityHandle*>(RawMemoryChunkBase);
72 }
73
75 {
76 return RawMemory;
77 }
78
80 {
81 return NumInstances;
82 }
83
85 {
86 NumInstances += Count;
87 SerialModificationNumber++;
88 }
89
91 {
92 NumInstances -= Count;
93 check(NumInstances >= 0);
94 SerialModificationNumber++;
95
96 // Because we only remove trailing chunks to avoid messing up the absolute indices in the entities map,
97 // We are freeing the memory here to save memory
98 if (NumInstances == 0)
99 {
100 FMemory::Free(RawMemory);
101 RawMemory = nullptr;
102 }
103 }
104
106 {
108 }
109
111 {
113 }
114
116 {
117 return SerialModificationNumber;
118 }
119
121
123 {
124 return ChunkFragmentData.FindByPredicate([Type](const FInstancedStruct& Element)
125 {
126 return Element.GetScriptStruct()->IsChildOf(Type);
127 });
128 }
129
131 {
132 checkf(NumInstances == 0, TEXT("Recycling a chunk that is not empty."));
133 SerialModificationNumber++;
134 ChunkFragmentData = InChunkFragmentsTemplate;
135 SharedFragmentValues = InSharedFragmentValues;
136
137 // If this chunk previously had entity and it does not anymore, we might have to reallocate the memory as it was freed to save memory
138 if (RawMemory == nullptr)
139 {
140 RawMemory = (uint8*)FMemory::Malloc(AllocSize);
141 }
142 }
143
144 bool IsValidSubChunk(const int32 StartIndex, const int32 Length) const
145 {
146 return StartIndex >= 0 && StartIndex < NumInstances && (StartIndex + Length) <= NumInstances;
147 }
148
149#if WITH_MASSENTITY_DEBUG
150 int32 DebugGetChunkFragmentCount() const { return ChunkFragmentData.Num(); }
151#endif // WITH_MASSENTITY_DEBUG
152
154 const FMassArchetypeSharedFragmentValues& GetSharedFragmentValues() const { return SharedFragmentValues; }
155};
156
157// Information for a single fragment type in an archetype
159{
160 const UScriptStruct* FragmentType = nullptr;
162
163 void* GetFragmentData(uint8* ChunkBase, int32 IndexWithinChunk) const
164 {
165 return ChunkBase + ArrayOffsetWithinChunk + (IndexWithinChunk * FragmentType->GetStructureSize());
166 }
167};
168
169// An archetype is defined by a collection of unique fragment types (no duplicates).
170// Order doesn't matter, there will only ever be one FMassArchetypeData per unique set of fragment types per entity manager subsystem
172{
173private:
174 // One-stop-shop variable describing the archetype's fragment and tag composition
175 FMassArchetypeCompositionDescriptor CompositionDescriptor;
176
177 // Pre-created default chunk fragment templates
178 TArray<FInstancedStruct> ChunkFragmentsTemplate;
179
181
183
184 // Entity ID to index within archetype
185 //@TODO: Could be folded into FEntityData in the entity manager at the expense of a bit
186 // of loss of encapsulation and extra complexity during archetype changes
187 TMap<int32, int32> EntityMap;
188
189 TMap<const UScriptStruct*, int32> FragmentIndexMap;
190
192
193 int32 NumEntitiesPerChunk;
194 uint32 TotalBytesPerEntity = 0;
195 int32 EntityListOffsetWithinChunk;
196
201 uint32 CreatedArchetypeDataVersion = 0;
202
207 uint32 EntityOrderVersion = 0;
208
210 const uint32 ChunkMemorySize = 0;
211
212#if WITH_MASSENTITY_DEBUG
214 TArray<FName> DebugNames;
215
221 FColor DebugColor;
222#endif // WITH_MASSENTITY_DEBUG
223
224 friend FMassEntityQuery;
226 friend FMassDebugger;
227
228public:
230
232 const FMassFragmentBitSet& GetFragmentBitSet() const { return CompositionDescriptor.GetFragments(); }
233 const FMassTagBitSet& GetTagBitSet() const { return CompositionDescriptor.GetTags(); }
234 const FMassChunkFragmentBitSet& GetChunkFragmentBitSet() const { return CompositionDescriptor.GetChunkFragments(); }
235 const FMassSharedFragmentBitSet& GetSharedFragmentBitSet() const { return CompositionDescriptor.GetSharedFragments(); }
237
238 const FMassArchetypeCompositionDescriptor& GetCompositionDescriptor() const { return CompositionDescriptor; }
240 {
241 const int32 AbsoluteIndex = EntityMap.FindChecked(EntityIndex);
242 const int32 ChunkIndex = AbsoluteIndex / NumEntitiesPerChunk;
243
244 return Chunks[ChunkIndex].GetSharedFragmentValues();
245 }
250
252 bool IsInGroup(const UE::Mass::FArchetypeGroupHandle GroupHandle) const;
253 bool IsInGroupOfType(const UE::Mass::FArchetypeGroupType GroupType) const;
254
256 void ForEachFragmentType(TFunction< void(const UScriptStruct* /*FragmentType*/)> Function) const;
257 bool HasFragmentType(const UScriptStruct* FragmentType) const;
258 bool HasTagType(const UScriptStruct* FragmentType) const { check(FragmentType); return CompositionDescriptor.GetTags().Contains(*FragmentType); }
259
261
262 void Initialize(const FMassEntityManager& EntityManager, const FMassArchetypeCompositionDescriptor& InCompositionDescriptor, const uint32 ArchetypeDataVersion);
263
270
272 void RemoveEntity(FMassEntityHandle Entity);
273
274 bool HasFragmentDataForEntity(const UScriptStruct* FragmentType, int32 EntityIndex) const;
275 void* GetFragmentDataForEntityChecked(const UScriptStruct* FragmentType, int32 EntityIndex) const;
276 void* GetFragmentDataForEntity(const UScriptStruct* FragmentType, int32 EntityIndex) const;
277
278 FORCEINLINE const int32* GetInternalIndexForEntity(const int32 EntityIndex) const { return EntityMap.Find(EntityIndex); }
279 FORCEINLINE int32 GetInternalIndexForEntityChecked(const int32 EntityIndex) const { return EntityMap.FindChecked(EntityIndex); }
280 int32 GetNumEntitiesPerChunk() const { return NumEntitiesPerChunk; }
281 SIZE_T GetBytesPerEntity() const { return TotalBytesPerEntity; }
282
283 int32 GetNumEntities() const { return EntityMap.Num(); }
284
285 SIZE_T GetChunkAllocSize() const { return ChunkMemorySize; }
286
287 int32 GetChunkCount() const { return Chunks.Num(); }
289
291 {
292 return EntityRange.Length > 0
293 ? EntityRange.Length
294 : (Chunk.GetNumInstances() - EntityRange.SubchunkStart);
295 }
296
303
306
311
314
319 int32 CompactEntities(const double TimeAllowed);
320
328
335
339
342
345
348
351
352 SIZE_T GetAllocatedSize() const;
353
355
357
358 // Converts the list of fragments into a user-readable debug string
359 FString DebugGetDescription() const;
360
363 {
364#if WITH_MASSENTITY_DEBUG
365 DebugNames = Other.DebugNames;
366#endif // WITH_MASSENTITY_DEBUG
367 }
368
369#if WITH_MASSENTITY_DEBUG
372
374 void AddUniqueDebugName(const FName& Name) { DebugNames.AddUnique(Name); }
375
377 const TConstArrayView<FName> GetDebugNames() const { return DebugNames; }
378
380 FString GetCombinedDebugNamesAsString() const;
381
386
393 void DebugPrintEntity(FMassEntityHandle Entity, FOutputDevice& Ar, const TCHAR* InPrefix = TEXT("")) const;
394#endif // WITH_MASSENTITY_DEBUG
395
397
398 void REMOVEME_GetArrayViewForFragmentInChunk(int32 ChunkIndex, const UScriptStruct* FragmentType, void*& OutChunkBase, int32& OutNumEntities);
399
401 // low level api
402 FORCEINLINE const int32* GetFragmentIndex(const UScriptStruct* FragmentType) const { return FragmentIndexMap.Find(FragmentType); }
403 FORCEINLINE int32 GetFragmentIndexChecked(const UScriptStruct* FragmentType) const { return FragmentIndexMap.FindChecked(FragmentType); }
404
406 {
407 return FragmentConfigs[FragmentIndex].GetFragmentData(RawEntityInChunkHandle.ChunkRawMemory, RawEntityInChunkHandle.IndexWithinChunk);
408 }
409
411 {
412 return Handle.IsSet() && Chunks.IsValidIndex(Handle.ChunkIndex) && Chunks[Handle.ChunkIndex].GetSerialModificationNumber() == Handle.ChunkSerialNumber;
413 }
414
416 {
417 checkf(IsValidHandle(EntityInChunkHandle), TEXT("Input FMassRawEntityInChunkData is out of date."));
418 return FragmentConfigs[FragmentIndex].GetFragmentData(EntityInChunkHandle.ChunkRawMemory, EntityInChunkHandle.IndexWithinChunk);
419 }
420
422 {
423 const int32 AbsoluteIndex = EntityMap.FindChecked(EntityIndex);
424 const int32 ChunkIndex = AbsoluteIndex / NumEntitiesPerChunk;
425
426 return FMassRawEntityInChunkData(Chunks[ChunkIndex].GetRawMemory(), AbsoluteIndex % NumEntitiesPerChunk);
427 }
428
430 {
431 return MakeRawEntityHandle(Entity.Index);
432 }
433
435 {
436 const int32 AbsoluteIndex = EntityMap.FindChecked(EntityIndex);
437 const int32 ChunkIndex = AbsoluteIndex / NumEntitiesPerChunk;
438 const FMassArchetypeChunk& Chunk = Chunks[ChunkIndex];
439
440 return FMassEntityInChunkDataHandle(Chunk.GetRawMemory(), AbsoluteIndex % NumEntitiesPerChunk
441 , ChunkIndex, Chunk.GetSerialModificationNumber());
442 }
443
445 {
446 return MakeEntityHandle(Entity.Index);
447 }
448
449 bool IsInitialized() const { return TotalBytesPerEntity > 0 && FragmentConfigs.IsEmpty() == false; }
450
452 // batched api
465
466protected:
469
477 void ConfigureFragments(const FMassEntityManager& EntityManager);
478
479 FORCEINLINE void* GetFragmentData(const int32 FragmentIndex, uint8* ChunkRawMemory, const int32 IndexWithinChunk) const
480 {
481 return FragmentConfigs[FragmentIndex].GetFragmentData(ChunkRawMemory, IndexWithinChunk);
482 }
483
488
497
499
500private:
502 void RemoveEntityInternal(const int32 AbsoluteIndex);
503};
504
505
507{
508 FORCEINLINE static FMassArchetypeData* ArchetypeDataFromHandle(const FMassArchetypeHandle& ArchetypeHandle) { return ArchetypeHandle.DataPtr.Get(); }
510 {
511 check(ArchetypeHandle.IsValid());
512 return *ArchetypeHandle.DataPtr.Get();
513 }
518
525#if WITH_MASSENTITY_DEBUG
526 MASSENTITY_API static bool DoesArchetypeMatchRequirements(const FMassArchetypeData& Archetype, const FMassFragmentRequirements& Requirements
527 , const bool bBailOutOnFirstFail = true, FOutputDevice* OutputDevice = nullptr);
528#endif // WITH_MASSENTITY_DEBUG
529
530 MASSENTITY_API static bool DoesArchetypeMatchRequirements(const FMassArchetypeData& Archetype, const FMassFragmentRequirements& Requirements);
532};
533
534//-----------------------------------------------------------------------------
535// INLINES
536//-----------------------------------------------------------------------------
538{
539 return Groups;
540}
541
543{
544 if (GroupHandle.IsValid())
545 {
547 return FoundGroupID.IsValid() && FoundGroupID == GroupHandle.GetGroupID();
548 }
549 return false;
550}
551
553{
554 return Groups.ContainsType(GroupType);
555}
556
558{
559 return CreatedArchetypeDataVersion;
560}
561
563{
564 return EntityOrderVersion;
565}
#define FORCEINLINE
Definition AndroidPlatform.h:140
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define check(expr)
Definition AssertionMacros.h:314
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::SIZE_T SIZE_T
An unsigned integer the same size as a pointer, the same as UPTRINT.
Definition Platform.h:1150
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define LLM_SCOPE_BYNAME(...)
Definition LowLevelMemTracker.h:1098
TFunction< bool(const FMassExecutionContext &) > FMassChunkConditionFunction
Definition MassArchetypeTypes.h:32
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition NameTypes.h:617
Definition OutputDevice.h:133
Definition ArrayView.h:139
Definition Array.h:670
ElementType * FindByPredicate(Predicate Pred)
Definition Array.h:1471
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_REWRITE bool IsEmpty() const
Definition Array.h:1133
UE_NODEBUG UE_FORCEINLINE_HINT bool IsValidIndex(SizeType Index) const
Definition Array.h:1122
UE_FORCEINLINE_HINT SizeType AddUnique(ElementType &&Item)
Definition Array.h:2993
Definition AndroidPlatformMisc.h:14
Definition UnrealString.h.inl:34
Definition SharedPointer.h:692
UE_FORCEINLINE_HINT ObjectType * Get() const
Definition SharedPointer.h:1065
Definition Class.h:1720
UE_FORCEINLINE_HINT int32 GetStructureSize() const
Definition Class.h:775
Definition MassArchetypeData.h:21
uint32 SanitizeChunkMemorySize(const uint32 InChunkMemorySize, const bool bLogMismatch=true)
Definition MassArchetypeData.cpp:23
U16 Index
Definition radfft.cpp:71
Definition Color.h:486
Definition InstancedStruct.h:32
Definition MassArchetypeData.h:27
FMassEntityHandle & GetEntityArrayElementRef(int32 ChunkBase, int32 IndexWithinChunk)
Definition MassArchetypeData.h:58
void AddMultipleInstances(uint32 Count)
Definition MassArchetypeData.h:84
void RemoveMultipleInstances(uint32 Count)
Definition MassArchetypeData.h:90
bool IsValidSubChunk(const int32 StartIndex, const int32 Length) const
Definition MassArchetypeData.h:144
FStructView GetMutableChunkFragmentViewChecked(const int32 Index)
Definition MassArchetypeData.h:120
void Recycle(TConstArrayView< FInstancedStruct > InChunkFragmentsTemplate, const FMassArchetypeSharedFragmentValues &InSharedFragmentValues)
Definition MassArchetypeData.h:130
void RemoveInstance()
Definition MassArchetypeData.h:110
~FMassArchetypeChunk()
Definition MassArchetypeData.h:47
uint8 * GetRawMemory() const
Definition MassArchetypeData.h:74
const FMassArchetypeSharedFragmentValues & GetSharedFragmentValues() const
Definition MassArchetypeData.h:154
void AddInstance()
Definition MassArchetypeData.h:105
FInstancedStruct * FindMutableChunkFragment(const UScriptStruct *Type)
Definition MassArchetypeData.h:122
FMassArchetypeSharedFragmentValues & GetMutableSharedFragmentValues()
Definition MassArchetypeData.h:153
int32 GetSerialModificationNumber() const
Definition MassArchetypeData.h:115
int32 GetNumInstances() const
Definition MassArchetypeData.h:79
const FMassEntityHandle * GetEntityArray(int32 ChunkBase) const
Definition MassArchetypeData.h:66
FMassArchetypeChunk(const SIZE_T InAllocSize, TConstArrayView< FInstancedStruct > InChunkFragmentTemplates, FMassArchetypeSharedFragmentValues InSharedFragmentValues)
Definition MassArchetypeData.h:37
Definition MassEntityTypes.h:74
const FMassFragmentBitSet & GetFragments() const
Definition MassEntityTypes.h:907
const FMassTagBitSet & GetTags() const
Definition MassEntityTypes.h:912
const FMassSharedFragmentBitSet & GetSharedFragments() const
Definition MassEntityTypes.h:922
const FMassConstSharedFragmentBitSet & GetConstSharedFragments() const
Definition MassEntityTypes.h:927
const FMassChunkFragmentBitSet & GetChunkFragments() const
Definition MassEntityTypes.h:917
Definition MassEntityTypes.h:816
Definition MassArchetypeData.h:471
uint8 * RawChunkMemory
Definition MassArchetypeData.h:472
int32 IndexWithinChunk
Definition MassArchetypeData.h:473
Definition MassArchetypeData.h:172
static FORCEINLINE int32 CalculateRangeLength(FMassArchetypeEntityCollection::FArchetypeEntityRange EntityRange, const FMassArchetypeChunk &Chunk)
Definition MassArchetypeData.h:290
void BatchDestroyEntityChunks(FMassArchetypeEntityCollection::FConstEntityRangeArrayView EntityRangeContainer, TArray< FMassEntityHandle > &OutEntitiesRemoved)
Definition MassArchetypeData.cpp:327
void BindSharedFragmentRequirements(FMassExecutionContext &RunContext, FMassArchetypeSharedFragmentValues &SharedFragmentValues, const FMassFragmentIndicesMapping &ChunkFragmentsMapping)
Definition MassArchetypeData.cpp:894
FORCEINLINE void * GetFragmentData(const int32 FragmentIndex, const FMassRawEntityInChunkData RawEntityInChunkHandle) const
Definition MassArchetypeData.h:405
SIZE_T GetAllocatedSize() const
Definition MassArchetypeData.cpp:933
void GetRequirementsChunkFragmentMapping(TConstArrayView< FMassFragmentRequirementDescription > ChunkRequirements, FMassFragmentIndicesMapping &OutFragmentIndices) const
Definition MassArchetypeData.cpp:726
void CopyDebugNamesFrom(const FMassArchetypeData &Other)
Definition MassArchetypeData.h:362
FORCEINLINE bool IsValidHandle(const FMassEntityInChunkDataHandle Handle) const
Definition MassArchetypeData.h:410
void AddEntity(FMassEntityHandle Entity, const FMassArchetypeSharedFragmentValues &InSharedFragmentValues)
Definition MassArchetypeData.cpp:181
int32 GetNonEmptyChunkCount() const
Definition MassArchetypeData.cpp:920
const FMassSharedFragmentBitSet & GetSharedFragmentBitSet() const
Definition MassArchetypeData.h:235
FORCEINLINE const int32 * GetFragmentIndex(const UScriptStruct *FragmentType) const
Definition MassArchetypeData.h:402
void RemoveEntity(FMassEntityHandle Entity)
Definition MassArchetypeData.cpp:269
void SetFragmentData(FMassArchetypeEntityCollection::FConstEntityRangeArrayView EntityRangeContainer, const FInstancedStruct &FragmentSource)
Definition MassArchetypeData.cpp:444
void SetFragmentsData(const FMassEntityHandle Entity, TArrayView< const FInstancedStruct > FragmentSources)
Definition MassArchetypeData.cpp:430
bool IsInGroup(const UE::Mass::FArchetypeGroupHandle GroupHandle) const
Definition MassArchetypeData.h:542
FORCEINLINE const int32 * GetInternalIndexForEntity(const int32 EntityIndex) const
Definition MassArchetypeData.h:278
bool IsInGroupOfType(const UE::Mass::FArchetypeGroupType GroupType) const
Definition MassArchetypeData.h:552
void ConfigureFragments(const FMassEntityManager &EntityManager)
Definition MassArchetypeData.cpp:131
FORCEINLINE void * GetFragmentData(const int32 FragmentIndex, uint8 *ChunkRawMemory, const int32 IndexWithinChunk) const
Definition MassArchetypeData.h:479
int32 GetNumEntities() const
Definition MassArchetypeData.h:283
FORCEINLINE void * GetFragmentData(const int32 FragmentIndex, const FMassEntityInChunkDataHandle EntityInChunkHandle) const
Definition MassArchetypeData.h:415
void BatchRemoveEntitiesInternal(const int32 ChunkIndex, const int32 StartIndexWithinChunk, const int32 NumberToRemove)
Definition MassArchetypeData.cpp:1366
void ExportEntityHandles(const TConstArrayView< FMassArchetypeEntityCollection::FArchetypeEntityRange > Ranges, TArray< FMassEntityHandle > &InOutHandles) const
Definition MassArchetypeData.cpp:946
int32 CalculateRangeLength(FMassArchetypeEntityCollection::FArchetypeEntityRange EntityRange) const
Definition MassArchetypeData.h:297
int32 GetChunkCount() const
Definition MassArchetypeData.h:287
void MoveEntityToAnotherArchetype(const FMassEntityHandle Entity, FMassArchetypeData &NewArchetype, const FMassArchetypeSharedFragmentValues *SharedFragmentValuesOverride=nullptr)
Definition MassArchetypeData.cpp:473
void * GetFragmentDataForEntityChecked(const UScriptStruct *FragmentType, int32 EntityIndex) const
Definition MassArchetypeData.cpp:376
FMassArchetypeEntityCollection::FArchetypeEntityRange PrepareNextEntitiesSpanInternal(TConstArrayView< FMassEntityHandle > Entities, const FMassArchetypeSharedFragmentValues &InSharedFragmentValues, const int32 StartingChunk=0)
Definition MassArchetypeData.cpp:1305
FORCEINLINE FMassRawEntityInChunkData MakeRawEntityHandle(int32 EntityIndex) const
Definition MassArchetypeData.h:421
bool IsInitialized() const
Definition MassArchetypeData.h:449
FORCEINLINE int32 GetInternalIndexForEntityChecked(const int32 EntityIndex) const
Definition MassArchetypeData.h:279
bool HasTagType(const UScriptStruct *FragmentType) const
Definition MassArchetypeData.h:258
bool HasFragmentDataForEntity(const UScriptStruct *FragmentType, int32 EntityIndex) const
Definition MassArchetypeData.cpp:371
void BindChunkFragmentRequirements(FMassExecutionContext &RunContext, const FMassFragmentIndicesMapping &ChunkFragmentsMapping, FMassArchetypeChunk &Chunk)
Definition MassArchetypeData.cpp:842
const FMassTagBitSet & GetTagBitSet() const
Definition MassArchetypeData.h:233
void MoveFragmentsToAnotherArchetypeInternal(FMassArchetypeData &TargetArchetype, FTransientChunkLocation Target, const FTransientChunkLocation Source, const int32 ElementsNum)
Definition MassArchetypeData.cpp:1410
FORCEINLINE FMassRawEntityInChunkData MakeRawEntityHandle(const FMassEntityHandle Entity) const
Definition MassArchetypeData.h:429
const FMassChunkFragmentBitSet & GetChunkFragmentBitSet() const
Definition MassArchetypeData.h:234
bool HasFragmentType(const UScriptStruct *FragmentType) const
Definition MassArchetypeData.cpp:55
void ForEachFragmentType(TFunction< void(const UScriptStruct *)> Function) const
Definition MassArchetypeData.cpp:47
void InitializeWithSimilar(const FMassEntityManager &EntityManager, const FMassArchetypeData &BaseArchetype, FMassArchetypeCompositionDescriptor &&NewComposition, const UE::Mass::FArchetypeGroups &InGroups, const uint32 ArchetypeDataVersion)
Definition MassArchetypeData.cpp:100
SIZE_T GetBytesPerEntity() const
Definition MassArchetypeData.h:281
FMassArchetypeChunk & GetOrAddChunk(const FMassArchetypeSharedFragmentValues &SharedFragmentValues, int32 &OutAbsoluteIndex, int32 &OutIndexWithinChunk)
Definition MassArchetypeData.cpp:215
FORCEINLINE FMassEntityInChunkDataHandle MakeEntityHandle(int32 EntityIndex) const
Definition MassArchetypeData.h:434
FString DebugGetDescription() const
Definition MassArchetypeData.cpp:977
const FMassFragmentBitSet & GetFragmentBitSet() const
Definition MassArchetypeData.h:232
void GetRequirementsConstSharedFragmentMapping(TConstArrayView< FMassFragmentRequirementDescription > Requirements, FMassFragmentIndicesMapping &OutFragmentIndices) const
Definition MassArchetypeData.cpp:751
int32 CompactEntities(const double TimeAllowed)
Definition MassArchetypeData.cpp:624
FORCEINLINE const FMassArchetypeSharedFragmentValues & GetSharedFragmentValues(int32 EntityIndex) const
Definition MassArchetypeData.h:239
void ExecutionFunctionForChunk(FMassExecutionContext &RunContext, const FMassExecuteFunction &Function, const FMassQueryRequirementIndicesMapping &RequirementMapping, const FMassArchetypeEntityCollection::FArchetypeEntityRange &EntityRange, const FMassChunkConditionFunction &ChunkCondition=FMassChunkConditionFunction())
Definition MassArchetypeData.cpp:598
void BindEntityRequirements(FMassExecutionContext &RunContext, const FMassFragmentIndicesMapping &EntityFragmentsMapping, FMassArchetypeChunk &Chunk, const int32 SubchunkStart, const int32 SubchunkLength)
Definition MassArchetypeData.cpp:794
void BatchSetFragmentValues(TConstArrayView< FMassArchetypeEntityCollection::FArchetypeEntityRange > EntityCollection, const FMassGenericPayloadViewSlice &Payload)
Definition MassArchetypeData.cpp:1460
void BindConstSharedFragmentRequirements(FMassExecutionContext &RunContext, const FMassArchetypeSharedFragmentValues &SharedFragmentValues, const FMassFragmentIndicesMapping &ChunkFragmentsMapping)
Definition MassArchetypeData.cpp:868
const FMassArchetypeCompositionDescriptor & GetCompositionDescriptor() const
Definition MassArchetypeData.h:238
void GetRequirementsSharedFragmentMapping(TConstArrayView< FMassFragmentRequirementDescription > Requirements, FMassFragmentIndicesMapping &OutFragmentIndices) const
Definition MassArchetypeData.cpp:772
bool IsEquivalent(const FMassArchetypeCompositionDescriptor &OtherCompositionDescriptor, const UE::Mass::FArchetypeGroups &OtherGroups) const
Definition MassArchetypeData.cpp:1488
void BatchAddEntities(TConstArrayView< FMassEntityHandle > Entities, const FMassArchetypeSharedFragmentValues &SharedFragmentValues, TArray< FMassArchetypeEntityCollection::FArchetypeEntityRange > &OutNewRanges)
Definition MassArchetypeData.cpp:1146
void SetSharedFragmentsData(const FMassEntityHandle Entity, TConstArrayView< FSharedStruct > SharedFragmentValueOverrides)
Definition MassArchetypeData.cpp:396
FORCEINLINE int32 GetFragmentIndexChecked(const UScriptStruct *FragmentType) const
Definition MassArchetypeData.h:403
void GetRequirementsFragmentMapping(TConstArrayView< FMassFragmentRequirementDescription > Requirements, FMassFragmentIndicesMapping &OutFragmentIndices) const
Definition MassArchetypeData.cpp:711
SIZE_T GetChunkAllocSize() const
Definition MassArchetypeData.h:285
uint32 GetEntityOrderVersion() const
Definition MassArchetypeData.h:562
void MoveFragmentsToNewLocationInternal(FTransientChunkLocation Target, const FTransientChunkLocation Source, const int32 NumberToMove)
Definition MassArchetypeData.cpp:1448
void SetDebugColor(const FColor InDebugColor)
Definition MassArchetypeData.cpp:1111
FORCEINLINE const FMassArchetypeSharedFragmentValues & GetSharedFragmentValues(FMassEntityHandle Entity) const
Definition MassArchetypeData.h:246
void ExecuteFunction(FMassExecutionContext &RunContext, const FMassExecuteFunction &Function, const FMassQueryRequirementIndicesMapping &RequirementMapping, FMassArchetypeEntityCollection::FConstEntityRangeArrayView EntityRangeContainer, const FMassChunkConditionFunction &ChunkCondition)
Definition MassArchetypeData.cpp:495
FORCEINLINE FMassEntityInChunkDataHandle MakeEntityHandle(const FMassEntityHandle Entity) const
Definition MassArchetypeData.h:444
void REMOVEME_GetArrayViewForFragmentInChunk(int32 ChunkIndex, const UScriptStruct *FragmentType, void *&OutChunkBase, int32 &OutNumEntities)
Definition MassArchetypeData.cpp:1134
const UE::Mass::FArchetypeGroups & GetGroups() const
Definition MassArchetypeData.h:537
void BatchMoveEntitiesToAnotherArchetype(const FMassArchetypeEntityCollection &EntityCollection, FMassArchetypeData &NewArchetype, TArray< FMassEntityHandle > &OutEntitiesBeingMoved, TArray< FMassArchetypeEntityCollection::FArchetypeEntityRange > *OutNewChunks=nullptr, const FMassArchetypeSharedFragmentValues *SharedFragmentValuesToAdd=nullptr, const FMassSharedFragmentBitSet *SharedFragmentToRemoveBitSet=nullptr, const FMassConstSharedFragmentBitSet *ConstSharedFragmentToRemoveBitSet=nullptr)
Definition MassArchetypeData.cpp:1174
int32 GetNumEntitiesPerChunk() const
Definition MassArchetypeData.h:280
void * GetFragmentDataForEntity(const UScriptStruct *FragmentType, int32 EntityIndex) const
Definition MassArchetypeData.cpp:385
TConstArrayView< FMassArchetypeFragmentConfig > GetFragmentConfigs() const
Definition MassArchetypeData.h:231
const FMassConstSharedFragmentBitSet & GetConstSharedFragmentBitSet() const
Definition MassArchetypeData.h:236
uint32 GetCreatedArchetypeDataVersion() const
Definition MassArchetypeData.h:557
Definition MassArchetypeTypes.h:93
TConstArrayView< FArchetypeEntityRange > FConstEntityRangeArrayView
Definition MassArchetypeTypes.h:161
Definition MassArchetypeData.h:159
const UScriptStruct * FragmentType
Definition MassArchetypeData.h:160
void * GetFragmentData(uint8 *ChunkBase, int32 IndexWithinChunk) const
Definition MassArchetypeData.h:163
int32 ArrayOffsetWithinChunk
Definition MassArchetypeData.h:161
Definition MassArchetypeTypes.h:39
bool IsValid() const
Definition MassArchetypeTypes.h:363
Definition MassArchetypeData.h:507
static FORCEINLINE FMassArchetypeData * ArchetypeDataFromHandle(const FMassArchetypeHandle &ArchetypeHandle)
Definition MassArchetypeData.h:508
static MASSENTITY_API bool DoesArchetypeMatchRequirements(const FMassArchetypeData &Archetype, const FMassFragmentRequirements &Requirements)
Definition MassArchetypeData.cpp:1496
static FORCEINLINE FMassArchetypeHandle ArchetypeHandleFromData(const TSharedPtr< FMassArchetypeData > &Archetype)
Definition MassArchetypeData.h:514
static FORCEINLINE FMassArchetypeData & ArchetypeDataFromHandleChecked(const FMassArchetypeHandle &ArchetypeHandle)
Definition MassArchetypeData.h:509
Definition MassEntityTypes.h:297
Definition MassDebugger.h:441
Definition MassEntityHandle.h:13
Definition MassArchetypeTypes.h:304
Definition MassEntityManager.h:96
Definition MassEntityQuery.h:51
Definition MassExecutionContext.h:29
Definition MassRequirements.h:51
Definition MassRequirements.h:160
Definition MassEntityTypes.h:658
Definition MassArchetypeTypes.h:326
Definition MassArchetypeTypes.h:285
static FORCENOINLINE CORE_API void Free(void *Original)
Definition UnrealMemory.cpp:685
Definition StructView.h:24
Definition MassArchetypeGroup.h:99
bool IsValid() const
Definition MassArchetypeGroup.h:146
FArchetypeGroupType GetGroupType() const
Definition MassArchetypeGroup.h:123
FArchetypeGroupID GetGroupID() const
Definition MassArchetypeGroup.h:128
Definition MassArchetypeGroup.h:56
bool IsValid() const
Definition MassArchetypeGroup.h:71
Definition MassArchetypeGroup.h:15
Definition MassArchetypeGroup.h:160
FArchetypeGroupID GetID(const FArchetypeGroupType GroupType) const
Definition MassArchetypeGroup.h:198
bool ContainsType(const FArchetypeGroupType GroupType) const
Definition MassArchetypeGroup.h:203
Definition MassEntityTypes.h:47