mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-13 15:52:03 +07:00
+ IsoPoint2
This commit is contained in:
76
Assets/IsoTools/Scripts/Internal/IsoPoint2.cs
Normal file
76
Assets/IsoTools/Scripts/Internal/IsoPoint2.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
namespace IsoTools.Internal {
|
||||
public struct IsoPoint2 {
|
||||
public int x;
|
||||
public int y;
|
||||
|
||||
public IsoPoint2(int x, int y) : this() {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public IsoPoint2(IsoPoint2 other) : this() {
|
||||
x = other.x;
|
||||
y = other.y;
|
||||
}
|
||||
|
||||
public void Set(int x, int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void Set(IsoPoint2 other) {
|
||||
x = other.x;
|
||||
y = other.y;
|
||||
}
|
||||
|
||||
public override bool Equals(object other) {
|
||||
return (other is IsoPoint2)
|
||||
? Equals((IsoPoint2)other)
|
||||
: false;
|
||||
}
|
||||
|
||||
public bool Equals(IsoPoint2 other) {
|
||||
return x == other.x && y == other.y;
|
||||
}
|
||||
|
||||
public override int GetHashCode() {
|
||||
return x ^ y;
|
||||
}
|
||||
|
||||
public static IsoPoint2 operator+(IsoPoint2 a, IsoPoint2 b) {
|
||||
return new IsoPoint2(a.x + b.x, a.y + b.y);
|
||||
}
|
||||
|
||||
public static IsoPoint2 operator-(IsoPoint2 a, IsoPoint2 b) {
|
||||
return new IsoPoint2(a.x - b.x, a.y - b.y);
|
||||
}
|
||||
|
||||
public static IsoPoint2 operator-(IsoPoint2 a) {
|
||||
return new IsoPoint2(-a.x, -a.y);
|
||||
}
|
||||
|
||||
public static bool operator==(IsoPoint2 lhs, IsoPoint2 rhs) {
|
||||
return lhs.x == rhs.x && lhs.y == rhs.y;
|
||||
}
|
||||
|
||||
public static bool operator!=(IsoPoint2 lhs, IsoPoint2 rhs) {
|
||||
return lhs.x != rhs.x || lhs.y != rhs.y;
|
||||
}
|
||||
|
||||
public static IsoPoint2 one {
|
||||
get { return new IsoPoint2(1, 1); }
|
||||
}
|
||||
|
||||
public static IsoPoint2 oneX {
|
||||
get { return new IsoPoint2(1, 0); }
|
||||
}
|
||||
|
||||
public static IsoPoint2 oneY {
|
||||
get { return new IsoPoint2(0, 1); }
|
||||
}
|
||||
|
||||
public static IsoPoint2 zero {
|
||||
get { return new IsoPoint2(0, 0); }
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/IsoTools/Scripts/Internal/IsoPoint2.cs.meta
Normal file
12
Assets/IsoTools/Scripts/Internal/IsoPoint2.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 534645fda9ef2415a9b5db4a91c601b5
|
||||
timeCreated: 1482561634
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user