Fix force-landed transports taking off after (un)loading passengers.
This commit is contained in:
@@ -29,6 +29,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
readonly WDist unloadRange;
|
readonly WDist unloadRange;
|
||||||
|
|
||||||
Target destination;
|
Target destination;
|
||||||
|
bool takeOffAfterUnload;
|
||||||
|
|
||||||
public UnloadCargo(Actor self, WDist unloadRange, bool unloadAll = true)
|
public UnloadCargo(Actor self, WDist unloadRange, bool unloadAll = true)
|
||||||
: this(self, Target.Invalid, unloadRange, unloadAll)
|
: this(self, Target.Invalid, unloadRange, unloadAll)
|
||||||
@@ -74,7 +75,11 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
// Move to the target destination
|
// Move to the target destination
|
||||||
if (aircraft != null)
|
if (aircraft != null)
|
||||||
|
{
|
||||||
|
// Queue the activity even if already landed in case self.Location != destination
|
||||||
QueueChild(self, new Land(self, destination, unloadRange));
|
QueueChild(self, new Land(self, destination, unloadRange));
|
||||||
|
takeOffAfterUnload = !aircraft.AtLandAltitude;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var cell = self.World.Map.Clamp(this.self.World.Map.CellContaining(destination.CenterPosition));
|
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)
|
if (cargo.Info.AfterUnloadDelay > 0)
|
||||||
QueueChild(self, new Wait(cargo.Info.AfterUnloadDelay, false), true);
|
QueueChild(self, new Wait(cargo.Info.AfterUnloadDelay, false), true);
|
||||||
|
|
||||||
if (aircraft != null && !aircraft.Info.LandWhenIdle)
|
if (takeOffAfterUnload)
|
||||||
QueueChild(self, new TakeOff(self), true);
|
QueueChild(self, new TakeOff(self), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
ConditionManager conditionManager;
|
ConditionManager conditionManager;
|
||||||
int loadingToken = ConditionManager.InvalidConditionToken;
|
int loadingToken = ConditionManager.InvalidConditionToken;
|
||||||
Stack<int> loadedTokens = new Stack<int>();
|
Stack<int> loadedTokens = new Stack<int>();
|
||||||
|
bool takeOffAfterLoad;
|
||||||
|
|
||||||
CPos currentCell;
|
CPos currentCell;
|
||||||
public IEnumerable<CPos> CurrentAdjacentCells { get; private set; }
|
public IEnumerable<CPos> CurrentAdjacentCells { get; private set; }
|
||||||
@@ -280,7 +281,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
var air = self.TraitOrDefault<Aircraft>();
|
var air = self.TraitOrDefault<Aircraft>();
|
||||||
if (air != null && !air.AtLandAltitude)
|
if (air != null && !air.AtLandAltitude)
|
||||||
|
{
|
||||||
|
takeOffAfterLoad = true;
|
||||||
self.QueueActivity(new Land(self));
|
self.QueueActivity(new Land(self));
|
||||||
|
}
|
||||||
|
|
||||||
self.QueueActivity(new WaitFor(() => state != State.Locked, false));
|
self.QueueActivity(new WaitFor(() => state != State.Locked, false));
|
||||||
return true;
|
return true;
|
||||||
@@ -294,9 +298,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
state = State.Free;
|
state = State.Free;
|
||||||
|
|
||||||
self.QueueActivity(new Wait(Info.AfterLoadDelay, false));
|
self.QueueActivity(new Wait(Info.AfterLoadDelay, false));
|
||||||
var air = self.TraitOrDefault<Aircraft>();
|
if (takeOffAfterLoad)
|
||||||
if (air != null)
|
|
||||||
self.QueueActivity(new TakeOff(self));
|
self.QueueActivity(new TakeOff(self));
|
||||||
|
|
||||||
|
takeOffAfterLoad = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string CursorForOrder(Actor self, Order order)
|
public string CursorForOrder(Actor self, Order order)
|
||||||
|
|||||||
Reference in New Issue
Block a user