Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Point16.cs
Go to the documentation of this file.
2
4
5public struct Point16
6{
7 public readonly short X;
8
9 public readonly short Y;
10
11 public static Point16 Zero = new Point16(0, 0);
12
13 public static Point16 NegativeOne = new Point16(-1, -1);
14
15 public Point16(Point point)
16 {
17 X = (short)point.X;
18 Y = (short)point.Y;
19 }
20
21 public Point16(int X, int Y)
22 {
23 this.X = (short)X;
24 this.Y = (short)Y;
25 }
26
27 public Point16(short X, short Y)
28 {
29 this.X = X;
30 this.Y = Y;
31 }
32
33 public static Point16 Max(int firstX, int firstY, int secondX, int secondY)
34 {
35 return new Point16((firstX > secondX) ? firstX : secondX, (firstY > secondY) ? firstY : secondY);
36 }
37
38 public Point16 Max(int compareX, int compareY)
39 {
40 return new Point16((X > compareX) ? X : compareX, (Y > compareY) ? Y : compareY);
41 }
42
43 public Point16 Max(Point16 compareTo)
44 {
45 return new Point16((X > compareTo.X) ? X : compareTo.X, (Y > compareTo.Y) ? Y : compareTo.Y);
46 }
47
48 public static bool operator ==(Point16 first, Point16 second)
49 {
50 if (first.X == second.X)
51 {
52 return first.Y == second.Y;
53 }
54 return false;
55 }
56
57 public static bool operator !=(Point16 first, Point16 second)
58 {
59 if (first.X == second.X)
60 {
61 return first.Y != second.Y;
62 }
63 return true;
64 }
65
66 public override bool Equals(object obj)
67 {
68 Point16 point = (Point16)obj;
69 if (X != point.X || Y != point.Y)
70 {
71 return false;
72 }
73 return true;
74 }
75
76 public override int GetHashCode()
77 {
78 return (X << 16) | (ushort)Y;
79 }
80
81 public override string ToString()
82 {
83 return $"{{{X}, {Y}}}";
84 }
85}
static bool operator!=(Point16 first, Point16 second)
Definition Point16.cs:57
static bool operator==(Point16 first, Point16 second)
Definition Point16.cs:48
override string ToString()
Definition Point16.cs:81
Point16 Max(Point16 compareTo)
Definition Point16.cs:43
Point16(short X, short Y)
Definition Point16.cs:27
override bool Equals(object obj)
Definition Point16.cs:66
static Point16 Max(int firstX, int firstY, int secondX, int secondY)
Definition Point16.cs:33
Point16 Max(int compareX, int compareY)
Definition Point16.cs:38