diff --git a/OpenRA.Mods.Common/Activities/Air/FlyAttack.cs b/OpenRA.Mods.Common/Activities/Air/FlyAttack.cs index 1c3419d52b..3419e56e15 100644 --- a/OpenRA.Mods.Common/Activities/Air/FlyAttack.cs +++ b/OpenRA.Mods.Common/Activities/Air/FlyAttack.cs @@ -111,11 +111,12 @@ namespace OpenRA.Mods.Common.Activities return true; } - // If all valid weapons have depleted their ammo and Rearmable trait exists, return to RearmActor to reload and then resume the activity + // If all valid weapons have depleted their ammo and Rearmable trait exists, return to RearmActor to reload + // and resume the activity after reloading if AbortOnResupply is set to 'false' if (rearmable != null && !useLastVisibleTarget && attackAircraft.Armaments.All(x => x.IsTraitPaused || !x.Weapon.IsValidAgainst(target, self.World, self))) { QueueChild(new ReturnToBase(self)); - return aircraft.Info.AbortOnResupply; + return attackAircraft.Info.AbortOnResupply; } var pos = self.CenterPosition; diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index 9705882c6c..69311b7814 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -94,9 +94,6 @@ namespace OpenRA.Mods.Common.Traits [Desc("Will this actor try to land after it has no more commands?")] public readonly bool LandWhenIdle = true; - [Desc("Does this actor cancel its previous activity after resupplying?")] - public readonly bool AbortOnResupply = true; - [Desc("Altitude at which the aircraft considers itself landed.")] public readonly WDist LandAltitude = WDist.Zero; diff --git a/OpenRA.Mods.Common/Traits/Air/AttackAircraft.cs b/OpenRA.Mods.Common/Traits/Air/AttackAircraft.cs index 19869fe1d7..1150393014 100644 --- a/OpenRA.Mods.Common/Traits/Air/AttackAircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/AttackAircraft.cs @@ -26,6 +26,9 @@ namespace OpenRA.Mods.Common.Traits [Desc("Delay, in game ticks, before strafing aircraft turns to attack.")] public readonly int AttackTurnDelay = 50; + [Desc("Does this actor cancel its attack activity when it needs to resupply? Setting this to 'false' will make the actor resume attack after reloading.")] + public readonly bool AbortOnResupply = true; + public override object Create(ActorInitializer init) { return new AttackAircraft(init.Self, this); } } diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/20190314/MoveAbortOnResupply.cs b/OpenRA.Mods.Common/UpdateRules/Rules/20190314/MoveAbortOnResupply.cs new file mode 100644 index 0000000000..29ea5a6b9c --- /dev/null +++ b/OpenRA.Mods.Common/UpdateRules/Rules/20190314/MoveAbortOnResupply.cs @@ -0,0 +1,60 @@ +#region Copyright & License Information +/* + * Copyright 2007-2019 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, either version 3 of + * the License, or (at your option) any later version. For more + * information, see COPYING. + */ +#endregion + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace OpenRA.Mods.Common.UpdateRules.Rules +{ + public class MoveAbortOnResupply : UpdateRule + { + public override string Name { get { return "Moved AbortOnResupply from Aircraft to AttackAircraft"; } } + public override string Description + { + get + { + return "AbortOnResupply boolean was moved to AttackAircraft."; + } + } + + public override IEnumerable UpdateActorNode(ModData modData, MiniYamlNode actorNode) + { + var aircraft = actorNode.LastChildMatching("Aircraft"); + var attackAircraft = actorNode.ChildrenMatching("AttackAircraft"); + + if (aircraft != null) + { + var abortOnResupply = aircraft.LastChildMatching("AbortOnResupply"); + if (abortOnResupply == null) + yield break; + + // Only add field to AttackAircraft if explicitly set to 'false' + if (!abortOnResupply.NodeValue()) + { + if (attackAircraft.Any()) + foreach (var a in attackAircraft) + a.AddNode(abortOnResupply); + else + { + var newAttackAircraft = new MiniYamlNode("AttackAircraft", ""); + newAttackAircraft.AddNode(abortOnResupply); + actorNode.AddNode(newAttackAircraft); + } + } + + aircraft.RemoveNode(abortOnResupply); + } + + yield break; + } + } +}