Rename FlyCircle to FlyIdle and make it tick TickIdle
It now handles both hovering and circling aircraft, for consistency.
This commit is contained in:
@@ -9,22 +9,26 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Activities
|
namespace OpenRA.Mods.Common.Activities
|
||||||
{
|
{
|
||||||
public class FlyCircle : Activity
|
public class FlyIdle : Activity
|
||||||
{
|
{
|
||||||
readonly Aircraft aircraft;
|
readonly Aircraft aircraft;
|
||||||
readonly int turnSpeedOverride;
|
readonly INotifyIdle[] tickIdles;
|
||||||
|
readonly int turnSpeed;
|
||||||
int remainingTicks;
|
int remainingTicks;
|
||||||
|
|
||||||
public FlyCircle(Actor self, int ticks = -1, int turnSpeedOverride = -1)
|
public FlyIdle(Actor self, int ticks = -1)
|
||||||
{
|
{
|
||||||
aircraft = self.Trait<Aircraft>();
|
aircraft = self.Trait<Aircraft>();
|
||||||
|
tickIdles = self.TraitsImplementing<INotifyIdle>().ToArray();
|
||||||
|
turnSpeed = aircraft.Info.IdleTurnSpeed > -1 ? aircraft.Info.IdleTurnSpeed : aircraft.TurnSpeed;
|
||||||
remainingTicks = ticks;
|
remainingTicks = ticks;
|
||||||
this.turnSpeedOverride = turnSpeedOverride;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Tick(Actor self)
|
public override bool Tick(Actor self)
|
||||||
@@ -32,26 +36,25 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (remainingTicks == 0 || (NextActivity != null && remainingTicks < 0))
|
if (remainingTicks == 0 || (NextActivity != null && remainingTicks < 0))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Refuse to take off if it would land immediately again.
|
if (aircraft.ForceLanding || IsCanceling)
|
||||||
if (aircraft.ForceLanding)
|
|
||||||
{
|
|
||||||
Cancel(self);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsCanceling)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (remainingTicks > 0)
|
if (remainingTicks > 0)
|
||||||
remainingTicks--;
|
remainingTicks--;
|
||||||
|
|
||||||
|
foreach (var tickIdle in tickIdles)
|
||||||
|
tickIdle.TickIdle(self);
|
||||||
|
|
||||||
|
if (!aircraft.Info.CanHover)
|
||||||
|
{
|
||||||
// We can't possibly turn this fast
|
// We can't possibly turn this fast
|
||||||
var desiredFacing = aircraft.Facing + 64;
|
var desiredFacing = aircraft.Facing + 64;
|
||||||
|
|
||||||
// This override is necessary, otherwise aircraft with CanSlide would circle sideways
|
// This override is necessary, otherwise aircraft with CanSlide would circle sideways
|
||||||
var move = aircraft.FlyStep(aircraft.Facing);
|
var move = aircraft.FlyStep(aircraft.Facing);
|
||||||
|
|
||||||
Fly.FlyTick(self, aircraft, desiredFacing, aircraft.Info.CruiseAltitude, move, turnSpeedOverride);
|
Fly.FlyTick(self, aircraft, desiredFacing, aircraft.Info.CruiseAltitude, move, turnSpeed);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -215,10 +215,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (!aircraft.CanLand(blockingCells, target.Actor))
|
if (!aircraft.CanLand(blockingCells, target.Actor))
|
||||||
{
|
{
|
||||||
// Maintain holding pattern.
|
// Maintain holding pattern.
|
||||||
if (aircraft.Info.CanHover)
|
QueueChild(new FlyIdle(self, 25));
|
||||||
QueueChild(new Wait(25));
|
|
||||||
else
|
|
||||||
QueueChild(new FlyCircle(self, 25));
|
|
||||||
|
|
||||||
self.NotifyBlocker(blockingCells);
|
self.NotifyBlocker(blockingCells);
|
||||||
finishedApproach = false;
|
finishedApproach = false;
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
}
|
}
|
||||||
|
|
||||||
QueueChild(new Fly(self, Target.FromActor(nearestResupplier), WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase, targetLineColor: Color.Green));
|
QueueChild(new Fly(self, Target.FromActor(nearestResupplier), WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase, targetLineColor: Color.Green));
|
||||||
QueueChild(new FlyCircle(self, aircraft.Info.NumberOfTicksToVerifyAvailableAirport));
|
QueueChild(new FlyIdle(self, aircraft.Info.NumberOfTicksToVerifyAvailableAirport));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -712,8 +712,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.QueueActivity(new TakeOff(self));
|
self.QueueActivity(new TakeOff(self));
|
||||||
else if (Info.IdleBehavior == IdleBehaviorType.Land && Info.LandableTerrainTypes.Count > 0)
|
else if (Info.IdleBehavior == IdleBehaviorType.Land && Info.LandableTerrainTypes.Count > 0)
|
||||||
self.QueueActivity(new Land(self));
|
self.QueueActivity(new Land(self));
|
||||||
else if (!Info.CanHover)
|
else
|
||||||
self.QueueActivity(new FlyCircle(self, -1, Info.IdleTurnSpeed > -1 ? Info.IdleTurnSpeed : TurnSpeed));
|
self.QueueActivity(new FlyIdle(self));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user