Remove fp from CenterLocation and aircraft.

This commit is contained in:
Paul Chote
2011-01-01 13:21:22 +13:00
parent d395c5e05d
commit 60e3f7621f
13 changed files with 26 additions and 25 deletions

View File

@@ -27,7 +27,7 @@ namespace OpenRA
public readonly uint ActorID;
public int2 Location { get { return Trait<IOccupySpace>().TopLeft; } }
public float2 CenterLocation { get { return Trait<IHasLocation>().PxPosition; } }
public int2 CenterLocation { get { return Trait<IHasLocation>().PxPosition; } }
[Sync]
public Player Owner;

View File

@@ -116,11 +116,10 @@ namespace OpenRA.Graphics
{
if (!actors.Any()) return;
var avgPos = (1f / actors.Count()) * actors
var avgPos = actors
.Select(a => a.CenterLocation)
.Aggregate((a, b) => a + b);
scrollPosition = this.NormalizeScrollPosition((avgPos.ToInt2() - screenSize / 2));
.Aggregate((a, b) => a + b) / actors.Count();
scrollPosition = this.NormalizeScrollPosition((avgPos - screenSize / 2));
}
public Rectangle ViewBounds(World world)

View File

@@ -59,7 +59,7 @@ namespace OpenRA.Traits
var p = target.CenterLocation;
var move = self.TraitOrDefault<IMove>();
var origin = move != null ? self.CenterLocation - new float2(0, move.Altitude) : self.CenterLocation;
var origin = move != null ? self.CenterLocation - new int2(0, move.Altitude) : self.CenterLocation;
Game.Renderer.LineRenderer.DrawLine(origin, p, c, c);
for (bool b = false; !b; p = origin, b = true)

View File

@@ -231,7 +231,7 @@ namespace OpenRA.Traits
public bool IsValid { get { return valid && (actor == null || actor.IsInWorld); } }
public int2 PxPosition { get { return IsActor ? actor.Trait<IHasLocation>().PxPosition : pos.ToInt2(); } }
public float2 CenterLocation { get { return PxPosition; } }
public int2 CenterLocation { get { return PxPosition; } }
public Actor Actor { get { return IsActor ? actor : null; } }
public bool IsActor { get { return actor != null && !actor.Destroyed; } }

View File

@@ -34,8 +34,9 @@ namespace OpenRA.Traits
static float2[] fvecs = Graphics.Util.MakeArray<float2>( 32,
i => -float2.FromAngle( i / 16.0f * (float)Math.PI ) * new float2( 1f, 1.3f ) );
public static int GetFacing( float2 d, int currentFacing )
public static int GetFacing( int2 dd, int currentFacing )
{
var d = dd.ToFloat2();
if (float2.WithinEpsilon(d, float2.Zero, 0.001f))
return currentFacing;

View File

@@ -139,7 +139,7 @@ namespace OpenRA.Traits
if (cells.Any()) return cells;
}
return new[] { (1f / Game.CellSize * a.CenterLocation).ToInt2() };
return new[] { a.CenterLocation / Game.CellSize };
}
void RemoveActor(Actor a)