Remove Resupply re-queueing hack from Aircraft
By preventing that other traits can remotely cancel Resupply or ReturnToBase.
This commit is contained in:
@@ -675,23 +675,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
protected virtual void OnBecomingIdle(Actor self)
|
protected virtual void OnBecomingIdle(Actor self)
|
||||||
{
|
{
|
||||||
var altitude = self.World.Map.DistanceAboveTerrain(CenterPosition);
|
|
||||||
var atLandAltitude = altitude == LandAltitude;
|
|
||||||
|
|
||||||
// Work-around to prevent players from accidentally canceling resupply by pressing 'Stop',
|
|
||||||
// by re-queueing Resupply as long as resupply hasn't finished and aircraft is still on resupplier.
|
|
||||||
// TODO: Investigate moving this back to ResolveOrder's "Stop" handling,
|
|
||||||
// once conflicts with other traits' "Stop" orders have been fixed.
|
|
||||||
if (atLandAltitude)
|
|
||||||
{
|
|
||||||
var host = GetActorBelow();
|
|
||||||
if (host != null && (CanRearmAt(host) || CanRepairAt(host)))
|
|
||||||
{
|
|
||||||
self.QueueActivity(new Resupply(self, host, WDist.Zero));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Info.IdleBehavior == IdleBehaviorType.LeaveMap)
|
if (Info.IdleBehavior == IdleBehaviorType.LeaveMap)
|
||||||
{
|
{
|
||||||
self.QueueActivity(new FlyOffMap(self));
|
self.QueueActivity(new FlyOffMap(self));
|
||||||
@@ -701,16 +684,17 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.QueueActivity(new ReturnToBase(self, null, !Info.TakeOffOnResupply));
|
self.QueueActivity(new ReturnToBase(self, null, !Info.TakeOffOnResupply));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (atLandAltitude)
|
var dat = self.World.Map.DistanceAboveTerrain(CenterPosition);
|
||||||
|
if (dat == LandAltitude)
|
||||||
{
|
{
|
||||||
if (!CanLand(self.Location) && ReservedActor == null)
|
if (!CanLand(self.Location) && ReservedActor == null)
|
||||||
self.QueueActivity(new TakeOff(self));
|
self.QueueActivity(new TakeOff(self));
|
||||||
|
|
||||||
// All remaining idle behaviors rely on not being atLandAltitude, so unconditionally return
|
// All remaining idle behaviors rely on not being at LandAltitude, so unconditionally return
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Info.IdleBehavior != IdleBehaviorType.Land && altitude != Info.CruiseAltitude)
|
if (Info.IdleBehavior != IdleBehaviorType.Land && dat != Info.CruiseAltitude)
|
||||||
self.QueueActivity(new TakeOff(self));
|
self.QueueActivity(new TakeOff(self));
|
||||||
else if (Info.IdleBehavior == IdleBehaviorType.Land && Info.LandableTerrainTypes.Count > 0)
|
else if (Info.IdleBehavior == IdleBehaviorType.Land && Info.LandableTerrainTypes.Count > 0)
|
||||||
self.QueueActivity(new Land(self));
|
self.QueueActivity(new Land(self));
|
||||||
@@ -1034,13 +1018,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
else if (orderString == "Stop")
|
else if (orderString == "Stop")
|
||||||
{
|
{
|
||||||
self.CancelActivity();
|
// We don't want the Stop order to cancel a running Resupply activity.
|
||||||
|
// Resupply is always either the main activity or a child of ReturnToBase.
|
||||||
// HACK: If the player accidentally pressed 'Stop', we don't want this to cancel reservation.
|
if (self.CurrentActivity is Resupply ||
|
||||||
// If unreserving is actually desired despite an actor below, it should be triggered from OnBecomingIdle.
|
(self.CurrentActivity is ReturnToBase && GetActorBelow() != null))
|
||||||
if (GetActorBelow() != null)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
self.CancelActivity();
|
||||||
UnReserve();
|
UnReserve();
|
||||||
}
|
}
|
||||||
else if (orderString == "ReturnToBase" && rearmable != null && rearmable.Info.RearmActors.Any())
|
else if (orderString == "ReturnToBase" && rearmable != null && rearmable.Info.RearmActors.Any())
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
|
using OpenRA.Mods.Common.Activities;
|
||||||
using OpenRA.Mods.Common.Warheads;
|
using OpenRA.Mods.Common.Warheads;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Support;
|
using OpenRA.Support;
|
||||||
@@ -206,6 +207,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
// Some 3rd-party mods rely on this being public
|
// Some 3rd-party mods rely on this being public
|
||||||
public virtual void OnStopOrder(Actor self)
|
public virtual void OnStopOrder(Actor self)
|
||||||
{
|
{
|
||||||
|
// We don't want Stop orders from traits other than Mobile or Aircraft to cancel Resupply activity.
|
||||||
|
// Resupply is always either the main activity or a child of ReturnToBase.
|
||||||
|
// TODO: This should generally only cancel activities queued by this trait.
|
||||||
|
if (self.CurrentActivity == null || self.CurrentActivity is Resupply || self.CurrentActivity is ReturnToBase)
|
||||||
|
return;
|
||||||
|
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,9 +116,16 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (currentTransform == null)
|
if (currentTransform == null)
|
||||||
self.QueueActivity(order.Queued, activity);
|
self.QueueActivity(order.Queued, activity);
|
||||||
}
|
}
|
||||||
|
else if (order.OrderString == "Stop")
|
||||||
|
{
|
||||||
|
// We don't want Stop orders from traits other than Mobile or Aircraft to cancel Resupply activity.
|
||||||
|
// Resupply is always either the main activity or a child of ReturnToBase.
|
||||||
|
// TODO: This should generally only cancel activities queued by this trait.
|
||||||
|
if (self.CurrentActivity == null || self.CurrentActivity is Resupply || self.CurrentActivity is ReturnToBase)
|
||||||
|
return;
|
||||||
|
|
||||||
if (order.OrderString == "Stop")
|
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string IOrderVoice.VoicePhraseForOrder(Actor self, Order order)
|
string IOrderVoice.VoicePhraseForOrder(Actor self, Order order)
|
||||||
|
|||||||
@@ -804,6 +804,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.QueueActivity(order.Queued, WrapMove(new Move(self, cell, WDist.FromCells(8), null, true)));
|
self.QueueActivity(order.Queued, WrapMove(new Move(self, cell, WDist.FromCells(8), null, true)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: This should only cancel activities queued by this trait
|
||||||
if (order.OrderString == "Stop")
|
if (order.OrderString == "Stop")
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user