From b7d966f78fd8e7f9e1df2cabee2f570c0d50eb27 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 10 Aug 2019 19:01:41 +0000 Subject: [PATCH] Don't exit FlyOffMap immediately on leaving map Usually they'll get removed afterwards, so they need to be out of players' sight before ending this activity. --- OpenRA.Mods.Common/Activities/Air/FlyOffMap.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/Air/FlyOffMap.cs b/OpenRA.Mods.Common/Activities/Air/FlyOffMap.cs index f6ddb80633..0ea5c1eb49 100644 --- a/OpenRA.Mods.Common/Activities/Air/FlyOffMap.cs +++ b/OpenRA.Mods.Common/Activities/Air/FlyOffMap.cs @@ -20,17 +20,18 @@ namespace OpenRA.Mods.Common.Activities readonly Aircraft aircraft; readonly Target target; readonly bool hasTarget; + int endingDelay; - public FlyOffMap(Actor self) + public FlyOffMap(Actor self, int endingDelay = 25) { aircraft = self.Trait(); ChildHasPriority = false; + this.endingDelay = endingDelay; } - public FlyOffMap(Actor self, Target target) + public FlyOffMap(Actor self, Target target, int endingDelay = 25) + : this(self, endingDelay) { - aircraft = self.Trait(); - ChildHasPriority = false; this.target = target; hasTarget = true; } @@ -40,6 +41,7 @@ namespace OpenRA.Mods.Common.Activities if (hasTarget) { QueueChild(new Fly(self, target)); + QueueChild(new FlyTimed(-1, self)); return; } @@ -54,14 +56,14 @@ namespace OpenRA.Mods.Common.Activities { // Refuse to take off if it would land immediately again. if (aircraft.ForceLanding) - { Cancel(self); - return true; - } - if (IsCanceling || !self.World.Map.Contains(self.Location)) + if (IsCanceling) return true; + if (!self.World.Map.Contains(self.Location) && --endingDelay < 0) + ChildActivity.Cancel(self); + return TickChild(self); } }