Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ArrayWithOffset.cs
Go to the documentation of this file.
3
5
6public readonly struct ArrayWithOffset
7{
8 private readonly object m_array;
9
10 private readonly int m_offset;
11
12 private readonly int m_count;
13
14 public ArrayWithOffset(object? array, int offset)
15 {
16 int num = 0;
17 if (array != null)
18 {
19 if (!(array is Array { Rank: 1 } array2) || !Marshal.IsPinnable(array2))
20 {
22 }
23 nuint num2 = array2.NativeLength * array2.GetElementSize();
24 if (num2 > 2147483632)
25 {
27 }
28 num = (int)num2;
29 }
30 if ((uint)offset > (uint)num)
31 {
33 }
34 m_array = array;
36 m_count = num - offset;
37 }
38
39 public object? GetArray()
40 {
41 return m_array;
42 }
43
44 public int GetOffset()
45 {
46 return m_offset;
47 }
48
49 public override int GetHashCode()
50 {
51 return m_count + m_offset;
52 }
53
54 public override bool Equals([NotNullWhen(true)] object? obj)
55 {
56 if (obj is ArrayWithOffset)
57 {
58 return Equals((ArrayWithOffset)obj);
59 }
60 return false;
61 }
62
64 {
65 if (obj.m_array == m_array && obj.m_offset == m_offset)
66 {
67 return obj.m_count == m_count;
68 }
69 return false;
70 }
71
73 {
74 return a.Equals(b);
75 }
76
78 {
79 return !(a == b);
80 }
81}
static bool IsPinnable(object obj)
static string ArgumentException_NotIsomorphic
Definition SR.cs:920
static string Argument_StructArrayTooLarge
Definition SR.cs:2106
static string IndexOutOfRange_ArrayWithOffset
Definition SR.cs:2108
Definition SR.cs:7
static bool operator==(ArrayWithOffset a, ArrayWithOffset b)
override bool Equals([NotNullWhen(true)] object? obj)
static bool operator!=(ArrayWithOffset a, ArrayWithOffset b)