From 3211119027ba93314df3a0f870b212f4520d837e Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sun, 17 Mar 2019 20:06:22 +0100 Subject: [PATCH] Simplify ResupplyAircraft By moving part of the take-off prevention (when TakeOffOnResupply is set to false) to Aircraft. Main reason & advantage is that dropping the 'WaitFor' child makes this activity always end when resupplies are done, which makes it more compatible with being queued as ChildActivity itself (for example by ReturnToBase). --- .../Activities/Air/ResupplyAircraft.cs | 18 +++++++----------- OpenRA.Mods.Common/Traits/Air/Aircraft.cs | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/Air/ResupplyAircraft.cs b/OpenRA.Mods.Common/Activities/Air/ResupplyAircraft.cs index 39b219e0bd..a78e66a29d 100644 --- a/OpenRA.Mods.Common/Activities/Air/ResupplyAircraft.cs +++ b/OpenRA.Mods.Common/Activities/Air/ResupplyAircraft.cs @@ -28,18 +28,14 @@ namespace OpenRA.Mods.Common.Activities if (host == null) return; - if (!aircraft.Info.TakeOffOnResupply) - { - ChildActivity = ActivityUtils.SequenceActivities(self, aircraft.GetResupplyActivities(host).ToArray()); - QueueChild(self, new AllowYieldingReservation(self)); - QueueChild(self, new WaitFor(() => NextActivity != null || aircraft.ReservedActor == null)); - } - else - { - ChildActivity = ActivityUtils.SequenceActivities(self, aircraft.GetResupplyActivities(host).ToArray()); - QueueChild(self, new AllowYieldingReservation(self)); + var resupplyActivities = aircraft.GetResupplyActivities(host).ToArray(); + if (resupplyActivities.Any()) + QueueChild(self, ActivityUtils.SequenceActivities(self, resupplyActivities)); + + QueueChild(self, new AllowYieldingReservation(self)); + + if (aircraft.Info.TakeOffOnResupply) QueueChild(self, new TakeOff(self, (a, b, c) => NextActivity == null && b.NextActivity == null)); - } } public override Activity Tick(Actor self) diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index 2aaa09d638..43f08f6379 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -528,7 +528,7 @@ namespace OpenRA.Mods.Common.Traits self.QueueActivity(new HeliLand(self, true)); } - else if (!Info.CanHover) + else if (!Info.CanHover && (Info.TakeOffOnResupply || ReservedActor == null || self.World.Map.DistanceAboveTerrain(CenterPosition) != Info.LandAltitude)) self.QueueActivity(new FlyCircle(self, -1, Info.IdleTurnSpeed > -1 ? Info.IdleTurnSpeed : TurnSpeed)); // Temporary HACK for the AutoCarryall special case (needs CanHover, but also HeliFlyCircle on idle).