Rewrite Aircraft movement using world coords.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2013 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,
|
||||
@@ -17,36 +17,35 @@ namespace OpenRA.Mods.RA.Air
|
||||
public class HeliAttack : Activity
|
||||
{
|
||||
Target target;
|
||||
public HeliAttack( Target target ) { this.target = target; }
|
||||
public HeliAttack(Target target) { this.target = target; }
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
if (!target.IsValid) return NextActivity;
|
||||
if (IsCanceled || !target.IsValid)
|
||||
return NextActivity;
|
||||
|
||||
var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
|
||||
var reloads = self.TraitOrDefault<Reloads>();
|
||||
if (limitedAmmo != null && !limitedAmmo.HasAmmo() && reloads == null)
|
||||
return Util.SequenceActivities( new HeliReturn(), NextActivity );
|
||||
|
||||
var aircraft = self.Trait<Aircraft>();
|
||||
var info = self.Info.Traits.Get<HelicopterInfo>();
|
||||
if (aircraft.Altitude != info.CruiseAltitude)
|
||||
{
|
||||
aircraft.Altitude += Math.Sign(info.CruiseAltitude - aircraft.Altitude);
|
||||
return this;
|
||||
}
|
||||
return Util.SequenceActivities(new HeliReturn(), NextActivity);
|
||||
|
||||
var helicopter = self.Trait<Helicopter>();
|
||||
var attack = self.Trait<AttackHeli>();
|
||||
var dist = target.CenterPosition - self.CenterPosition;
|
||||
|
||||
var desiredFacing = Util.GetFacing(dist, aircraft.Facing);
|
||||
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, aircraft.ROT);
|
||||
// Can rotate facing while ascending
|
||||
var desiredFacing = Util.GetFacing(dist, helicopter.Facing);
|
||||
helicopter.Facing = Util.TickFacing(helicopter.Facing, desiredFacing, helicopter.ROT);
|
||||
|
||||
var cruiseAltitude = new WRange(helicopter.Info.CruiseAltitude * 1024 / Game.CellSize);
|
||||
if (HeliFly.AdjustAltitude(self, helicopter, cruiseAltitude))
|
||||
return this;
|
||||
|
||||
// Fly towards the target
|
||||
if (!target.IsInRange(self.CenterPosition, attack.GetMaximumRange()))
|
||||
aircraft.TickMove(PSubPos.PerPx * aircraft.MovementSpeed, desiredFacing);
|
||||
helicopter.SetPosition(self, helicopter.CenterPosition + helicopter.FlyStep(desiredFacing));
|
||||
|
||||
attack.DoAttack( self, target );
|
||||
attack.DoAttack(self, target);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user