UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MassArchetypeGroup.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
6#include "Containers/Map.h"
7
8
9namespace UE::Mass
10{
11 //-----------------------------------------------------------------------------
12 // FArchetypeGroupType
13 //-----------------------------------------------------------------------------
15 {
17
19 : Identifier(Value)
20 {
21 }
22
23 FArchetypeGroupType(const FArchetypeGroupType& Source) = default;
24
26 {
27 return GetTypeHash(Instance.Identifier);
28 }
29
31 {
32 return Identifier == Other.Identifier;
33 }
34
36 {
37 return Identifier < Other.Identifier;
38 }
39
40 explicit operator int32() const
41 {
42 return static_cast<int32>(Identifier);
43 }
44
45 bool IsValid() const
46 {
47 return Identifier != InvalidArchetypeGroupTypeIdentifier;
48 }
49
50 private:
51 uint32 Identifier;
52 };
53
54
56 {
57 constexpr static uint32 InvalidArchetypeGroupID = static_cast<uint32>(INDEX_NONE);
58 constexpr static uint32 FirstGroupID = 0;
59
60 FArchetypeGroupID() = default;
62 : ID(InID)
63 {
64 }
65
67 {
68 return ID == Other.ID;
69 }
70
71 bool IsValid() const
72 {
73 return ID != InvalidArchetypeGroupID;
74 }
75
76 operator int32() const
77 {
78 return static_cast<int32>(ID);
79 }
80
82 {
84 }
85
87 {
88 return FArchetypeGroupID(ID + 1);
89 }
90
91 private:
93 };
94
95 //-----------------------------------------------------------------------------
96 // FArchetypeGroupHandle
97 //-----------------------------------------------------------------------------
99 {
101 : GroupType(InGroupType), GroupID(InGroupID)
102 {
103 }
104
106
108 {
109 return GroupType == Other.GroupType && GroupID == Other.GroupID;
110 }
111
113 {
114 return !(*this == Other);
115 }
116
118 {
119 const uint64 CombinedHandle = static_cast<uint64>(static_cast<int32>(Instance.GroupType)) << 32 | Instance.GroupID;
121 }
122
124 {
125 return GroupType;
126 }
127
129 {
130 return GroupID;
131 }
132
134 {
135 return GroupType < Other.GroupType || (GroupType == Other.GroupType && GroupID < Other.GroupID);
136 }
137
139 {
140 if (ensureMsgf(Other.GroupType == GroupType, TEXT("Updating ID is only supported for group handles of the same type")))
141 {
142 new (this) FArchetypeGroupHandle(GroupType, Other.GroupID);
143 }
144 }
145
146 bool IsValid() const
147 {
148 return GroupType.IsValid() && GroupID.IsValid();
149 }
150
151 private:
152 FArchetypeGroupType GroupType;
153 FArchetypeGroupID GroupID;
154 };
155
156 //-----------------------------------------------------------------------------
157 // FArchetypeGroups
158 //-----------------------------------------------------------------------------
160 {
161 FArchetypeGroups() = default;
164
165 bool operator==(const FArchetypeGroups& OtherGroups) const;
168
172 void Add(FArchetypeGroupHandle GroupHandle);
173
180
185 void Remove(FArchetypeGroupType GroupType);
186
194
195 void Shrink();
196 bool IsShrunk() const;
197
199 {
200 return IDContainer.IsValidIndex(static_cast<int32>(GroupType)) ? IDContainer[static_cast<int32>(GroupType)] : FArchetypeGroupID();
201 }
202
203 bool ContainsType(const FArchetypeGroupType GroupType) const
204 {
205 return IDContainer.IsValidIndex(static_cast<int32>(GroupType));
206 }
207
209
210 protected:
212 };
213
214} // namespace UE::Mass
#define ensureMsgf( InExpression, InFormat,...)
Definition AssertionMacros.h:465
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition SparseArray.h:524
Definition MassArchetypeData.h:21
Definition MassArchetypeGroup.h:99
friend uint32 GetTypeHash(const FArchetypeGroupHandle &Instance)
Definition MassArchetypeGroup.h:117
FArchetypeGroupHandle(const FArchetypeGroupType InGroupType, const FArchetypeGroupID InGroupID)
Definition MassArchetypeGroup.h:100
bool IsValid() const
Definition MassArchetypeGroup.h:146
FArchetypeGroupType GetGroupType() const
Definition MassArchetypeGroup.h:123
bool operator==(const FArchetypeGroupHandle Other) const
Definition MassArchetypeGroup.h:107
bool operator!=(const FArchetypeGroupHandle Other) const
Definition MassArchetypeGroup.h:112
bool operator<(const FArchetypeGroupHandle Other) const
Definition MassArchetypeGroup.h:133
void UpdateID(const FArchetypeGroupHandle Other)
Definition MassArchetypeGroup.h:138
FArchetypeGroupID GetGroupID() const
Definition MassArchetypeGroup.h:128
Definition MassArchetypeGroup.h:56
static constexpr uint32 InvalidArchetypeGroupID
Definition MassArchetypeGroup.h:57
static constexpr uint32 FirstGroupID
Definition MassArchetypeGroup.h:58
static FArchetypeGroupID First()
Definition MassArchetypeGroup.h:81
bool IsValid() const
Definition MassArchetypeGroup.h:71
bool operator==(const FArchetypeGroupID Other) const
Definition MassArchetypeGroup.h:66
FArchetypeGroupID(const uint32 InID)
Definition MassArchetypeGroup.h:61
FArchetypeGroupID Next() const
Definition MassArchetypeGroup.h:86
Definition MassArchetypeGroup.h:15
bool operator==(const FArchetypeGroupType Other) const
Definition MassArchetypeGroup.h:30
FArchetypeGroupType(const FArchetypeGroupType &Source)=default
bool IsValid() const
Definition MassArchetypeGroup.h:45
static constexpr uint32 InvalidArchetypeGroupTypeIdentifier
Definition MassArchetypeGroup.h:16
friend uint32 GetTypeHash(const FArchetypeGroupType &Instance)
Definition MassArchetypeGroup.h:25
bool operator<(const FArchetypeGroupType Other) const
Definition MassArchetypeGroup.h:35
FArchetypeGroupType(const uint32 Value=InvalidArchetypeGroupTypeIdentifier)
Definition MassArchetypeGroup.h:18
Definition MassArchetypeGroup.h:160
TSparseArray< FArchetypeGroupID > IDContainer
Definition MassArchetypeGroup.h:211
bool operator==(const FArchetypeGroups &OtherGroups) const
Definition MassArchetypeGroup.cpp:11
friend uint32 GetTypeHash(const FArchetypeGroups &Instance)
Definition MassArchetypeGroup.cpp:103
FArchetypeGroups(FArchetypeGroups &&InGroups)=default
FArchetypeGroupID GetID(const FArchetypeGroupType GroupType) const
Definition MassArchetypeGroup.h:198
FArchetypeGroups & operator=(FArchetypeGroups &&InGroups)
Definition MassArchetypeGroup.cpp:16
bool IsShrunk() const
Definition MassArchetypeGroup.cpp:95
bool ContainsType(const FArchetypeGroupType GroupType) const
Definition MassArchetypeGroup.h:203
void Shrink()
Definition MassArchetypeGroup.cpp:90
FArchetypeGroups(const FArchetypeGroups &InGroups)=default