Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SlotId.cs
Go to the documentation of this file.
1namespace ReLogic.Utilities;
2
3public struct SlotId
4{
5 public static readonly SlotId Invalid = new SlotId(65535u);
6
7 private const uint KEY_INC = 65536u;
8
9 private const uint INDEX_MASK = 65535u;
10
11 private const uint ACTIVE_MASK = 2147483648u;
12
13 private const uint KEY_MASK = 2147418112u;
14
15 public readonly uint Value;
16
17 public bool IsValid => (Value & 0xFFFF) != 65535;
18
19 internal bool IsActive
20 {
21 get
22 {
23 if ((Value & 0x80000000u) != 0)
24 {
25 return IsValid;
26 }
27 return false;
28 }
29 }
30
31 internal uint Index => Value & 0xFFFFu;
32
33 internal uint Key => Value & 0x7FFF0000u;
34
35 internal SlotId ToInactive(uint freeHead)
36 {
37 return new SlotId(Key | freeHead);
38 }
39
40 internal SlotId ToActive(uint index)
41 {
42 uint num = 0x7FFF0000u & (Key + 65536);
43 return new SlotId(0x80000000u | num | index);
44 }
45
46 public SlotId(uint value)
47 {
48 Value = value;
49 }
50
51 public override bool Equals(object obj)
52 {
53 if (!(obj is SlotId))
54 {
55 return false;
56 }
57 return ((SlotId)obj).Value == Value;
58 }
59
60 public override int GetHashCode()
61 {
62 return Value.GetHashCode();
63 }
64
65 public static bool operator ==(SlotId lhs, SlotId rhs)
66 {
67 return lhs.Value == rhs.Value;
68 }
69
70 public static bool operator !=(SlotId lhs, SlotId rhs)
71 {
72 return lhs.Value != rhs.Value;
73 }
74
75 public float ToFloat()
76 {
78 }
79
80 public static SlotId FromFloat(float value)
81 {
82 return new SlotId(ReinterpretCast.FloatAsUInt(value));
83 }
84}
static float UIntAsFloat(uint value)
static uint FloatAsUInt(float value)
static bool operator==(SlotId lhs, SlotId rhs)
Definition SlotId.cs:65
const uint INDEX_MASK
Definition SlotId.cs:9
static bool operator!=(SlotId lhs, SlotId rhs)
Definition SlotId.cs:70
override int GetHashCode()
Definition SlotId.cs:60
SlotId(uint value)
Definition SlotId.cs:46
static readonly SlotId Invalid
Definition SlotId.cs:5
const uint ACTIVE_MASK
Definition SlotId.cs:11
override bool Equals(object obj)
Definition SlotId.cs:51
static SlotId FromFloat(float value)
Definition SlotId.cs:80
readonly uint Value
Definition SlotId.cs:15
SlotId ToInactive(uint freeHead)
Definition SlotId.cs:35
const uint KEY_INC
Definition SlotId.cs:7
SlotId ToActive(uint index)
Definition SlotId.cs:40
const uint KEY_MASK
Definition SlotId.cs:13