Remove Turret and PVecFloat cruft.
This commit is contained in:
@@ -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
|
||||
|
||||
1
OpenRA.Game/OpenRA.Game.csproj
Executable file → Normal file
1
OpenRA.Game/OpenRA.Game.csproj
Executable file → Normal file
@@ -84,7 +84,6 @@
|
||||
<Compile Include="PSubVec.cs" />
|
||||
<Compile Include="PSubPos.cs" />
|
||||
<Compile Include="PVecInt.cs" />
|
||||
<Compile Include="PVecFloat.cs" />
|
||||
<Compile Include="PPos.cs" />
|
||||
<Compile Include="Download.cs" />
|
||||
<Compile Include="Effects\DelayedAction.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); }
|
||||
|
||||
@@ -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); }
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Pixel coordinate vector (fine; float)
|
||||
/// </summary>
|
||||
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); }
|
||||
}
|
||||
}
|
||||
@@ -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); }
|
||||
|
||||
@@ -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<RenderUnit>();
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user