Navigation Menu

Skip to content

Commit

Permalink
Fix force-landed transports taking off after (un)loading passengers.
Browse files Browse the repository at this point in the history
  • Loading branch information
pchote authored and teinarss committed Jul 1, 2019
1 parent da0b24e commit 5d8b6d6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion OpenRA.Mods.Common/Activities/UnloadCargo.cs
Expand Up @@ -29,6 +29,7 @@ public class UnloadCargo : Activity
readonly WDist unloadRange;

Target destination;
bool takeOffAfterUnload;

public UnloadCargo(Actor self, WDist unloadRange, bool unloadAll = true)
: this(self, Target.Invalid, unloadRange, unloadAll)
Expand Down Expand Up @@ -74,7 +75,11 @@ protected override void OnFirstRun(Actor self)

// 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));
Expand Down Expand Up @@ -135,7 +140,7 @@ public override Activity Tick(Actor self)
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);
}

Expand Down
9 changes: 7 additions & 2 deletions OpenRA.Mods.Common/Traits/Cargo.cs
Expand Up @@ -105,6 +105,7 @@ public class Cargo : IPips, IIssueOrder, IResolveOrder, IOrderVoice, INotifyCrea
ConditionManager conditionManager;
int loadingToken = ConditionManager.InvalidConditionToken;
Stack<int> loadedTokens = new Stack<int>();
bool takeOffAfterLoad;

CPos currentCell;
public IEnumerable<CPos> CurrentAdjacentCells { get; private set; }
Expand Down Expand Up @@ -280,7 +281,10 @@ bool LockForPickup(Actor self)

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;
Expand All @@ -294,9 +298,10 @@ void ReleaseLock(Actor self)
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)
Expand Down

0 comments on commit 5d8b6d6

Please sign in to comment.