add IHasLocation

This commit is contained in:
Bob
2010-10-08 19:10:31 +13:00
committed by Chris Forbes
parent 9c362f7d41
commit 011a20e8b4
31 changed files with 133 additions and 107 deletions

View File

@@ -18,9 +18,11 @@ namespace OpenRA.Mods.RA.Activities
{
public readonly float2 Pos;
public Fly(float2 pos) { Pos = pos; }
public Fly(int2 pos) { Pos = Util.CenterOfCell(pos); }
private Fly( float2 px ) { Pos = px; }
public static Fly ToPx( float2 px ) { return new Fly( px ); }
public static Fly ToCell( int2 pos ) { return new Fly( Util.CenterOfCell( pos ) ); }
public override IActivity Tick(Actor self)
{
var cruiseAltitude = self.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
@@ -57,7 +59,7 @@ namespace OpenRA.Mods.RA.Activities
var aircraft = self.Trait<Aircraft>();
var speed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
var angle = aircraft.Facing / 128f * Math.PI;
self.CenterLocation += speed * -float2.FromAngle((float)angle);
aircraft.center += speed * -float2.FromAngle((float)angle);
aircraft.Location = Util.CellContaining(self.CenterLocation);
aircraft.Altitude += Math.Sign(desiredAltitude - aircraft.Altitude);
}