Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
EntityHandle.cs
Go to the documentation of this file.
2
4
5public readonly struct EntityHandle : IEquatable<EntityHandle>
6{
7 private readonly uint _vToken;
8
10
12
13 internal uint Type => _vToken & 0x7F000000u;
14
15 internal uint VType => _vToken & 0xFF000000u;
16
17 internal bool IsVirtual => (_vToken & 0x80000000u) != 0;
18
19 public bool IsNil => (_vToken & 0x80FFFFFFu) == 0;
20
21 internal int RowId => (int)(_vToken & 0xFFFFFF);
22
23 internal uint SpecificHandleValue => _vToken & 0x80FFFFFFu;
24
25 public HandleKind Kind => (HandleKind)(Type >> 24);
26
27 internal int Token => (int)_vToken;
28
29 internal EntityHandle(uint vToken)
30 {
31 _vToken = vToken;
32 }
33
34 public static implicit operator Handle(EntityHandle handle)
35 {
36 return Handle.FromVToken(handle._vToken);
37 }
38
39 public static explicit operator EntityHandle(Handle handle)
40 {
41 if (handle.IsHeapHandle)
42 {
44 }
45 return new EntityHandle(handle.EntityHandleValue);
46 }
47
48 public override bool Equals([NotNullWhen(true)] object? obj)
49 {
50 if (obj is EntityHandle other)
51 {
52 return Equals(other);
53 }
54 return false;
55 }
56
58 {
59 return _vToken == other._vToken;
60 }
61
62 public override int GetHashCode()
63 {
64 return (int)_vToken;
65 }
66
67 public static bool operator ==(EntityHandle left, EntityHandle right)
68 {
69 return left.Equals(right);
70 }
71
72 public static bool operator !=(EntityHandle left, EntityHandle right)
73 {
74 return !left.Equals(right);
75 }
76
77 internal static int Compare(EntityHandle left, EntityHandle right)
78 {
79 return left._vToken.CompareTo(right._vToken);
80 }
81}
static void InvalidCast()
Definition Throw.cs:12
static bool operator==(EntityHandle left, EntityHandle right)
static bool operator!=(EntityHandle left, EntityHandle right)
static int Compare(EntityHandle left, EntityHandle right)
override bool Equals([NotNullWhen(true)] object? obj)
static Handle FromVToken(uint vToken)
Definition Handle.cs:52