git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1315 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -30,9 +30,11 @@
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="int2.cs" />
|
||||
<Compile Include="PriorityQueue.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Tuple.cs" />
|
||||
|
||||
37
OpenRa.DataStructures/int2.cs
Normal file
37
OpenRa.DataStructures/int2.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace OpenRa
|
||||
{
|
||||
public struct int2
|
||||
{
|
||||
public int X,Y;
|
||||
|
||||
public int2( int x, int y ) { this.X = x; this.Y = y; }
|
||||
public int2( Point p ) { X = p.X; Y = p.Y; }
|
||||
public int2( Size p ) { X = p.Width; Y = p.Height; }
|
||||
|
||||
public static int2 operator +(int2 a, int2 b) { return new int2(a.X + b.X, a.Y + b.Y); }
|
||||
public static int2 operator -(int2 a, int2 b) { return new int2(a.X - b.X, a.Y - b.Y); }
|
||||
public static int2 operator *(int a, int2 b) { return new int2(a * b.X, a * b.Y); }
|
||||
public static int2 operator *(int2 b, int a) { return new int2(a * b.X, a * b.Y); }
|
||||
|
||||
public static bool operator ==(int2 me, int2 other) { return (me.X == other.X && me.Y == other.Y); }
|
||||
public static bool operator !=(int2 me, int2 other) { return !(me == other); }
|
||||
|
||||
public int2 Sign() { return new int2(Math.Sign(X), Math.Sign(Y)); }
|
||||
public int2 Abs() { return new int2( Math.Abs( X ), Math.Abs( Y ) ); }
|
||||
public override int GetHashCode() { return X.GetHashCode() ^ Y.GetHashCode(); }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
|
||||
int2 o = (int2)obj;
|
||||
return o == this;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user