diff --git a/OpenRA.Game/Actor.cs b/OpenRA.Game/Actor.cs index 4fcd7f5f5e..39be1ac013 100755 --- a/OpenRA.Game/Actor.cs +++ b/OpenRA.Game/Actor.cs @@ -32,7 +32,6 @@ namespace OpenRA public IOccupySpace OccupiesSpace { get { return occupySpace.Value; } } public CPos Location { get { return occupySpace.Value.TopLeft; } } - public PPos CenterLocation { get { return PPos.FromWPos(occupySpace.Value.CenterPosition); } } public WPos CenterPosition { get { return occupySpace.Value.CenterPosition; } } public WRot Orientation diff --git a/OpenRA.Game/CPos.cs b/OpenRA.Game/CPos.cs index 4a9151a269..cb43935556 100644 --- a/OpenRA.Game/CPos.cs +++ b/OpenRA.Game/CPos.cs @@ -39,7 +39,6 @@ namespace OpenRA public float2 ToFloat2() { return new float2(X, Y); } public int2 ToInt2() { return new int2(X, Y); } - public PPos ToPPos() { return new PPos(Game.CellSize * X, Game.CellSize * Y); } public WPos CenterPosition { get { return new WPos(1024 * X + 512, 1024 * Y + 512, 0); } } public WPos TopLeft { get { return new WPos(1024 * X, 1024 * Y, 0); } } diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 410110aeee..eca34a8364 100644 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -85,8 +85,6 @@ - - diff --git a/OpenRA.Game/PPos.cs b/OpenRA.Game/PPos.cs deleted file mode 100644 index d965b5191e..0000000000 --- a/OpenRA.Game/PPos.cs +++ /dev/null @@ -1,107 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation. For more information, - * see COPYING. - */ -#endregion - -using System; -using System.Drawing; - -namespace OpenRA -{ - /// - /// Pixel coordinate position in the world (fine). - /// - public struct PPos - { - public readonly int X, Y; - - public PPos(int x, int y) { X = x; Y = y; } - - public static readonly PPos Zero = new PPos(0, 0); - public static PPos FromWPos(WPos pos) - { - return new PPos(Game.CellSize*pos.X/1024, Game.CellSize*pos.Y/1024); - } - - // Temporary hack for things that throw away altitude and - // cache screen positions directly. This can go once all - // the callers understand world coordinates - public static PPos FromWPosHackZ(WPos pos) - { - return new PPos(Game.CellSize*pos.X/1024, Game.CellSize*(pos.Y - pos.Z)/1024); - } - - public static explicit operator PPos(int2 a) { return new PPos(a.X, a.Y); } - - public static explicit operator PVecInt(PPos a) { return new PVecInt(a.X, a.Y); } - - public static PPos operator +(PPos a, PVecInt b) { return new PPos(a.X + b.X, a.Y + b.Y); } - public static PVecInt operator -(PPos a, PPos b) { return new PVecInt(a.X - b.X, a.Y - b.Y); } - public static PPos operator -(PPos a, PVecInt b) { return new PPos(a.X - b.X, a.Y - b.Y); } - - public static bool operator ==(PPos me, PPos other) { return (me.X == other.X && me.Y == other.Y); } - public static bool operator !=(PPos me, PPos other) { return !(me == other); } - - public static PPos Max(PPos a, PPos b) { return new PPos(Math.Max(a.X, b.X), Math.Max(a.Y, b.Y)); } - public static PPos Min(PPos a, PPos b) { return new PPos(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y)); } - - public static PPos Lerp(PPos a, PPos b, int mul, int div) - { - return a + ((PVecInt)(b - a) * mul / div); - } - - public static PPos Average(params PPos[] list) - { - if (list == null || list.Length == 0) - throw new ArgumentException("PPos: Cannot calculate average of empty list."); - - var x = 0; - var y = 0; - foreach(var pos in list) - { - x += pos.X; - y += pos.Y; - } - - x /= list.Length; - y /= list.Length; - - return new PPos(x,y); - } - - public float2 ToFloat2() { return new float2(X, Y); } - public int2 ToInt2() { return new int2(X, Y); } - public CPos ToCPos() { return new CPos((int)(1f / Game.CellSize * X), (int)(1f / Game.CellSize * Y)); } - - public PPos Clamp(Rectangle r) - { - return new PPos(Math.Min(r.Right, Math.Max(X, r.Left)), - Math.Min(r.Bottom, Math.Max(Y, r.Top))); - } - - public WPos ToWPos(int z) - { - return new WPos(1024*X/Game.CellSize, - 1024*Y/Game.CellSize, - 1024*z/Game.CellSize); - } - - public override int GetHashCode() { return X.GetHashCode() ^ Y.GetHashCode(); } - - public override bool Equals(object obj) - { - if (obj == null) - return false; - - PPos o = (PPos)obj; - return o == this; - } - - public override string ToString() { return "{0},{1}".F(X, Y); } - } -} diff --git a/OpenRA.Game/PVecInt.cs b/OpenRA.Game/PVecInt.cs deleted file mode 100644 index aed7981228..0000000000 --- a/OpenRA.Game/PVecInt.cs +++ /dev/null @@ -1,79 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation. For more information, - * see COPYING. - */ -#endregion - -using System; -using System.Drawing; - -namespace OpenRA -{ - /// - /// Pixel coordinate vector (fine; integer) - /// - public struct PVecInt - { - public readonly int X, Y; - - public PVecInt(int x, int y) { X = x; Y = y; } - public PVecInt(Size p) { X = p.Width; Y = p.Height; } - - public static readonly PVecInt Zero = new PVecInt(0, 0); - public static PVecInt OneCell { get { return new PVecInt(Game.CellSize, Game.CellSize); } } - - public static explicit operator PVecInt(int2 a) { return new PVecInt(a.X, a.Y); } - - public static PVecInt FromRadius(int r) { return new PVecInt(r, r); } - - public static PVecInt operator +(PVecInt a, PVecInt b) { return new PVecInt(a.X + b.X, a.Y + b.Y); } - public static PVecInt operator -(PVecInt a, PVecInt b) { return new PVecInt(a.X - b.X, a.Y - b.Y); } - public static PVecInt operator *(int a, PVecInt b) { return new PVecInt(a * b.X, a * b.Y); } - public static PVecInt operator *(PVecInt b, int a) { return new PVecInt(a * b.X, a * b.Y); } - public static PVecInt operator /(PVecInt a, int b) { return new PVecInt(a.X / b, a.Y / b); } - - public static PVecInt operator -(PVecInt a) { return new PVecInt(-a.X, -a.Y); } - - public static bool operator ==(PVecInt me, PVecInt other) { return (me.X == other.X && me.Y == other.Y); } - public static bool operator !=(PVecInt me, PVecInt other) { return !(me == other); } - - public static PVecInt Max(PVecInt a, PVecInt b) { return new PVecInt(Math.Max(a.X, b.X), Math.Max(a.Y, b.Y)); } - public static PVecInt Min(PVecInt a, PVecInt b) { return new PVecInt(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y)); } - - public static int Dot(PVecInt a, PVecInt b) { return a.X * b.X + a.Y * b.Y; } - - public PVecInt Sign() { return new PVecInt(Math.Sign(X), Math.Sign(Y)); } - public PVecInt Abs() { return new PVecInt(Math.Abs(X), Math.Abs(Y)); } - public int LengthSquared { get { return X * X + Y * Y; } } - public int Length { get { return (int)Math.Sqrt(LengthSquared); } } - - public float2 ToFloat2() { return new float2(X, Y); } - public int2 ToInt2() { return new int2(X, Y); } - public CVec ToCVec() { return new CVec(X / Game.CellSize, Y / Game.CellSize); } - - public PVecInt Clamp(Rectangle r) - { - return new PVecInt( - Math.Min(r.Right, Math.Max(X, r.Left)), - Math.Min(r.Bottom, Math.Max(Y, r.Top)) - ); - } - - public override int GetHashCode() { return X.GetHashCode() ^ Y.GetHashCode(); } - - public override bool Equals(object obj) - { - if (obj == null) - return false; - - PVecInt o = (PVecInt)obj; - return o == this; - } - - public override string ToString() { return "{0},{1}".F(X, Y); } - } -} diff --git a/OpenRA.Game/Sync.cs b/OpenRA.Game/Sync.cs index 285450fe61..59c1a6af97 100755 --- a/OpenRA.Game/Sync.cs +++ b/OpenRA.Game/Sync.cs @@ -36,8 +36,6 @@ namespace OpenRA {typeof(int2), ((Func)hash_int2).Method}, {typeof(CPos), ((Func)hash_CPos).Method}, {typeof(CVec), ((Func)hash_CVec).Method}, - {typeof(PPos), ((Func)hash_PPos).Method}, - {typeof(PVecInt), ((Func)hash_PVecInt).Method}, {typeof(WRange), ((Func)hash).Method}, {typeof(WPos), ((Func)hash).Method}, {typeof(WVec), ((Func)hash).Method}, @@ -115,16 +113,6 @@ namespace OpenRA { return ((i2.X * 5) ^ (i2.Y * 3)) / 4; } - - public static int hash_PPos(PPos i2) - { - return ((i2.X * 5) ^ (i2.Y * 3)) / 4; - } - - public static int hash_PVecInt(PVecInt i2) - { - return ((i2.X * 5) ^ (i2.Y * 3)) / 4; - } public static int hash_tdict(TypeDictionary d) {