Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SortVersion.cs
Go to the documentation of this file.
3
5
7[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
8public sealed class SortVersion : IEquatable<SortVersion?>
9{
10 private readonly int m_NlsVersion;
11
12 private Guid m_SortId;
13
15
16 public Guid SortId => m_SortId;
17
18 public SortVersion(int fullVersion, Guid sortId)
19 {
20 m_SortId = sortId;
21 m_NlsVersion = fullVersion;
22 }
23
24 internal SortVersion(int nlsVersion, int effectiveId, Guid customVersion)
25 {
26 m_NlsVersion = nlsVersion;
27 if (customVersion == Guid.Empty)
28 {
29 byte h = (byte)(effectiveId >> 24);
30 byte i = (byte)((effectiveId & 0xFF0000) >> 16);
31 byte j = (byte)((effectiveId & 0xFF00) >> 8);
32 byte k = (byte)((uint)effectiveId & 0xFFu);
33 customVersion = new Guid(0, 0, 0, 0, 0, 0, 0, h, i, j, k);
34 }
35 m_SortId = customVersion;
36 }
37
38 public override bool Equals([NotNullWhen(true)] object? obj)
39 {
40 if (obj is SortVersion other)
41 {
42 return Equals(other);
43 }
44 return false;
45 }
46
47 public bool Equals([NotNullWhen(true)] SortVersion? other)
48 {
49 if (other == null)
50 {
51 return false;
52 }
53 if (m_NlsVersion == other.m_NlsVersion)
54 {
55 return m_SortId == other.m_SortId;
56 }
57 return false;
58 }
59
60 public override int GetHashCode()
61 {
62 return (m_NlsVersion * 7) | m_SortId.GetHashCode();
63 }
64
65 [MethodImpl(MethodImplOptions.AggressiveInlining)]
66 public static bool operator ==(SortVersion? left, SortVersion? right)
67 {
68 if ((object)right == null)
69 {
70 if ((object)left != null)
71 {
72 return false;
73 }
74 return true;
75 }
76 return right.Equals(left);
77 }
78
79 public static bool operator !=(SortVersion? left, SortVersion? right)
80 {
81 return !(left == right);
82 }
83}
static bool operator!=(SortVersion? left, SortVersion? right)
bool Equals([NotNullWhen(true)] SortVersion? other)
static bool operator==(SortVersion? left, SortVersion? right)
SortVersion(int fullVersion, Guid sortId)
SortVersion(int nlsVersion, int effectiveId, Guid customVersion)
override bool Equals([NotNullWhen(true)] object? obj)
override int GetHashCode()
Definition Guid.cs:700
static readonly Guid Empty
Definition Guid.cs:86