Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Point.cs
Go to the documentation of this file.
1using System;
5using Microsoft.Xna.Framework.Design;
6
8
10[TypeConverter(typeof(PointConverter))]
11public struct Point : IEquatable<Point>
12{
13 [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
14 public int X;
15
16 [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
17 public int Y;
18
19 private static Point _zero = default(Point);
20
21 public static Point Zero => _zero;
22
23 public Point(int x, int y)
24 {
25 X = x;
26 Y = y;
27 }
28
29 public bool Equals(Point other)
30 {
31 if (X == other.X)
32 {
33 return Y == other.Y;
34 }
35 return false;
36 }
37
38 public override bool Equals(object obj)
39 {
40 bool result = false;
41 if (obj is Point)
42 {
43 result = Equals((Point)obj);
44 }
45 return result;
46 }
47
48 public override int GetHashCode()
49 {
50 return X.GetHashCode() + Y.GetHashCode();
51 }
52
53 public override string ToString()
54 {
55 CultureInfo currentCulture = CultureInfo.CurrentCulture;
56 return string.Format(currentCulture, "{{X:{0} Y:{1}}}", new object[2]
57 {
58 X.ToString(currentCulture),
59 Y.ToString(currentCulture)
60 });
61 }
62
63 public static bool operator ==(Point a, Point b)
64 {
65 return a.Equals(b);
66 }
67
68 public static bool operator !=(Point a, Point b)
69 {
70 if (a.X == b.X)
71 {
72 return a.Y != b.Y;
73 }
74 return true;
75 }
76}
static CultureInfo CurrentCulture
static bool operator==(Point a, Point b)
Definition Point.cs:63
bool Equals(Point other)
Definition Point.cs:29
override bool Equals(object obj)
Definition Point.cs:38
override int GetHashCode()
Definition Point.cs:48
override string ToString()
Definition Point.cs:53
static bool operator!=(Point a, Point b)
Definition Point.cs:68