Move ChildActivity handling into base Activity class.
This commit is contained in:
@@ -65,13 +65,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
if (ChildActivity != null)
|
||||
return this;
|
||||
}
|
||||
|
||||
// Refuse to take off if it would land immediately again.
|
||||
if (aircraft.ForceLanding)
|
||||
Cancel(self);
|
||||
@@ -121,7 +114,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// If all valid weapons have depleted their ammo and Rearmable trait exists, return to RearmActor to reload and then resume the activity
|
||||
if (rearmable != null && !useLastVisibleTarget && attackAircraft.Armaments.All(x => x.IsTraitPaused || !x.Weapon.IsValidAgainst(target, self.World, self)))
|
||||
{
|
||||
QueueChild(self, new ReturnToBase(self, aircraft.Info.AbortOnResupply), true);
|
||||
QueueChild(new ReturnToBase(self, aircraft.Info.AbortOnResupply));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -139,7 +132,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
}
|
||||
|
||||
// Fly towards the last known position
|
||||
QueueChild(self, new Fly(self, target, WDist.Zero, lastVisibleMaximumRange, checkTarget.CenterPosition, Color.Red), true);
|
||||
QueueChild(new Fly(self, target, WDist.Zero, lastVisibleMaximumRange, checkTarget.CenterPosition, Color.Red));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -148,21 +141,21 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var isAirborne = self.World.Map.DistanceAboveTerrain(pos).Length >= aircraft.Info.MinAirborneAltitude;
|
||||
|
||||
if (!isAirborne)
|
||||
QueueChild(self, new TakeOff(self), true);
|
||||
QueueChild(new TakeOff(self));
|
||||
|
||||
if (attackAircraft.Info.AttackType == AirAttackType.Strafe)
|
||||
{
|
||||
if (target.IsInRange(pos, attackAircraft.GetMinimumRange()))
|
||||
QueueChild(self, new FlyTimed(ticksUntilTurn, self), true);
|
||||
QueueChild(new FlyTimed(ticksUntilTurn, self));
|
||||
|
||||
QueueChild(self, new Fly(self, target, target.CenterPosition, Color.Red), true);
|
||||
QueueChild(self, new FlyTimed(ticksUntilTurn, self));
|
||||
QueueChild(new Fly(self, target, target.CenterPosition, Color.Red));
|
||||
QueueChild(new FlyTimed(ticksUntilTurn, self));
|
||||
}
|
||||
else
|
||||
{
|
||||
var minimumRange = attackAircraft.GetMinimumRangeVersusTarget(target);
|
||||
if (!target.IsInRange(pos, lastVisibleMaximumRange) || target.IsInRange(pos, minimumRange))
|
||||
QueueChild(self, new Fly(self, target, minimumRange, lastVisibleMaximumRange, target.CenterPosition, Color.Red), true);
|
||||
QueueChild(new Fly(self, target, minimumRange, lastVisibleMaximumRange, target.CenterPosition, Color.Red));
|
||||
else if (isAirborne) // Don't use 'else' to avoid conflict with TakeOff
|
||||
Fly.VerticalTakeOffOrLandTick(self, aircraft, desiredFacing, aircraft.Info.CruiseAltitude);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user