From 819d315d56a034ecab633966b65b36f29b93f2b6 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Mon, 1 Apr 2013 12:28:38 +1300 Subject: [PATCH] Remove Turret and PVecFloat cruft. --- OpenRA.Game/Graphics/Viewport.cs | 2 +- OpenRA.Game/OpenRA.Game.csproj | 1 - OpenRA.Game/PPos.cs | 1 - OpenRA.Game/PSubPos.cs | 1 - OpenRA.Game/PSubVec.cs | 5 -- OpenRA.Game/PVecFloat.cs | 97 -------------------------------- OpenRA.Game/PVecInt.cs | 1 - OpenRA.Mods.RA/Turreted.cs | 27 --------- 8 files changed, 1 insertion(+), 134 deletions(-) mode change 100755 => 100644 OpenRA.Game/OpenRA.Game.csproj delete mode 100644 OpenRA.Game/PVecFloat.cs diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs index af87f627ed..885060c2ce 100755 --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -165,7 +165,7 @@ namespace OpenRA.Graphics var avgPos = actors .Select(a => (PVecInt)a.CenterLocation) .Aggregate((a, b) => a + b) / actors.Count(); - scrollPosition = NormalizeScrollPosition(((PVecFloat)avgPos - (PVecFloat)(1f / (2 * Zoom) * screenSize.ToFloat2())).ToInt2()); + scrollPosition = NormalizeScrollPosition((avgPos.ToFloat2() - (1f / (2 * Zoom) * screenSize.ToFloat2())).ToInt2()); } // Rectangle (in viewport coords) that contains things to be drawn diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj old mode 100755 new mode 100644 index e1d4cc465c..ac7aae5bb2 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -84,7 +84,6 @@ - diff --git a/OpenRA.Game/PPos.cs b/OpenRA.Game/PPos.cs index 2703986419..4a3f45b350 100644 --- a/OpenRA.Game/PPos.cs +++ b/OpenRA.Game/PPos.cs @@ -39,7 +39,6 @@ namespace OpenRA 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 explicit operator PVecFloat(PPos a) { return new PVecFloat(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); } diff --git a/OpenRA.Game/PSubPos.cs b/OpenRA.Game/PSubPos.cs index 8894012c92..7bd193565a 100644 --- a/OpenRA.Game/PSubPos.cs +++ b/OpenRA.Game/PSubPos.cs @@ -29,7 +29,6 @@ namespace OpenRA public static explicit operator PSubPos(int2 a) { return new PSubPos(a.X, a.Y); } public static explicit operator PSubVec(PSubPos a) { return new PSubVec(a.X, a.Y); } - public static explicit operator PVecFloat(PSubPos a) { return new PVecFloat(a.X, a.Y); } public static PSubPos operator +(PSubPos a, PSubVec b) { return new PSubPos(a.X + b.X, a.Y + b.Y); } public static PSubVec operator -(PSubPos a, PSubPos b) { return new PSubVec(a.X - b.X, a.Y - b.Y); } diff --git a/OpenRA.Game/PSubVec.cs b/OpenRA.Game/PSubVec.cs index 44c9b92837..d461ec6333 100644 --- a/OpenRA.Game/PSubVec.cs +++ b/OpenRA.Game/PSubVec.cs @@ -94,10 +94,5 @@ namespace OpenRA { return new PSubVec((vec.X * PSubPos.PerPx), (vec.Y * PSubPos.PerPx)); } - - public static PSubVec ToPSubVec(this PVecFloat vec) - { - return new PSubVec((int)(vec.X * PSubPos.PerPx), (int)(vec.Y * PSubPos.PerPx)); - } } } diff --git a/OpenRA.Game/PVecFloat.cs b/OpenRA.Game/PVecFloat.cs deleted file mode 100644 index be463763d4..0000000000 --- a/OpenRA.Game/PVecFloat.cs +++ /dev/null @@ -1,97 +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; float) - /// - public struct PVecFloat - { - public readonly float X, Y; - - public PVecFloat(float x, float y) { X = x; Y = y; } - public PVecFloat(Size p) { X = p.Width; Y = p.Height; } - - public static readonly PVecFloat Zero = new PVecFloat(0, 0); - - public static explicit operator PVecInt(PVecFloat a) { return new PVecInt((int)a.X, (int)a.Y); } - public static explicit operator PVecFloat(float2 a) { return new PVecFloat(a.X, a.Y); } - - public static PVecFloat operator +(PVecFloat a, PVecFloat b) { return new PVecFloat(a.X + b.X, a.Y + b.Y); } - public static PVecFloat operator -(PVecFloat a, PVecFloat b) { return new PVecFloat(a.X - b.X, a.Y - b.Y); } - public static PVecFloat operator *(float a, PVecFloat b) { return new PVecFloat(a * b.X, a * b.Y); } - public static PVecFloat operator *(PVecFloat b, float a) { return new PVecFloat(a * b.X, a * b.Y); } - public static PVecFloat operator /(PVecFloat a, float b) { return new PVecFloat(a.X / b, a.Y / b); } - - public static PVecFloat operator -(PVecFloat a) { return new PVecFloat(-a.X, -a.Y); } - - public static bool operator ==(PVecFloat me, PVecFloat other) { return (me.X == other.X && me.Y == other.Y); } - public static bool operator !=(PVecFloat me, PVecFloat other) { return !(me == other); } - - public static PVecFloat Max(PVecFloat a, PVecFloat b) { return new PVecFloat(Math.Max(a.X, b.X), Math.Max(a.Y, b.Y)); } - public static PVecFloat Min(PVecFloat a, PVecFloat b) { return new PVecFloat(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y)); } - - public static float Dot(PVecFloat a, PVecFloat b) { return a.X * b.X + a.Y * b.Y; } - - public static PVecFloat FromAngle(float a) { return new PVecFloat((float)Math.Sin(a), (float)Math.Cos(a)); } - - public static PVecFloat Lerp(PVecFloat a, PVecFloat b, float t) - { - return new PVecFloat( - float2.Lerp(a.X, b.X, t), - float2.Lerp(a.Y, b.Y, t) - ); - } - - public static PVecFloat Lerp(PVecFloat a, PVecFloat b, PVecFloat t) - { - return new PVecFloat( - float2.Lerp(a.X, b.X, t.X), - float2.Lerp(a.Y, b.Y, t.Y) - ); - } - - public PVecFloat Sign() { return new PVecFloat(Math.Sign(X), Math.Sign(Y)); } - public PVecFloat Abs() { return new PVecFloat(Math.Abs(X), Math.Abs(Y)); } - public PVecFloat Round() { return new PVecFloat((float)Math.Round(X), (float)Math.Round(Y)); } - public float LengthSquared { get { return X * X + Y * Y; } } - public float Length { get { return (float)Math.Sqrt(LengthSquared); } } - - public float2 ToFloat2() { return new float2(X, Y); } - public int2 ToInt2() { return new int2((int)X, (int)Y); } - - static float Constrain(float x, float a, float b) { return x < a ? a : x > b ? b : x; } - - public PVecFloat Constrain(PVecFloat min, PVecFloat max) - { - return new PVecFloat( - Constrain(X, min.X, max.X), - Constrain(Y, min.Y, max.Y) - ); - } - - public override int GetHashCode() { return X.GetHashCode() ^ Y.GetHashCode(); } - - public override bool Equals(object obj) - { - if (obj == null) - return false; - - PVecFloat o = (PVecFloat)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 index a98ea9fc5a..aed7981228 100644 --- a/OpenRA.Game/PVecInt.cs +++ b/OpenRA.Game/PVecInt.cs @@ -26,7 +26,6 @@ namespace OpenRA public static readonly PVecInt Zero = new PVecInt(0, 0); public static PVecInt OneCell { get { return new PVecInt(Game.CellSize, Game.CellSize); } } - public static implicit operator PVecFloat(PVecInt a) { return new PVecFloat((float)a.X, (float)a.Y); } 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); } diff --git a/OpenRA.Mods.RA/Turreted.cs b/OpenRA.Mods.RA/Turreted.cs index 37fdfa225d..0040377b81 100755 --- a/OpenRA.Mods.RA/Turreted.cs +++ b/OpenRA.Mods.RA/Turreted.cs @@ -95,31 +95,4 @@ namespace OpenRA.Mods.RA return WRot.FromYaw(WAngle.FromFacing(turretFacing) - self.Orientation.Yaw); } } - - // TODO: Remove this - public class Turret - { - public PVecInt UnitSpacePosition; // where, in the unit's local space. - public PVecInt ScreenSpacePosition; // screen-space hack to make things line up good. - - public Turret(int[] offset) - { - ScreenSpacePosition = (PVecInt) offset.AbsOffset().ToInt2(); - UnitSpacePosition = (PVecInt) offset.RelOffset().ToInt2(); - } - - public PVecFloat PxPosition(Actor self, IFacing facing) - { - // Things that don't have a rotating base don't need the turrets repositioned - if (facing == null) return ScreenSpacePosition; - - var ru = self.TraitOrDefault(); - var numDirs = (ru != null) ? ru.anim.CurrentSequence.Facings : 8; - var bodyFacing = facing.Facing; - var quantizedFacing = Util.QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs); - - return (PVecFloat)Util.RotateVectorByFacing(UnitSpacePosition.ToFloat2(), quantizedFacing, .7f) - + (PVecFloat)ScreenSpacePosition.ToFloat2(); - } - } }