Move AbortOnResupply to AttackAircraft

Additionally, if AbortOnResupply is set to 'true',
abort FlyAttack right away when queueing ReturnToBase.
This commit is contained in:
reaperrr
2019-07-01 02:19:30 +02:00
committed by Paul Chote
parent 1f16cb6864
commit e4011b86ac
4 changed files with 66 additions and 5 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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); }
}

View File

@@ -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<string> 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<bool>())
{
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;
}
}
}