Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
LocalConstantHandle.cs
Go to the documentation of this file.
2
4
5public readonly struct LocalConstantHandle : IEquatable<LocalConstantHandle>
6{
7 private readonly int _rowId;
8
9 public bool IsNil => RowId == 0;
10
11 internal int RowId => _rowId;
12
13 private LocalConstantHandle(int rowId)
14 {
15 _rowId = rowId;
16 }
17
18 internal static LocalConstantHandle FromRowId(int rowId)
19 {
20 return new LocalConstantHandle(rowId);
21 }
22
23 public static implicit operator Handle(LocalConstantHandle handle)
24 {
25 return new Handle(52, handle._rowId);
26 }
27
28 public static implicit operator EntityHandle(LocalConstantHandle handle)
29 {
30 return new EntityHandle((uint)(0x34000000uL | (ulong)handle._rowId));
31 }
32
33 public static explicit operator LocalConstantHandle(Handle handle)
34 {
35 if (handle.VType != 52)
36 {
38 }
39 return new LocalConstantHandle(handle.RowId);
40 }
41
42 public static explicit operator LocalConstantHandle(EntityHandle handle)
43 {
44 if (handle.VType != 872415232)
45 {
47 }
48 return new LocalConstantHandle(handle.RowId);
49 }
50
51 public static bool operator ==(LocalConstantHandle left, LocalConstantHandle right)
52 {
53 return left._rowId == right._rowId;
54 }
55
56 public override bool Equals([NotNullWhen(true)] object? obj)
57 {
58 if (obj is LocalConstantHandle localConstantHandle)
59 {
60 return localConstantHandle._rowId == _rowId;
61 }
62 return false;
63 }
64
66 {
67 return _rowId == other._rowId;
68 }
69
70 public override int GetHashCode()
71 {
72 return _rowId.GetHashCode();
73 }
74
75 public static bool operator !=(LocalConstantHandle left, LocalConstantHandle right)
76 {
77 return left._rowId != right._rowId;
78 }
79}
static void InvalidCast()
Definition Throw.cs:12
static LocalConstantHandle FromRowId(int rowId)
static bool operator!=(LocalConstantHandle left, LocalConstantHandle right)
static bool operator==(LocalConstantHandle left, LocalConstantHandle right)
override bool Equals([NotNullWhen(true)] object? obj)