From a7fa372045186bc5b567d21c345d1289710c1fe2 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Fri, 21 Jun 2019 03:17:39 +0200 Subject: [PATCH] Fix Resupply regression The work-around was originally written with ground units in mind and caused issues with aircraft. --- OpenRA.Mods.Common/Activities/Resupply.cs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/Resupply.cs b/OpenRA.Mods.Common/Activities/Resupply.cs index 40b17b098a..16c3dabc70 100644 --- a/OpenRA.Mods.Common/Activities/Resupply.cs +++ b/OpenRA.Mods.Common/Activities/Resupply.cs @@ -76,18 +76,29 @@ namespace OpenRA.Mods.Common.Activities public override bool Tick(Actor self) { // HACK: If the activity is cancelled while we're already resupplying (or about to start resupplying), - // move actor outside the resupplier footprint - // TODO: This check is nowhere near robust enough, and should be rewritten + // move actor outside the resupplier footprint. + // TODO: This check is nowhere near robust enough, and should be rewritten. if (IsCanceling && host.IsInRange(self.CenterPosition, closeEnough)) { - QueueChild(self.Trait().MoveToTarget(self, host)); foreach (var notifyResupply in notifyResupplies) notifyResupply.ResupplyTick(host.Actor, self, ResupplyType.None); - return false; - } + var aircraft = self.TraitOrDefault(); + if (aircraft != null) + { + aircraft.AllowYieldingReservation(); + if (aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.TakeOffOnResupply)) + Queue(new TakeOff(self)); - if (IsCanceling || host.Type == TargetType.Invalid + return true; + } + else if (self.Info.HasTraitInfo()) + { + QueueChild(self.Trait().MoveToTarget(self, host)); + return false; + } + } + else if (IsCanceling || host.Type == TargetType.Invalid || (closeEnough.LengthSquared > 0 && !host.IsInRange(self.CenterPosition, closeEnough))) { // This is necessary to ensure host resupply actions (like animations) finish properly