Fix force-landed transports taking off after (un)loading passengers.

This commit is contained in:
Paul Chote
2019-06-30 18:10:53 +01:00
committed by teinarss
parent da0b24e891
commit 5d8b6d6057
2 changed files with 13 additions and 3 deletions

View File

@@ -29,6 +29,7 @@ namespace OpenRA.Mods.Common.Activities
readonly WDist unloadRange;
Target destination;
bool takeOffAfterUnload;
public UnloadCargo(Actor self, WDist unloadRange, bool unloadAll = true)
: this(self, Target.Invalid, unloadRange, unloadAll)
@@ -74,7 +75,11 @@ namespace OpenRA.Mods.Common.Activities
// Move to the target destination
if (aircraft != null)
{
// Queue the activity even if already landed in case self.Location != destination
QueueChild(self, new Land(self, destination, unloadRange));
takeOffAfterUnload = !aircraft.AtLandAltitude;
}
else
{
var cell = self.World.Map.Clamp(this.self.World.Map.CellContaining(destination.CenterPosition));
@@ -135,7 +140,7 @@ namespace OpenRA.Mods.Common.Activities
if (cargo.Info.AfterUnloadDelay > 0)
QueueChild(self, new Wait(cargo.Info.AfterUnloadDelay, false), true);
if (aircraft != null && !aircraft.Info.LandWhenIdle)
if (takeOffAfterUnload)
QueueChild(self, new TakeOff(self), true);
}

View File

@@ -105,6 +105,7 @@ namespace OpenRA.Mods.Common.Traits
ConditionManager conditionManager;
int loadingToken = ConditionManager.InvalidConditionToken;
Stack<int> loadedTokens = new Stack<int>();
bool takeOffAfterLoad;
CPos currentCell;
public IEnumerable<CPos> CurrentAdjacentCells { get; private set; }
@@ -280,7 +281,10 @@ namespace OpenRA.Mods.Common.Traits
var air = self.TraitOrDefault<Aircraft>();
if (air != null && !air.AtLandAltitude)
{
takeOffAfterLoad = true;
self.QueueActivity(new Land(self));
}
self.QueueActivity(new WaitFor(() => state != State.Locked, false));
return true;
@@ -294,9 +298,10 @@ namespace OpenRA.Mods.Common.Traits
state = State.Free;
self.QueueActivity(new Wait(Info.AfterLoadDelay, false));
var air = self.TraitOrDefault<Aircraft>();
if (air != null)
if (takeOffAfterLoad)
self.QueueActivity(new TakeOff(self));
takeOffAfterLoad = false;
}
public string CursorForOrder(Actor self, Order order)