-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathentEntityID.hpp
76 lines (60 loc) · 1.67 KB
/
entEntityID.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#pragma once
#include <compare>
#include <RED4ext/Common.hpp>
namespace RED4ext::ent
{
struct EntityID
{
static constexpr const char* NAME = "entEntityID";
static constexpr const char* ALIAS = "EntityID";
static constexpr uint64_t DynamicUpperBound = 0xFFFFFF;
static constexpr uint64_t PersistableLowerBound = 9000000;
static constexpr uint64_t PersistableUpperBound = 10000000;
constexpr EntityID(uint64_t aHash = 0) noexcept
: hash(aHash)
{
}
constexpr operator uint32_t() const noexcept
{
return static_cast<uint32_t>(hash);
}
constexpr operator uint64_t() const noexcept
{
return hash;
}
constexpr operator bool() const noexcept
{
return IsDefined();
}
constexpr bool operator==(const EntityID& aRhs) const noexcept
{
return hash == aRhs.hash;
}
constexpr std::strong_ordering operator<=>(const EntityID& aRhs) const noexcept
{
return hash <=> aRhs.hash;
}
[[nodiscard]] constexpr bool IsDefined() const noexcept
{
return hash;
}
[[nodiscard]] constexpr bool IsStatic() const noexcept
{
return hash && hash > DynamicUpperBound;
}
[[nodiscard]] constexpr bool IsDynamic() const noexcept
{
return hash && hash <= DynamicUpperBound;
}
[[nodiscard]] constexpr bool IsPersistable() const noexcept
{
return hash >= PersistableLowerBound && hash < PersistableUpperBound;
}
[[nodiscard]] constexpr bool IsTransient() const noexcept
{
return hash && !IsPersistable();
}
uint64_t hash; // 00
};
RED4EXT_ASSERT_SIZE(EntityID, 0x8);
} // namespace RED4ext::ent