UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MassEntityManager.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "UObject/GCObject.h"
7#include "MassEntityTypes.h"
9#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_7
10#include "MassEntityQuery.h"
11#endif
12#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_5
15#endif
16#include "MassObserverManager.h"
18#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_7
20#endif // UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_7
23#include "MassArchetypeGroup.h"
24#include "MassRelationManager.h"
25#include "MassEntityRelations.h"
26
27#if WITH_MASSENTITY_DEBUG
28#include "Misc/EnumClassFlags.h"
30#else
31struct FMassRequirementAccessDetector;
32#endif
33
34#define UE_API MASSENTITY_API
35
36struct FInstancedStruct;
37struct FMassEntityQuery;
42class FOutputDevice;
43struct FMassDebugger;
45enum class EMassFragmentAccess : uint8;
46enum class EForkProcessRole : uint8;
47namespace UE::Mass
48{
49 struct FEntityBuilder;
50 struct FTypeManager;
51 struct FTypeHandle;
52 namespace Private
53 {
54 struct FEntityStorageInitializer;
55 }
56 namespace ObserverManager
57 {
58 struct FObserverLock;
59 struct FCreationContext;
60 }
61}
62
63// use REQUESTED_MASS_CONCURRENT_RESERVE=0 in your project's Build.cs file to disable concurrent storage
64// NOTE that it will always be enabled in WITH_EDITOR since editor code requires it.
65// @see WITH_MASS_CONCURRENT_RESERVE
66#ifndef REQUESTED_MASS_CONCURRENT_RESERVE
67#define REQUESTED_MASS_CONCURRENT_RESERVE 1
68#endif
69
70#define WITH_MASS_CONCURRENT_RESERVE (REQUESTED_MASS_CONCURRENT_RESERVE || WITH_EDITOR)
71
72namespace UE::Mass
73{
74#if WITH_MASS_CONCURRENT_RESERVE
76#else
78#endif //WITH_MASS_CONCURRENT_RESERVE
79}
80
95struct FMassEntityManager : public TSharedFromThis<FMassEntityManager>, public FGCObject
96{
99
101
102private:
103 // Index 0 is reserved so we can treat that index as an invalid entity handle
104 constexpr static int32 NumReservedEntities = 1;
105
106public:
108 {
109 explicit FScopedProcessing(std::atomic<int32>& InProcessingScopeCount) : ScopedProcessingCount(InProcessingScopeCount)
110 {
111 ++ScopedProcessingCount;
112 }
114 {
115 --ScopedProcessingCount;
116 }
117 private:
118 std::atomic<int32>& ScopedProcessingCount;
119 };
120 using FStructInitializationCallback = TFunctionRef<void(void* Fragment, const UScriptStruct& FragmentType)>;
121
123
124 UE_API explicit FMassEntityManager(UObject* InOwner = nullptr);
126 UE_API virtual ~FMassEntityManager();
127
128 // FGCObject interface
129 UE_API virtual void AddReferencedObjects(FReferenceCollector& Collector) override;
130 virtual FString GetReferencerName() const override
131 {
132 return TEXT("FMassEntityManager");
133 }
134 // End of FGCObject interface
136
137 // Default to use single threaded implementation
138 UE_API void Initialize();
140 UE_API void PostInitialize();
141 UE_API void Deinitialize();
142
148
158
170
179
191
205
214 , const FMassSharedFragmentBitSet& SharedFragmentBitSet
215 , const FMassConstSharedFragmentBitSet& ConstSharedFragmentBitSet
217
225
232
234 static UE_API void ForEachArchetypeFragmentType(const FMassArchetypeHandle& ArchetypeHandle, TFunction< void(const UScriptStruct* /*FragmentType*/)> Function);
235
240 UE_API void DoEntityCompaction(const double TimeAllowed);
241
247 UE_API FMassEntityHandle CreateEntity(const FMassArchetypeHandle& ArchetypeHandle, const FMassArchetypeSharedFragmentValues& SharedFragmentValues = {});
248
255
257
274
287
313
317 UE_API void DestroyEntity(FMassEntityHandle EntityHandle);
318
323
330 UE_API void BuildEntity(FMassEntityHandle EntityHandle, const FMassArchetypeHandle& ArchetypeHandle, const FMassArchetypeSharedFragmentValues& SharedFragmentValues = {});
331
339
340 /*
341 * Releases a previously reserved entity handle that was not yet built, otherwise call DestroyEntity
342 * @param EntityHandle to release */
344
352
360
367
374
380
382
383 UE_API void AddFragmentToEntity(FMassEntityHandle EntityHandle, const UScriptStruct* FragmentType);
385
391
393 UE_API void RemoveFragmentFromEntity(FMassEntityHandle EntityHandle, const UScriptStruct* FragmentType);
395
399
405
411
412 /*
413 * Removes ElementType from the entities, treating it accordingly based on which element type it represents (i.e. Fragment or Tag).
414 * The function will assert on unhandled types.
415 */
417
418 /*
419 * Removes ElementType from the entity, treating it accordingly based on which element type it represents (i.e. Fragment or Tag).
420 * The function will assert on unhandled types.
421 */
423
426
436
443
453
460
466
471
477
484
496
506
508
516
523
528
530
535 UE_API bool IsEntityActive(FMassEntityHandle EntityHandle) const;
536
541 UE_API bool IsEntityValid(FMassEntityHandle EntityHandle) const;
542
544 UE_API bool IsEntityBuilt(FMassEntityHandle EntityHandle) const;
545
550 UE_API bool IsEntityReserved(FMassEntityHandle EntityHandle) const;
551
553 inline void CheckIfEntityIsValid(FMassEntityHandle EntityHandle) const
554 {
555 checkf(IsEntityValid(EntityHandle), TEXT("Invalid entity (ID: %d, SN:%d, %s)"), EntityHandle.Index, EntityHandle.SerialNumber,
556 (EntityHandle.Index == 0) ? TEXT("was never initialized") : TEXT("already destroyed"));
557 }
558
560 inline void CheckIfEntityIsActive(FMassEntityHandle EntityHandle) const
561 {
562 checkf(IsEntityBuilt(EntityHandle), TEXT("Entity not yet created(ID: %d, SN:%d)"), EntityHandle.Index, EntityHandle.SerialNumber);
563 }
564
568 UE_API FMassEntityHandle CreateEntityIndexHandle(const int32 EntityIndex) const;
569
570 template<typename FragmentType>
571 FragmentType& GetFragmentDataChecked(FMassEntityHandle EntityHandle) const
572 {
574 return *((FragmentType*)InternalGetFragmentDataChecked(EntityHandle, FragmentType::StaticStruct()));
575 }
576
577 template<typename FragmentType>
578 FragmentType* GetFragmentDataPtr(FMassEntityHandle EntityHandle) const
579 {
581 return (FragmentType*)InternalGetFragmentDataPtr(EntityHandle, FragmentType::StaticStruct());
582 }
583
584 FStructView GetFragmentDataStruct(FMassEntityHandle EntityHandle, const UScriptStruct* FragmentType) const
585 {
587 , TEXT("GetFragmentDataStruct called with an invalid fragment type '%s'"), *GetPathNameSafe(FragmentType));
588 return FStructView(FragmentType, static_cast<uint8*>(InternalGetFragmentDataPtr(EntityHandle, FragmentType)));
589 }
590
591 template<typename ConstSharedFragmentType>
593 {
594 static_assert(UE::Mass::CConstSharedFragment<ConstSharedFragmentType>, "Given struct doesn't represent a valid const shared fragment type. Make sure to inherit from FMassConstSharedFragment or one of its child-types.");
595 const FConstSharedStruct* ConstSharedStruct = InternalGetConstSharedFragmentPtr(EntityHandle, ConstSharedFragmentType::StaticStruct());
596 return (ConstSharedFragmentType*)(ConstSharedStruct ? ConstSharedStruct->GetMemory() : nullptr);
597 }
598
599 template<typename ConstSharedFragmentType>
606
608 {
610 , TEXT("GetConstSharedFragmentDataStruct called with an invalid fragment type '%s'"), *GetPathNameSafe(ConstSharedFragmentType));
611 const FConstSharedStruct* ConstSharedStruct = InternalGetConstSharedFragmentPtr(EntityHandle, ConstSharedFragmentType);
612 return ConstSharedStruct
613 ? FConstStructView(*ConstSharedStruct)
615 }
616
617 template<typename SharedFragmentType>
619 {
621 , "Given struct doesn't represent a valid shared fragment type. Make sure to inherit from FMassSharedFragment or one of its child-types.");
622
623 TArray<FSharedStruct>* InstancesOfType = SharedFragmentsContainer.Find(SharedFragmentType::StaticStruct());
625 }
626
627 template<typename SharedFragmentType>
629 {
631 , "Given struct doesn't represent a valid shared fragment type. Make sure to inherit from FMassSharedFragment or one of its child-types.");
632 const FSharedStruct* FragmentPtr = InternalGetSharedFragmentPtr(EntityHandle, SharedFragmentType::StaticStruct());
633 return (SharedFragmentType*)(FragmentPtr ? FragmentPtr->GetMemory() : nullptr);
634 }
635
636 template<typename SharedFragmentType>
638 {
640 check(TypePtr);
641 return *TypePtr;
642 }
643
645 {
647 , TEXT("GetSharedFragmentDataStruct called with an invalid fragment type '%s'"), *GetPathNameSafe(SharedFragmentType));
648 const FSharedStruct* FragmentPtr = InternalGetSharedFragmentPtr(EntityHandle, SharedFragmentType);
649 return FragmentPtr
652 }
653
654 template<typename T>
656 {
657 if constexpr (std::is_same_v<T, FMassFragment>)
658 {
659 return GetFragmentDataStruct(EntityHandle, FragmentType);
660 }
661 else if constexpr (std::is_same_v<T, FMassSharedFragment>)
662 {
663 return GetSharedFragmentDataStruct(EntityHandle, FragmentType);
664 }
665 else if constexpr (std::is_same_v<T, FMassConstSharedFragment>)
666 {
667 return GetConstSharedFragmentDataStruct(EntityHandle, FragmentType);
668 }
669 else
670 {
671 static_assert(UE::Mass::TAlwaysFalse<T>, "Unsupported element type passed to GetElementDataStruct");
672 return {};
673 }
674 }
675
676 uint32 GetArchetypeDataVersion() const { return ArchetypeDataVersion; }
677
681 UE_API FMassExecutionContext CreateExecutionContext(const float DeltaSeconds);
682
683 FScopedProcessing NewProcessingScope() { return FScopedProcessing(ProcessingScopeCount); }
684
690 bool IsProcessing() const { return ProcessingScopeCount > 0; }
691
692 FMassCommandBuffer& Defer() const { return *DeferredCommandBuffers[OpenedCommandBufferIndex].Get(); }
699
700 UE_API void FlushCommands();
701
708
709 template<typename T>
710 UE_DEPRECATED(5.5, "This method will no longer be exposed. Use GetOrCreateConstSharedFragment instead.")
712 {
713 static_assert(UE::Mass::CConstSharedFragment<T>, "Given struct doesn't represent a valid const shared fragment type. Make sure to inherit from FMassConstSharedFragment or one of its child-types.");
714 return ConstSharedFragmentsContainer.FindOrAdd(Hash, T::StaticStruct(), reinterpret_cast<const uint8*>(&Fragment));
715 }
716
717private:
718 template<typename T>
719 const FSharedStruct& GetOrCreateSharedFragmentByHash(const uint32 Hash, const T& Fragment)
720 {
721 static_assert(UE::Mass::CSharedFragment<T>, "Given struct doesn't represent a valid shared fragment type. Make sure to inherit from FMassSharedFragment or one of its child-types.");
722 return SharedFragmentsContainer.FindOrAdd(Hash, T::StaticStruct(), reinterpret_cast<const uint8*>(&Fragment));
723 }
724
726 {
727 return ConstSharedFragmentsContainer.FindOrAdd(Hash, InScriptStruct, InStructMemory);
728 }
729
730 const FSharedStruct& GetOrCreateSharedFragmentByHash(const uint32 Hash, const UScriptStruct* InScriptStruct, const uint8* InStructMemory)
731 {
732 return SharedFragmentsContainer.FindOrAdd(Hash, InScriptStruct, InStructMemory);
733 }
734
735 template<typename T, typename... TArgs>
737 {
738 static_assert(UE::Mass::CConstSharedFragment<T>, "Given struct doesn't represent a valid const shared fragment type. Make sure to inherit from FMassConstSharedFragment or one of its child-types.");
739 return ConstSharedFragmentsContainer.FindOrAdd<T>(Hash, Forward<TArgs>(InArgs)...);
740 }
741
742public:
743
744#if WITH_EDITOR || WITH_MASSENTITY_DEBUG
745 template<typename CallableT>
746 void ForEachArchetype(int32 BeginRange, int32 EndRange, const CallableT& Callable) const
747 {
748 if (EndRange > AllArchetypes.Num())
749 {
750 EndRange = AllArchetypes.Num();
751 }
752 for (int32 Cursor = BeginRange; Cursor < EndRange; ++Cursor)
753 {
754 FMassArchetypeHandle Handle(AllArchetypes[Cursor]);
755 Callable(*this, Handle);
756 }
757 }
758#endif
759
760 //-----------------------------------------------------------------------------
761 // Shared fragments
762 //-----------------------------------------------------------------------------
763 template<typename T, typename... TArgs>
764 UE_DEPRECATED(5.5, "This method will no longer be exposed. Use GetOrCreateSharedFragment instead.")
765 const FSharedStruct& GetOrCreateSharedFragmentByHash(const uint32 Hash, TArgs&&... InArgs)
766 {
767 static_assert(UE::Mass::CSharedFragment<T>, "Given struct doesn't represent a valid shared fragment type. Make sure to inherit from FMassSharedFragment or one of its child-types.");
768 return SharedFragmentsContainer.FindOrAdd<T>(Hash, Forward<TArgs>(InArgs)...);
769 }
770
793 template<typename T>
795 {
797 "Given struct doesn't represent a valid const shared fragment type. Make sure to inherit from FMassConstSharedFragment or one of its child-types.");
802 }
803
826 template<typename T>
827 const FSharedStruct& GetOrCreateSharedFragment(const T& Fragment)
828 {
829 static_assert(UE::Mass::CSharedFragment<T>,
830 "Given struct doesn't represent a valid shared fragment type. Make sure to inherit from FMassSharedFragment or one of its child-types.");
832 return GetOrCreateSharedFragmentByHash(Hash, Fragment);
833 }
834
857 template<typename T, typename... TArgs>
859 {
861 "Given struct doesn't represent a valid const shared fragment type. Make sure to inherit from FMassConstSharedFragment or one of its child-types.");
862 T Struct(Forward<TArgs>(InArgs)...);
867 }
868
891 template<typename T, typename... TArgs>
893 {
894 static_assert(UE::Mass::CSharedFragment<T>,
895 "Given struct doesn't represent a valid shared fragment type. Make sure to inherit from FMassSharedFragment or one of its child-types.");
896 T Struct(Forward<TArgs>(InArgs)...);
898 return GetOrCreateSharedFragmentByHash(Hash, MoveTemp(Struct));
899 }
900
914 {
916 TEXT("Given struct doesn't represent a valid const shared fragment type. Make sure to inherit from FMassConstSharedFragment or one of its child-types."));
919 }
920
934 {
936 TEXT("Given struct doesn't represent a valid shared fragment type. Make sure to inherit from FMassSharedFragment or one of its child-types."));
938 return GetOrCreateSharedFragmentByHash(Hash, &InScriptStruct, InStructMemory);
939 }
940
976 template<typename T, typename... TArgs>
978 {
980 "Given struct doesn't represent a valid const shared fragment type. Make sure to inherit from FMassConstSharedFragment or one of its child-types.");
981 T Fragment(Forward<TArgs>(InArgs)...);
986 }
987
1023 template<typename T, typename... TArgs>
1025 {
1026 static_assert(UE::Mass::CSharedFragment<T>,
1027 "Given struct doesn't represent a valid shared fragment type. Make sure to inherit from FMassSharedFragment or one of its child-types.");
1028 T Fragment(Forward<TArgs>(InArgs)...);
1030 return GetOrCreateSharedFragmentByHash(Hash, MoveTemp(Fragment));
1031 }
1032
1033 template<UE::Mass::CSharedFragment T>
1034 void ForEachSharedFragment(TFunctionRef< void(T& /*SharedFragment*/) > ExecuteFunction);
1035
1036 template<UE::Mass::CSharedFragment T>
1037 void ForEachSharedFragmentConditional(TFunctionRef< bool(T& /*SharedFragment*/) > ConditionFunction, TFunctionRef< void(T& /*SharedFragment*/) > ExecuteFunction);
1038
1039 template<UE::Mass::CConstSharedFragment T>
1040 void ForEachConstSharedFragment(TFunctionRef< void(const T& /*ConstSharedFragment*/) > ExecuteFunction);
1041
1042 template<UE::Mass::CConstSharedFragment T>
1043 void ForEachConstSharedFragmentConditional(TFunctionRef< bool(const T& /*ConstSharedFragment*/) > ConditionFunction, TFunctionRef< void(const T& /*ConstSharedFragment*/) > ExecuteFunction);
1044
1045 //-----------------------------------------------------------------------------
1046 // Relations
1047 //-----------------------------------------------------------------------------
1049
1050 template<UE::Mass::CRelation T>
1053
1054 //-----------------------------------------------------------------------------
1055 // Type management
1056 //-----------------------------------------------------------------------------
1058
1059protected:
1061
1062public:
1063 //-----------------------------------------------------------------------------
1064 // Entity Builder
1065 //-----------------------------------------------------------------------------
1067
1068 //-----------------------------------------------------------------------------
1069 // Sub-Managers
1070 //-----------------------------------------------------------------------------
1073
1074 FMassObserverManager& GetObserverManager() { return ObserverManager; }
1075
1076 FOnNewArchetypeDelegate& GetOnNewArchetypeEvent() { return OnNewArchetypeEvent; }
1081 UWorld* GetWorld() const { return Owner.IsValid() ? Owner->GetWorld() : nullptr; }
1082 UObject* GetOwner() const { return Owner.Get(); }
1083
1084 bool IsDuringEntityCreation() const;
1085
1086 UE_API void SetDebugName(const FString& NewDebugGame);
1087#if WITH_MASSENTITY_DEBUG
1088 UE_API void DebugPrintArchetypes(FOutputDevice& Ar, const bool bIncludeEmpty = true) const;
1089 UE_API void DebugGetArchetypesStringDetails(FOutputDevice& Ar, const bool bIncludeEmpty = true) const;
1098 UE_DEPRECATED(5.7, "Using CreateEntityIndexHandle instead.")
1100 UE_API const FString& DebugGetName() const;
1101
1102 enum class EDebugFeatures
1103 {
1104 None,
1105 TraceProcessors = 1 << 0, // Used to track information about processors such as their name.
1107 };
1108
1112
1113 UE_API FMassRequirementAccessDetector& GetRequirementAccessDetector();
1114
1115 // For use by the friend MassDebugger
1117 // For use by the friend MassDebugger
1119
1120 UE_API bool DebugHasCommandsToFlush() const;
1121#endif // WITH_MASSENTITY_DEBUG
1122
1123protected:
1126
1128
1137
1140
1141private:
1142 void InternalBuildEntity(FMassEntityHandle EntityHandle, const FMassArchetypeHandle& ArchetypeHandle, const FMassArchetypeSharedFragmentValues& SharedFragmentValues);
1143 void InternalReleaseEntity(FMassEntityHandle EntityHandle);
1144
1149 FMassFragmentBitSet InternalAddFragmentListToEntityChecked(FMassEntityHandle EntityHandle, const FMassFragmentBitSet& InFragments);
1150
1155 void InternalAddFragmentListToEntity(FMassEntityHandle EntityHandle, const FMassFragmentBitSet& InFragments);
1157 UE_API void* InternalGetFragmentDataChecked(FMassEntityHandle EntityHandle, const UScriptStruct* FragmentType) const;
1159 UE_API void* InternalGetFragmentDataPtr(FMassEntityHandle EntityHandle, const UScriptStruct* FragmentType) const;
1161 UE_API const FConstSharedStruct* InternalGetConstSharedFragmentPtr(FMassEntityHandle EntityHandle, const UScriptStruct* ConstSharedFragmentType) const;
1163 UE_API const FSharedStruct* InternalGetSharedFragmentPtr(FMassEntityHandle EntityHandle, const UScriptStruct* SharedFragmentType) const;
1164
1165 TSharedRef<FEntityCreationContext> InternalBatchCreateReservedEntities(const FMassArchetypeHandle& ArchetypeHandle,
1167
1168 UE::Mass::FStorageType& GetEntityStorageInterface() const
1169 {
1170#if WITH_MASS_CONCURRENT_RESERVE
1171 using namespace UE::Mass;
1172 struct StorageSelector
1173 {
1175 {
1176 checkf(false, TEXT("Attempt to use EntityStorageInterface without initialization"));
1177 return nullptr;
1178 }
1180 {
1181 return &Storage;
1182 }
1184 {
1185 return &Storage;
1186 }
1187 };
1188
1190
1191 return *Interface;
1192#else
1193 return EntityStorage.Get<UE::Mass::FSingleThreadedEntityStorage>();
1194#endif
1195 }
1196
1197 bool DebugDoCollectionsOverlapCreationContext(TConstArrayView<FMassArchetypeEntityCollection> EntityCollections) const;
1198
1199private:
1200
1206 mutable FEntityStorageContainerType EntityStorage;
1207#if WITH_MASSENTITY_DEBUG
1209#endif // WITH_MASSENTITY_DEBUG
1210
1211 std::atomic<int32> ProcessingScopeCount = 0;
1212
1213 // the "version" number increased every time an archetype gets added
1214 uint32 ArchetypeDataVersion = 0;
1215
1216 // Map of hash of sorted fragment list to archetypes with that hash
1217 TMap<uint32, TArray<TSharedPtr<FMassArchetypeData>>> FragmentHashToArchetypeMap;
1218
1219 // Map to list of archetypes that contain the specified fragment type
1221
1222 // Contains all archetypes ever created. The array always growing and a given archetypes remains at a given index
1223 // throughout its lifetime, and the index is never reused for another archetype.
1225
1230 template<typename TSharedStructType>
1231 struct TSharedFragmentsContainer
1232 {
1234 {
1235 return TypeToInstanceMap.Find(Type);
1236 }
1237
1238 TSharedStructType& FindOrAdd(const uint32 Hash, const UScriptStruct* Type, const uint8* Data)
1239 {
1240 for (TMultiMap<uint32, int32>::TConstKeyIterator It = HashToInstanceIndexMap.CreateConstKeyIterator(Hash); It; ++It)
1241 {
1242 TSharedStructType& Instance = Instances[It.Value()];
1243
1244 if (Instance.GetScriptStruct() == Type
1245 && Type->CompareScriptStruct(Instance.GetMemory(), Data, PPF_None))
1246 {
1247 return Instance;
1248 }
1249 }
1250
1251 int32 Index = Add(TSharedStructType::Make(Type, Data));
1252 HashToInstanceIndexMap.Add(Hash, Index);
1253 return Instances[Index];
1254 }
1255
1256 template<typename T, typename... TArgs>
1257 TSharedStructType& FindOrAdd(const uint32 Hash, TArgs&&... InArgs)
1258 {
1259 // Need to actually construct the struct to make proper comparison to possible existing instance
1261
1262 for (TMultiMap<uint32, int32>::TConstKeyIterator It = HashToInstanceIndexMap.CreateConstKeyIterator(Hash); It; ++It)
1263 {
1264 TSharedStructType& Instance = Instances[It.Value()];
1265
1266 if (Instance.GetScriptStruct() == T::StaticStruct()
1267 && T::StaticStruct()->CompareScriptStruct(Instance.GetMemory(), TempInstance.GetMemory(), PPF_None))
1268 {
1269 return Instance;
1270 }
1271 }
1272
1274 HashToInstanceIndexMap.Add(Hash, Index);
1275 return Instances[Index];
1276 }
1277
1278 TSharedStructType& operator[](const int32 Index)
1279 {
1280 return Instances[Index];
1281 }
1282
1283 TArrayView<TSharedStructType> GetAllInstances()
1284 {
1285 return Instances;
1286 }
1287
1288 private:
1289 int32 Add(TSharedStructType&& SharedStruct)
1290 {
1291 TArray<TSharedStructType>& InstancesOfType = TypeToInstanceMap.FindOrAdd(SharedStruct.GetScriptStruct(), {});
1292 const int32 Index = Instances.Add(Forward<TSharedStructType>(SharedStruct));
1293 // note that even though we're copying the input F[Const]SharedStruct instance it's perfectly fine since
1294 // F[Const]SharedStruct does guarantee there's not going to be data duplication (via a member shared pointer to hosted data)
1295 InstancesOfType.Add(Instances[Index]);
1296 return Index;
1297 }
1298
1299 TArray<TSharedStructType> Instances;
1300 // Hash/Index in array pair
1301 TMultiMap<uint32, int32> HashToInstanceIndexMap;
1302 // Maps specific struct type to a collection of FSharedStruct instances of that type
1304 };
1305
1306 TSharedFragmentsContainer<FConstSharedStruct> ConstSharedFragmentsContainer;
1307 TSharedFragmentsContainer<FSharedStruct> SharedFragmentsContainer;
1308
1309 FMassObserverManager ObserverManager;
1310
1312 UE::Mass::FRelationManager RelationManager;
1313
1314 TMap<const FName, const int32> GroupNameToTypeIndex;
1315 // @todo we'll probably have some "GroupTypeInformation" here in the future
1316 TArray<const FName> GroupTypes;
1317
1318#if WITH_MASSENTITY_DEBUG
1319 FMassRequirementAccessDetector RequirementAccessDetector;
1320 FString DebugName;
1321 EDebugFeatures EnabledDebugFeatures = EDebugFeatures::All;
1322#endif // WITH_MASSENTITY_DEBUG
1323
1325
1326 FOnNewArchetypeDelegate OnNewArchetypeEvent;
1327
1328 FDelegateHandle OnPostForkHandle;
1329
1337 static constexpr int32 NumCommandBuffers = 2;
1338 TStaticArray<TSharedPtr<FMassCommandBuffer>, NumCommandBuffers> DeferredCommandBuffers;
1339 uint8 OpenedCommandBufferIndex = 0;
1340 std::atomic<bool> bCommandBufferFlushingInProgress = false;
1341 bool bFirstCommandFlush = true;
1342
1343 enum class EInitializationState : uint8
1344 {
1347 Deinitialized
1348 };
1349
1350 EInitializationState InitializationState = EInitializationState::Uninitialized;
1351
1352 //-----------------------------------------------------------------------------
1353 // DEPRECATED
1354 //-----------------------------------------------------------------------------
1355protected:
1356 UE_DEPRECATED(5.6, "This flavor of InternalCreateSimilarArchetype is deprecated due to the introduction of archetype grouping. Use InternalCreateSimilarArchetype with a FArchetypeGroups parameter instead")
1358public:
1359 UE_DEPRECATED(5.6, "SetEntityFragmentsValues is deprecated. Use SetEntityFragmentValues instead (note the slight change in name).")
1361
1362 UE_DEPRECATED(5.6, "Static BatchSetEntityFragmentsValues is deprecated. Use EntityManager's member function BatchSetEntityFragmentValues (note the slight change in name).")
1364
1365 UE_DEPRECATED(5.6, "Static BatchSetEntityFragmentsValues is deprecated. Use EntityManager's member function BatchSetEntityFragmentValues (note the slight change in name).")
1367
1368 template<UE::Mass::CConstSharedFragment T>
1369 UE_DEPRECATED(5.6, "Using ForEachSharedFragment for Const Shared Fragments has been deprecated. Use ForEachConstSharedFragment instead.")
1370 void ForEachSharedFragment(TFunctionRef< void(T& /*SharedFragment*/) > ExecuteFunction)
1371 {
1372 }
1373
1374 template<UE::Mass::CConstSharedFragment T>
1375 UE_DEPRECATED(5.6, "Using ForEachSharedFragmentConditional for Const Shared Fragments has been deprecated. Use ForEachConstSharedFragmentConditional instead.")
1376 void ForEachSharedFragmentConditional(TFunctionRef< bool(T& /*SharedFragment*/) > ConditionFunction, TFunctionRef< void(T& /*SharedFragment*/) > ExecuteFunction)
1377 {
1378 }
1379};
1380
1381//-----------------------------------------------------------------------------
1382// INLINE
1383//-----------------------------------------------------------------------------
1384
1385#if WITH_MASSENTITY_DEBUG
1386ENUM_CLASS_FLAGS(FMassEntityManager::EDebugFeatures);
1387#endif
1388
1389template<UE::Mass::CSharedFragment T>
1390void FMassEntityManager::ForEachSharedFragment(TFunctionRef< void(T& /*SharedFragment*/) > ExecuteFunction)
1391{
1392 if (TArray<FSharedStruct>* InstancesOfType = SharedFragmentsContainer.Find(T::StaticStruct()))
1393 {
1394 for (const FSharedStruct& SharedStruct : *InstancesOfType)
1395 {
1396 ExecuteFunction(SharedStruct.Get<T>());
1397 }
1398 }
1399}
1400
1401template<UE::Mass::CSharedFragment T>
1402void FMassEntityManager::ForEachSharedFragmentConditional(TFunctionRef< bool(T& /*SharedFragment*/) > ConditionFunction, TFunctionRef< void(T& /*SharedFragment*/) > ExecuteFunction)
1403{
1404 if (TArray<FSharedStruct>* InstancesOfType = SharedFragmentsContainer.Find(T::StaticStruct()))
1405 {
1406 for (const FSharedStruct& SharedStruct : *InstancesOfType)
1407 {
1408 T& StructInstanceRef = SharedStruct.Get<T>();
1410 {
1411 ExecuteFunction(StructInstanceRef);
1412 }
1413 }
1414 }
1415}
1416
1417template<UE::Mass::CConstSharedFragment T>
1418void FMassEntityManager::ForEachConstSharedFragment(TFunctionRef< void(const T& /*ConstSharedFragment*/) > ExecuteFunction)
1419{
1420 if (TArray<FConstSharedStruct>* InstancesOfType = ConstSharedFragmentsContainer.Find(T::StaticStruct()))
1421 {
1422 for (const FConstSharedStruct& SharedStruct : *InstancesOfType)
1423 {
1424 ExecuteFunction(SharedStruct.Get<const T>());
1425 }
1426 }
1427}
1428
1429template<UE::Mass::CConstSharedFragment T>
1430void FMassEntityManager::ForEachConstSharedFragmentConditional(TFunctionRef< bool(const T& /*ConstSharedFragment*/) > ConditionFunction, TFunctionRef< void(const T& /*ConstSharedFragment*/) > ExecuteFunction)
1431{
1432 if (TArray<FConstSharedStruct>* InstancesOfType = ConstSharedFragmentsContainer.Find(T::StaticStruct()))
1433 {
1434 for (const FConstSharedStruct& SharedStruct : *InstancesOfType)
1435 {
1436 const T& StructInstanceRef = SharedStruct.Get<const T>();
1438 {
1439 ExecuteFunction(StructInstanceRef);
1440 }
1441 }
1442 }
1443}
1444
1446{
1447 return *TypeManager;
1448}
1449
1451{
1452 return *TypeManager;
1453}
1454
1456{
1457 return ObserverManager.GetCreationContext().IsValid();
1458}
1459
1464
1466{
1467 return RelationManager;
1468}
1469
1470template<UE::Mass::CRelation T>
1475
1476#undef UE_API
OODEFFUNC typedef const int const char * function
Definition oodle2.h:710
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define check(expr)
Definition AssertionMacros.h:314
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FString GetPathNameSafe(const FField *InField, const UObject *StopOuter)
Definition Field.cpp:1150
#define TEXT(x)
Definition Platform.h:1272
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 ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
EForkProcessRole
Definition Fork.h:22
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
@ Composition
Definition HairStrandsComposition.cpp:43
#define MASS_INVALID_FRAGMENT_MSG
Definition MassEntityElementTypes.h:16
#define UE_API
Definition MassEntityManager.h:34
EMassFragmentAccess
Definition MassRequirements.h:18
T TNotNull
Definition NotNull.h:307
@ PPF_None
Definition PropertyPortFlags.h:15
decltype(auto) Visit(Func &&Callable, Variants &&... Args)
Definition TVariant.h:271
TConstArrayView< const UScriptStruct * > TConstArrayView< const UScriptStruct * >
Definition TypedElementQueryCapabilities.inl:16
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
UEBinkAudioDecodeInterface * Interface
Definition binka_ue_decode_test.cpp:24
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition IDelegateInstance.h:14
Definition GCObject.h:128
Definition NameTypes.h:617
Definition UnrealType.h:3087
Definition OutputDevice.h:133
Definition UObjectGlobals.h:2492
Definition ArrayView.h:139
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
UE_NODEBUG UE_FORCEINLINE_HINT bool Find(const ElementType &Item, SizeType &Index) const
Definition Array.h:1302
Definition AssetRegistryState.h:50
Definition AndroidPlatformMisc.h:14
Definition UnrealString.h.inl:34
Definition SharedPointer.h:1640
Definition SharedPointer.h:692
Definition SharedPointer.h:153
Definition StaticArray.h:26
Definition TVariant.h:48
U & Get() UE_LIFETIMEBOUND
Definition TVariant.h:146
Definition MassEntityManagerStorage.h:198
Definition MassEntityManagerStorage.h:138
Definition MassEntityManagerStorage.h:53
Definition Object.h:95
Definition Class.h:1720
Definition World.h:918
Definition MassEntityConcepts.h:32
Definition MassEntityConcepts.h:16
Definition MassEntityConcepts.h:29
@ Uninitialized
Definition AnimationAsset.h:50
Definition OverriddenPropertySet.cpp:45
Definition MassArchetypeData.h:21
bool IsA< FMassSharedFragment >(const UStruct *Struct)
Definition MassEntityElementTypes.h:73
bool IsA< FMassFragment >(const UStruct *Struct)
Definition MassEntityElementTypes.h:55
bool IsA< FMassConstSharedFragment >(const UStruct *Struct)
Definition MassEntityElementTypes.h:79
uint32 GetStructInstanceCrc32(const UScriptStruct &ScriptStruct, const uint8 *StructMemory, const uint32 CRC)
Definition StructUtilsTypes.cpp:58
Definition AdvancedWidgetsModule.cpp:13
U16 Index
Definition radfft.cpp:71
Definition SharedStruct.h:538
const uint8 * GetMemory() const
Definition SharedStruct.h:584
Definition StructView.h:217
static FConstStructView Make(const T &Struct)
Definition StructView.h:246
Definition TVariant.h:29
Definition InstancedStruct.h:32
Definition MassEntityTypes.h:74
Definition MassEntityTypes.h:816
Definition MassArchetypeData.h:172
Definition MassArchetypeTypes.h:233
Definition MassArchetypeTypes.h:93
Definition MassArchetypeTypes.h:39
Definition MassEntityTypes.h:297
Definition MassCommandBuffer.h:99
Definition MassDebugger.h:441
Definition MassEntityHandle.h:13
int32 SerialNumber
Definition MassEntityHandle.h:26
int32 Index
Definition MassEntityHandle.h:23
Definition MassEntityManager.h:108
~FScopedProcessing()
Definition MassEntityManager.h:113
FScopedProcessing(std::atomic< int32 > &InProcessingScopeCount)
Definition MassEntityManager.h:109
Definition MassEntityManager.h:96
UE_API bool RemoveSharedFragmentFromEntity(const FMassEntityHandle EntityHandle, const UScriptStruct &SharedFragmentType)
Definition MassEntityManager.cpp:1560
FragmentType * GetFragmentDataPtr(FMassEntityHandle EntityHandle) const
Definition MassEntityManager.h:578
friend FMassEntityQuery
Definition MassEntityManager.h:97
UE_API FMassArchetypeHandle GetArchetypeForEntityUnsafe(FMassEntityHandle EntityHandle) const
Definition MassEntityManager.cpp:539
UE_API void BatchAddSharedFragmentsForEntities(TConstArrayView< FMassArchetypeEntityCollection > EntityCollections, const FMassArchetypeSharedFragmentValues &AddedFragmentValues)
Definition MassEntityManager.cpp:1789
UE_API void SetDebugName(const FString &NewDebugGame)
Definition MassEntityManager.cpp:2132
bool DoesEntityHaveElement(FMassEntityHandle Entity, TNotNull< const UScriptStruct * > ElementType) const
Definition MassEntityManager.cpp:1340
UWorld * GetWorld() const
Definition MassEntityManager.h:1081
void CheckIfEntityIsActive(FMassEntityHandle EntityHandle) const
Definition MassEntityManager.h:560
ConstSharedFragmentType & GetConstSharedFragmentDataChecked(FMassEntityHandle EntityHandle) const
Definition MassEntityManager.h:600
UE_API void BuildEntity(FMassEntityHandle EntityHandle, const FMassArchetypeHandle &ArchetypeHandle, const FMassArchetypeSharedFragmentValues &SharedFragmentValues={})
Definition MassEntityManager.cpp:635
virtual UE_API void AddReferencedObjects(FReferenceCollector &Collector) override
Definition MassEntityManager.cpp:103
bool IsProcessing() const
Definition MassEntityManager.h:690
UE_API TSharedRef< FEntityCreationContext > GetOrMakeCreationContext()
Definition MassEntityManager.cpp:2081
UE_API const UE::Mass::FArchetypeGroups & GetGroupsForArchetype(const FMassArchetypeHandle &ArchetypeHandle) const
Definition MassEntityManager.cpp:1003
UE_API void AddFragmentListToEntity(FMassEntityHandle EntityHandle, TConstArrayView< const UScriptStruct * > FragmentList)
Definition MassEntityManager.cpp:1044
UE_API void SetEntityFragmentValues(FMassEntityHandle EntityHandle, TArrayView< const FInstancedStruct > FragmentInstanceList)
Definition MassEntityManager.cpp:1850
UE_API UE::Mass::FArchetypeGroupType FindOrAddArchetypeGroupType(const FName GroupName)
Definition MassEntityManager.cpp:989
const FSharedStruct & GetOrCreateSharedFragment(const UScriptStruct &InScriptStruct, const uint8 *InStructMemory)
Definition MassEntityManager.h:933
UE_API void AddCompositionToEntity_GetDelta(FMassEntityHandle EntityHandle, FMassArchetypeCompositionDescriptor &InOutDescriptor, const FMassArchetypeSharedFragmentValues *AddedSharedFragmentValues=nullptr)
Definition MassEntityManager.cpp:1055
UE_API void BatchChangeFragmentCompositionForEntities(TConstArrayView< FMassArchetypeEntityCollection > EntityCollections, const FMassFragmentBitSet &FragmentsToAdd, const FMassFragmentBitSet &FragmentsToRemove)
Definition MassEntityManager.cpp:1653
bool BatchCreateRelations(TArrayView< FMassEntityHandle > Subjects, TArrayView< FMassEntityHandle > Objects)
Definition MassEntityManager.h:1471
UE_API void GetResourceSizeEx(FResourceSizeEx &CumulativeResourceSize)
Definition MassEntityManager.cpp:81
uint32 GetArchetypeDataVersion() const
Definition MassEntityManager.h:676
void ForEachSharedFragmentConditional(TFunctionRef< bool(T &) > ConditionFunction, TFunctionRef< void(T &) > ExecuteFunction)
Definition MassEntityManager.h:1402
UE_API bool AddSharedFragmentToEntity(const FMassEntityHandle EntityHandle, const FSharedStruct &InSharedFragment)
Definition MassEntityManager.cpp:1510
const FConstSharedStruct & GetOrCreateConstSharedFragmentByHash(const uint32 Hash, const T &Fragment)
Definition MassEntityManager.h:711
FOnNewArchetypeDelegate & GetOnNewArchetypeEvent()
Definition MassEntityManager.h:1076
UE_API bool RemoveConstSharedFragmentFromEntity(const FMassEntityHandle EntityHandle, const UScriptStruct &ConstSharedFragmentType)
Definition MassEntityManager.cpp:1467
TConstArrayView< FSharedStruct > GetSharedFragmentsOfType()
Definition MassEntityManager.h:618
UE_API FMassExecutionContext CreateExecutionContext(const float DeltaSeconds)
Definition MassEntityManager.cpp:1993
ConstSharedFragmentType * GetConstSharedFragmentDataPtr(FMassEntityHandle EntityHandle) const
Definition MassEntityManager.h:592
UE_API void SetEntityFragmentsValues(FMassEntityHandle EntityHandle, TArrayView< const FInstancedStruct > FragmentInstanceList)
Definition MassEntityManager.cpp:2312
UE_API FMassArchetypeHandle GetOrCreateSuitableArchetype(const FMassArchetypeHandle &ArchetypeHandle, const FMassSharedFragmentBitSet &SharedFragmentBitSet, const FMassConstSharedFragmentBitSet &ConstSharedFragmentBitSet, const FMassArchetypeCreationParams &CreationParams=FMassArchetypeCreationParams())
Definition MassEntityManager.cpp:358
UE_API void BatchChangeTagsForEntities(TConstArrayView< FMassArchetypeEntityCollection > EntityCollections, const FMassTagBitSet &TagsToAdd, const FMassTagBitSet &TagsToRemove)
Definition MassEntityManager.cpp:1603
UE_API void Initialize()
Definition MassEntityManager.cpp:133
UE_API void FlushCommands()
Definition MassEntityManager.cpp:2030
const FConstSharedStruct & GetOrCreateConstSharedFragment(TArgs &&... InArgs)
Definition MassEntityManager.h:858
virtual UE_API ~FMassEntityManager()
Definition MassEntityManager.cpp:73
const FSharedStruct & GetOrCreateSharedFragment(const FConstStructView HashingHelperStruct, TArgs &&... InArgs)
Definition MassEntityManager.h:1024
UE_API void AddFragmentToEntity(FMassEntityHandle EntityHandle, const UScriptStruct *FragmentType)
Definition MassEntityManager.cpp:1014
UE_API void RemoveFragmentFromEntity(FMassEntityHandle EntityHandle, const UScriptStruct *FragmentType)
Definition MassEntityManager.cpp:1223
UE_API FMassArchetypeHandle CreateArchetype(TConstArrayView< const UScriptStruct * > FragmentsAndTagsList, const FMassArchetypeCreationParams &CreationParams=FMassArchetypeCreationParams())
Definition MassEntityManager.cpp:318
FMassEntityManager(const FMassEntityManager &Other)=delete
friend FMassDebugger
Definition MassEntityManager.h:98
TSharedRef< FEntityCreationContext > BatchCreateEntities(const FMassArchetypeHandle &ArchetypeHandle, const int32 Count, TArray< FMassEntityHandle > &InOutEntities)
Definition MassEntityManager.h:309
UE_API void AppendCommands(const TSharedPtr< FMassCommandBuffer > &InOutCommandBuffer)
Definition MassEntityManager.cpp:2070
void AddElementToEntities(TConstArrayView< FMassEntityHandle > Entities, TNotNull< const UScriptStruct * > ElementType)
Definition MassEntityManager.cpp:1355
FStructView GetFragmentDataStruct(FMassEntityHandle EntityHandle, const UScriptStruct *FragmentType) const
Definition MassEntityManager.h:584
FConstStructView GetSharedFragmentDataStruct(FMassEntityHandle EntityHandle, const UScriptStruct *SharedFragmentType) const
Definition MassEntityManager.h:644
void OnRelationTypeRegistered(UE::Mass::FTypeHandle RegisteredTypeHandle, const UE::Mass::FRelationTypeTraits &RelationTypeTraits)
Definition MassEntityManager.cpp:2103
UE_API void ReleaseReservedEntity(FMassEntityHandle EntityHandle)
Definition MassEntityManager.cpp:628
SharedFragmentType * GetSharedFragmentDataPtr(FMassEntityHandle EntityHandle) const
Definition MassEntityManager.h:628
FragmentType & GetFragmentDataChecked(FMassEntityHandle EntityHandle) const
Definition MassEntityManager.h:571
UE_API void BatchDestroyEntityChunks(const FMassArchetypeEntityCollection &Collection)
Definition MassEntityManager.cpp:877
UE_API TSharedRef< FEntityCreationContext > BatchBuildEntities(const FMassArchetypeEntityCollectionWithPayload &EncodedEntitiesWithPayload, const FMassFragmentBitSet &FragmentsAffected, const FMassArchetypeSharedFragmentValues &SharedFragmentValues={}, const FMassArchetypeCreationParams &CreationParams=FMassArchetypeCreationParams())
Definition MassEntityManager.cpp:688
UE_API void BatchDestroyEntities(TConstArrayView< FMassEntityHandle > InEntities)
Definition MassEntityManager.cpp:842
UE_API void PostInitialize()
Definition MassEntityManager.cpp:246
void RemoveElementFromEntities(TConstArrayView< FMassEntityHandle > Entities, TNotNull< const UScriptStruct * > ElementType)
Definition MassEntityManager.cpp:1386
UE_API void BatchGroupEntities(const UE::Mass::FArchetypeGroupHandle GroupHandle, TConstArrayView< FMassArchetypeEntityCollection > Collections)
Definition MassEntityManager.cpp:914
UE_API TConstArrayView< FMassEntityHandle > BatchReserveEntities(const int32 Count, TArray< FMassEntityHandle > &InOutEntities)
Definition MassEntityManager.cpp:674
TSharedRef< UE::Mass::ObserverManager::FObserverLock > GetOrMakeObserversLock()
Definition MassEntityManager.h:1460
TSharedRef< FEntityCreationContext > BatchCreateReservedEntities(const FMassArchetypeHandle &ArchetypeHandle, TConstArrayView< FMassEntityHandle > OutEntities)
Definition MassEntityManager.h:296
FMassCommandBuffer & Defer() const
Definition MassEntityManager.h:692
const static UE_API FMassEntityHandle InvalidEntity
Definition MassEntityManager.h:122
UE_API void InternalAppendFragmentsAndTagsToArchetypeCompositionDescriptor(FMassArchetypeCompositionDescriptor &InOutComposition, TConstArrayView< const UScriptStruct * > FragmentsAndTagsList) const
Definition MassEntityManager.cpp:505
UE_API void BatchAddFragmentInstancesForEntities(TConstArrayView< FMassArchetypeEntityCollectionWithPayload > EntityCollections, const FMassFragmentBitSet &FragmentsAffected)
Definition MassEntityManager.cpp:1711
UE_API void OnPostFork(EForkProcessRole Role)
Definition MassEntityManager.cpp:297
UE_API bool IsEntityBuilt(FMassEntityHandle EntityHandle) const
Definition MassEntityManager.cpp:1946
void AddElementToEntity(FMassEntityHandle Entity, TNotNull< const UScriptStruct * > ElementType)
Definition MassEntityManager.cpp:1372
const FSharedStruct & GetOrCreateSharedFragment(TArgs &&... InArgs)
Definition MassEntityManager.h:892
const FConstSharedStruct & GetOrCreateConstSharedFragment(const T &Fragment)
Definition MassEntityManager.h:794
const FConstSharedStruct & GetOrCreateConstSharedFragment(const UScriptStruct &InScriptStruct, const uint8 *InStructMemory)
Definition MassEntityManager.h:913
FConstStructView GetConstSharedFragmentDataStruct(FMassEntityHandle EntityHandle, const UScriptStruct *ConstSharedFragmentType) const
Definition MassEntityManager.h:607
UE_API void MoveEntityToAnotherArchetype(FMassEntityHandle EntityHandle, FMassArchetypeHandle NewArchetypeHandle, const FMassArchetypeSharedFragmentValues *SharedFragmentValuesOverride=nullptr)
Definition MassEntityManager.cpp:1827
void ForEachSharedFragment(TFunctionRef< void(T &) > ExecuteFunction)
Definition MassEntityManager.h:1390
virtual FString GetReferencerName() const override
Definition MassEntityManager.h:130
UE_API void RemoveFragmentListFromEntity(FMassEntityHandle EntityHandle, TConstArrayView< const UScriptStruct * > FragmentList)
Definition MassEntityManager.cpp:1228
UObject * GetOwner() const
Definition MassEntityManager.h:1082
UE_API void RemoveTagFromEntity(FMassEntityHandle EntityHandle, const UScriptStruct *TagType)
Definition MassEntityManager.cpp:1315
UE_API void RemoveEntityFromGroupType(FMassEntityHandle EntityHandle, UE::Mass::FArchetypeGroupType GroupType)
Definition MassEntityManager.cpp:961
UE_API FMassArchetypeHandle InternalCreateSimilarArchetype(const TSharedPtr< FMassArchetypeData > &SourceArchetype, const FMassTagBitSet &OverrideTags)
Definition MassEntityManager.cpp:429
UE_API TSharedRef< FEntityCreationContext > BatchCreateReservedEntities(const FMassArchetypeHandle &ArchetypeHandle, const FMassArchetypeSharedFragmentValues &SharedFragmentValues, TConstArrayView< FMassEntityHandle > ReservedEntities)
Definition MassEntityManager.cpp:764
void CheckIfEntityIsValid(FMassEntityHandle EntityHandle) const
Definition MassEntityManager.h:553
UE_API FMassEntityHandle CreateEntityIndexHandle(const int32 EntityIndex) const
Definition MassEntityManager.cpp:1959
UE::Mass::FRelationManager & GetRelationManager()
Definition MassEntityManager.h:1465
UE_API bool IsEntityReserved(FMassEntityHandle EntityHandle) const
Definition MassEntityManager.cpp:1953
DECLARE_MULTICAST_DELEGATE_OneParam(FOnNewArchetypeDelegate, const FMassArchetypeHandle &)
void ForEachConstSharedFragmentConditional(TFunctionRef< bool(const T &) > ConditionFunction, TFunctionRef< void(const T &) > ExecuteFunction)
Definition MassEntityManager.h:1430
static UE_API void ForEachArchetypeFragmentType(const FMassArchetypeHandle &ArchetypeHandle, TFunction< void(const UScriptStruct *)> Function)
Definition MassEntityManager.cpp:550
UE_API void DoEntityCompaction(const double TimeAllowed)
Definition MassEntityManager.cpp:556
UE_API UE::Mass::FEntityBuilder MakeEntityBuilder()
Definition MassEntityManager.cpp:2086
UE_API void SwapTagsForEntity(FMassEntityHandle EntityHandle, const UScriptStruct *FromFragmentType, const UScriptStruct *ToFragmentType)
Definition MassEntityManager.cpp:1262
bool IsDuringEntityCreation() const
Definition MassEntityManager.h:1455
const UE::Mass::FTypeManager & GetTypeManager() const
Definition MassEntityManager.h:1445
UE_API bool IsEntityActive(FMassEntityHandle EntityHandle) const
Definition MassEntityManager.cpp:1929
UE_API void AddTagToEntity(FMassEntityHandle EntityHandle, const UScriptStruct *TagType)
Definition MassEntityManager.cpp:1290
UE_API bool AddConstSharedFragmentToEntity(const FMassEntityHandle EntityHandle, const FConstSharedStruct &InConstSharedFragment)
Definition MassEntityManager.cpp:1417
TFunctionRef< void(void *Fragment, const UScriptStruct &FragmentType)> FStructInitializationCallback
Definition MassEntityManager.h:120
UE_API void BatchSetEntityFragmentValues(const FMassArchetypeEntityCollection &SparseEntities, TArrayView< const FInstancedStruct > FragmentInstanceList)
Definition MassEntityManager.cpp:1859
SharedFragmentType & GetSharedFragmentDataChecked(FMassEntityHandle EntityHandle) const
Definition MassEntityManager.h:637
UE_API void AddFragmentInstanceListToEntity(FMassEntityHandle EntityHandle, TConstArrayView< FInstancedStruct > FragmentInstanceList)
Definition MassEntityManager.cpp:1207
UE_API const FMassArchetypeCompositionDescriptor & GetArchetypeComposition(const FMassArchetypeHandle &ArchetypeHandle) const
Definition MassEntityManager.cpp:1148
FConstStructView GetElementDataStruct(FMassEntityHandle EntityHandle, TNotNull< const UScriptStruct * > FragmentType) const
Definition MassEntityManager.h:655
UE_API void Deinitialize()
Definition MassEntityManager.cpp:265
UE_API UE::Mass::FArchetypeGroupHandle GetGroupForEntity(FMassEntityHandle EntityHandle, UE::Mass::FArchetypeGroupType GroupType) const
Definition MassEntityManager.cpp:979
FMassObserverManager & GetObserverManager()
Definition MassEntityManager.h:1074
const FConstSharedStruct & GetOrCreateConstSharedFragment(const FConstStructView HashingHelperStruct, TArgs &&... InArgs)
Definition MassEntityManager.h:977
static UE_API void BatchSetEntityFragmentsValues(const FMassArchetypeEntityCollection &SparseEntities, TArrayView< const FInstancedStruct > FragmentInstanceList)
Definition MassEntityManager.cpp:2317
void ForEachConstSharedFragment(TFunctionRef< void(const T &) > ExecuteFunction)
Definition MassEntityManager.h:1418
UE_API FMassArchetypeHandle GetArchetypeForEntity(FMassEntityHandle EntityHandle) const
Definition MassEntityManager.cpp:530
UE_API void GetMatchingArchetypes(const FMassFragmentRequirements &Requirements, TArray< FMassArchetypeHandle > &OutValidArchetypes) const
Definition MassEntityManager.cpp:545
UE_API void RemoveCompositionFromEntity(FMassEntityHandle EntityHandle, const FMassArchetypeCompositionDescriptor &InDescriptor)
Definition MassEntityManager.cpp:1103
UE_API bool IsEntityValid(FMassEntityHandle EntityHandle) const
Definition MassEntityManager.cpp:1939
FScopedProcessing NewProcessingScope()
Definition MassEntityManager.h:683
const FSharedStruct & GetOrCreateSharedFragment(const T &Fragment)
Definition MassEntityManager.h:827
void RemoveElementFromEntity(FMassEntityHandle Entity, TNotNull< const UScriptStruct * > ElementType)
Definition MassEntityManager.cpp:1403
UE_API TSharedRef< FEntityCreationContext > BatchCreateEntities(const FMassArchetypeHandle &ArchetypeHandle, const FMassArchetypeSharedFragmentValues &SharedFragmentValues, const int32 Count, TArray< FMassEntityHandle > &InOutEntities)
Definition MassEntityManager.cpp:777
UE_API FMassEntityHandle ReserveEntity()
Definition MassEntityManager.cpp:621
void OnNewTypeRegistered(UE::Mass::FTypeHandle RegisteredTypeHandle)
Definition MassEntityManager.cpp:2091
Definition MassEntityQuery.h:51
Definition MassExecutionContext.h:29
Definition MassRequirements.h:160
Definition MassObserverManager.h:67
TSharedPtr< FCreationContext > GetCreationContext() const
Definition MassObserverManager.h:327
MASSENTITY_API TSharedRef< FObserverLock > GetOrMakeObserverLock()
Definition MassObserverManager.cpp:740
Definition ResourceSize.h:31
Definition SharedStruct.h:161
Definition StructView.h:24
Definition Class.h:5288
Definition WeakObjectPtrTemplates.h:25
FORCEINLINE T * Get(bool bEvenIfPendingKill) const
Definition WeakObjectPtrTemplates.h:132
FORCEINLINE bool IsValid(bool bEvenIfPendingKill, bool bThreadsafeTest=false) const
Definition WeakObjectPtrTemplates.h:232
Definition MassArchetypeGroup.h:99
Definition MassArchetypeGroup.h:15
Definition MassArchetypeGroup.h:160
Definition MassEntityBuilder.h:61
Definition MassRelationManager.h:68
Definition MassTypeManager.h:27
Definition MassTypeManager.h:141
static FTypeHandle MakeTypeHandle(TNotNull< const UStruct * > InTypeKey)
Definition MassTypeManager.h:307
Definition MassObserverNotificationTypes.h:404
Definition MassEntityManager.cpp:143
Definition MassEntityRelations.h:105