Remove fp from CenterLocation and aircraft.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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; } }
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -17,11 +17,11 @@ namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
public class Fly : CancelableActivity
|
||||
{
|
||||
public readonly float2 Pos;
|
||||
public readonly int2 Pos;
|
||||
|
||||
private Fly( float2 px ) { Pos = px; }
|
||||
private Fly( int2 px ) { Pos = px; }
|
||||
|
||||
public static Fly ToPx( float2 px ) { return new Fly( px ); }
|
||||
public static Fly ToPx( int2 px ) { return new Fly( px ); }
|
||||
public static Fly ToCell( int2 pos ) { return new Fly( Util.CenterOfCell( pos ) ); }
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
bool isCalculated;
|
||||
Actor dest;
|
||||
|
||||
float2 w1, w2, w3; /* tangent points to turn circles */
|
||||
int2 w1, w2, w3; /* tangent points to turn circles */
|
||||
|
||||
public static Actor ChooseAirfield(Actor self)
|
||||
{
|
||||
@@ -74,9 +74,9 @@ namespace OpenRA.Mods.RA.Air
|
||||
|
||||
if (f.X > 0) f = -f;
|
||||
|
||||
w1 = c1 + f;
|
||||
w2 = c2 + f;
|
||||
w3 = approachStart;
|
||||
w1 = (c1 + f).ToInt2();
|
||||
w2 = (c2 + f).ToInt2();
|
||||
w3 = (approachStart).ToInt2();
|
||||
|
||||
isCalculated = true;
|
||||
}
|
||||
|
||||
@@ -47,8 +47,8 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
srcAltitude = self.Trait<IMove>().Altitude,
|
||||
destAltitude = 0,
|
||||
src = self.CenterLocation.ToInt2(),
|
||||
dest = self.CenterLocation.ToInt2(),
|
||||
src = self.CenterLocation,
|
||||
dest = self.CenterLocation,
|
||||
facing = self.Trait<IFacing>().Facing,
|
||||
firedBy = self,
|
||||
weapon = weapon
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
if (!doneDamage)
|
||||
{
|
||||
if (args.target.IsValid)
|
||||
args.dest = args.target.CenterLocation.ToInt2();
|
||||
args.dest = args.target.CenterLocation;
|
||||
|
||||
Combat.DoImpacts(args);
|
||||
doneDamage = true;
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
readonly ProjectileArgs Args;
|
||||
|
||||
int2 offset;
|
||||
float2 Pos;
|
||||
int2 Pos;
|
||||
readonly Animation anim;
|
||||
int Facing;
|
||||
int t;
|
||||
@@ -93,12 +93,13 @@ namespace OpenRA.Mods.RA.Effects
|
||||
var speed = Scale * Info.Speed * ((targetAltitude > 0 && Info.TurboBoost) ? 1.5f : 1f);
|
||||
|
||||
var angle = Facing / 128f * Math.PI;
|
||||
var move = speed * -float2.FromAngle((float)angle);
|
||||
// TODO: Replace float2.FromAngle with int2.FromFacing
|
||||
var move = (speed * -float2.FromAngle((float)angle)).ToInt2();
|
||||
Pos += move;
|
||||
|
||||
if (Info.Trail != null)
|
||||
world.AddFrameEndTask(w => w.Add(
|
||||
new Smoke(w, (Pos - 1.5f * move - new int2(0, Altitude)).ToInt2(), Info.Trail)));
|
||||
new Smoke(w, (Pos - 1.5f * move.ToFloat2() - new int2(0, Altitude)).ToInt2(), Info.Trail)));
|
||||
|
||||
if (Info.RangeLimit != 0 && t > Info.RangeLimit * 40)
|
||||
Explode(world);
|
||||
@@ -116,7 +117,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
void Explode(World world)
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
Args.dest = Pos.ToInt2();
|
||||
Args.dest = Pos;
|
||||
if (t > Info.Arm * 40) /* don't blow up in our launcher's face! */
|
||||
Combat.DoImpacts(Args);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
if (!doneDamage)
|
||||
{
|
||||
if (Args.target.IsValid)
|
||||
Args.dest = Args.target.CenterLocation.ToInt2();
|
||||
Args.dest = Args.target.CenterLocation;
|
||||
|
||||
Combat.DoImpacts(Args);
|
||||
doneDamage = true;
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace OpenRA.Mods.RA
|
||||
+ Combat.GetTurretPosition(self, facing, Turret)
|
||||
+ Combat.GetBarrelPosition(self, facing, Turret, barrel)).ToInt2(),
|
||||
srcAltitude = move != null ? move.Altitude : 0,
|
||||
dest = target.CenterLocation.ToInt2(),
|
||||
dest = target.CenterLocation,
|
||||
destAltitude = destMove != null ? destMove.Altitude : 0,
|
||||
|
||||
facing = barrel.Facing +
|
||||
|
||||
Reference in New Issue
Block a user