-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVector2Int.cs
More file actions
68 lines (54 loc) · 1.06 KB
/
Vector2Int.cs
File metadata and controls
68 lines (54 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
namespace QuadTreeSample
{
#region
using System.Windows;
#endregion
public struct Vector2Int
{
public readonly int X;
public readonly int Y;
public Vector2Int(int x, int y)
{
this.X = x;
this.Y = y;
}
public Vector2Int(Point position) : this((int)position.X, (int)position.Y)
{
}
public static Vector2Int operator +(Vector2Int a, Vector2Int b)
{
return new Vector2Int(a.X + b.X, a.Y + b.Y);
}
public static bool operator ==(Vector2Int a, Vector2Int b)
{
return a.Equals(b);
}
public static bool operator !=(Vector2Int a, Vector2Int b)
{
return !(a == b);
}
public bool Equals(Vector2Int other)
{
return this.X == other.X && this.Y == other.Y;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
return obj is Vector2Int && this.Equals((Vector2Int)obj);
}
public override int GetHashCode()
{
unchecked
{
return (this.X * 397) ^ this.Y;
}
}
public override string ToString()
{
return $"{this.X};{this.Y}";
}
}
}