Remove PPos and PVecInt.
This commit is contained in:
@@ -32,7 +32,6 @@ namespace OpenRA
|
|||||||
public IOccupySpace OccupiesSpace { get { return occupySpace.Value; } }
|
public IOccupySpace OccupiesSpace { get { return occupySpace.Value; } }
|
||||||
|
|
||||||
public CPos Location { get { return occupySpace.Value.TopLeft; } }
|
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 WPos CenterPosition { get { return occupySpace.Value.CenterPosition; } }
|
||||||
|
|
||||||
public WRot Orientation
|
public WRot Orientation
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ namespace OpenRA
|
|||||||
|
|
||||||
public float2 ToFloat2() { return new float2(X, Y); }
|
public float2 ToFloat2() { return new float2(X, Y); }
|
||||||
public int2 ToInt2() { return new int2(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 CenterPosition { get { return new WPos(1024 * X + 512, 1024 * Y + 512, 0); } }
|
||||||
public WPos TopLeft { get { return new WPos(1024 * X, 1024 * Y, 0); } }
|
public WPos TopLeft { get { return new WPos(1024 * X, 1024 * Y, 0); } }
|
||||||
|
|||||||
@@ -85,8 +85,6 @@
|
|||||||
<Compile Include="ActorInitializer.cs" />
|
<Compile Include="ActorInitializer.cs" />
|
||||||
<Compile Include="ActorReference.cs" />
|
<Compile Include="ActorReference.cs" />
|
||||||
<Compile Include="Graphics\QuadRenderer.cs" />
|
<Compile Include="Graphics\QuadRenderer.cs" />
|
||||||
<Compile Include="PVecInt.cs" />
|
|
||||||
<Compile Include="PPos.cs" />
|
|
||||||
<Compile Include="Download.cs" />
|
<Compile Include="Download.cs" />
|
||||||
<Compile Include="Effects\DelayedAction.cs" />
|
<Compile Include="Effects\DelayedAction.cs" />
|
||||||
<Compile Include="Effects\FlashTarget.cs" />
|
<Compile Include="Effects\FlashTarget.cs" />
|
||||||
|
|||||||
@@ -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
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Pixel coordinate position in the world (fine).
|
|
||||||
/// </summary>
|
|
||||||
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); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Pixel coordinate vector (fine; integer)
|
|
||||||
/// </summary>
|
|
||||||
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); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -36,8 +36,6 @@ namespace OpenRA
|
|||||||
{typeof(int2), ((Func<int2, int>)hash_int2).Method},
|
{typeof(int2), ((Func<int2, int>)hash_int2).Method},
|
||||||
{typeof(CPos), ((Func<CPos, int>)hash_CPos).Method},
|
{typeof(CPos), ((Func<CPos, int>)hash_CPos).Method},
|
||||||
{typeof(CVec), ((Func<CVec, int>)hash_CVec).Method},
|
{typeof(CVec), ((Func<CVec, int>)hash_CVec).Method},
|
||||||
{typeof(PPos), ((Func<PPos, int>)hash_PPos).Method},
|
|
||||||
{typeof(PVecInt), ((Func<PVecInt, int>)hash_PVecInt).Method},
|
|
||||||
{typeof(WRange), ((Func<WRange, int>)hash<WRange>).Method},
|
{typeof(WRange), ((Func<WRange, int>)hash<WRange>).Method},
|
||||||
{typeof(WPos), ((Func<WPos, int>)hash<WPos>).Method},
|
{typeof(WPos), ((Func<WPos, int>)hash<WPos>).Method},
|
||||||
{typeof(WVec), ((Func<WVec, int>)hash<WVec>).Method},
|
{typeof(WVec), ((Func<WVec, int>)hash<WVec>).Method},
|
||||||
@@ -115,16 +113,6 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
return ((i2.X * 5) ^ (i2.Y * 3)) / 4;
|
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)
|
public static int hash_tdict(TypeDictionary d)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user