3#include <basis/seadAssert.h>
4#include <basis/seadTypes.h>
7
8
9
10
11
24
25
32
33
34
41
42
43
44
45 UniqueID(u32 i_array_index, u32 i_create_index)
47 setValue(i_array_index, i_create_index);
51
52
53
60
61
62
63
64 void setValue(u32 i_array_index, u32 i_create_index)
66 SEAD_ASSERT(i_array_index <= cArrayIndexMax);
67 SEAD_ASSERT(i_create_index <= cCreateIndexMax);
68 mValue = i_array_index << 22 | i_create_index;
72
73
80
81
82
89
90
91
94 return mValue & cCreateIndexMax;
98
99
102 return mValue != cInvalidID;
106
107
114
115
118 return lhs.mValue == rhs.mValue;
122
123
126 return lhs.mValue != rhs.mValue;
132static_assert(
sizeof(
UniqueID) == 0x4,
"UniqueID size mismatch");
Safe identifier handle used as an alternative to raw actor pointers.
Definition UniqueID.h:13
u32 mValue
The raw 32-bit packed value containing both the array index and create index.
Definition UniqueID.h:130
UniqueID(u32 i_array_index, u32 i_create_index)
Constructs an UniqueID by packing a physical index and a global generation index.
Definition UniqueID.h:45
static const u32 cCreateIndexMax
The maximum allowed global create index (22 bits; 4,194,303)
Definition UniqueID.h:20
void setValue(u32 i_array_index, u32 i_create_index)
Overwrites the ID by packing a physical index and a global generation index.
Definition UniqueID.h:64
u32 getCreateIndex() const
Extracts the global generation counter assigned to this actor at creation.
Definition UniqueID.h:92
static const u32 cInvalidID
Represents an invalid or uninitialized ID.
Definition UniqueID.h:16
u32 getArrayIndex() const
Extracts the physical array index where this actor is stored.
Definition UniqueID.h:83
friend bool operator!=(const UniqueID &lhs, const UniqueID &rhs)
Compares two UniqueIDs for inequality.
Definition UniqueID.h:124
void setValue(u32 id)
Overwrites the ID with a raw 32-bit packed value containing both the array index and create index.
Definition UniqueID.h:54
bool isValid() const
Whether this ID has been assigned a valid value (not equal to cInvalidID).
Definition UniqueID.h:100
UniqueID(u32 id)
Constructs an UniqueID from a raw 32-bit packed value containing both the array index and create inde...
Definition UniqueID.h:35
u32 getValue() const
The raw 32-bit packed value of this ID.
Definition UniqueID.h:74
UniqueID()
Constructs an invalid UniqueID.
Definition UniqueID.h:26
static const u32 cArrayIndexMax
The maximum allowed array index (10 bits; 1023).
Definition UniqueID.h:18
void invalidate()
Clears the ID, setting it back to cInvalidID.
Definition UniqueID.h:108
friend bool operator==(const UniqueID &lhs, const UniqueID &rhs)
Compares two UniqueIDs for equality.
Definition UniqueID.h:116