Fix harvesters refusing to queue dock orders whenn empty
(cherry picked from commit 19040126046a53fd5092515f2a4895fdd5c9c87a)
This commit is contained in:
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Info.EnterCursor,
|
||||
Info.EnterBlockedCursor,
|
||||
() => Info.RequiresForceMove,
|
||||
DockingPossible,
|
||||
CanQueueDockAt,
|
||||
CanDockAt);
|
||||
}
|
||||
}
|
||||
@@ -109,9 +109,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
string IOrderVoice.VoicePhraseForOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == "Dock" && CanDockAt(order.Target.Actor, false))
|
||||
return Info.Voice;
|
||||
else if (order.OrderString == "ForceDock" && CanDockAt(order.Target.Actor, true))
|
||||
if (order.Target.Type != TargetType.Actor || IsTraitDisabled)
|
||||
return null;
|
||||
|
||||
if (order.OrderString != "Dock" && order.OrderString != "ForceDock")
|
||||
return null;
|
||||
|
||||
if (CanQueueDockAt(order.Target.Actor, order.OrderString == "ForceDock", order.Queued))
|
||||
return Info.Voice;
|
||||
|
||||
return null;
|
||||
@@ -125,12 +129,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Clone of <see cref="DockClientManager.DockingPossible(Actor, bool)"/>.</summary>
|
||||
public bool DockingPossible(Actor target, bool forceEnter)
|
||||
{
|
||||
return !IsTraitDisabled && target.TraitsImplementing<DockHost>().Any(host => dockClients.Any(client => client.CanDock(host.GetDockType)));
|
||||
}
|
||||
|
||||
/// <summary>Clone of <see cref="DockClientManager.CanDockAt(Actor, bool, bool)"/>.</summary>
|
||||
public bool CanDockAt(Actor target, bool forceEnter)
|
||||
{
|
||||
@@ -140,5 +138,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return !IsTraitDisabled && target.TraitsImplementing<DockHost>().Any(
|
||||
host => dockClients.Any(client => client.CanDockAt(target, host, forceEnter, true)));
|
||||
}
|
||||
|
||||
/// <summary>Clone of <see cref="DockClientManager.CanQueueDockAt(Actor, bool, bool)"/>.</summary>
|
||||
public bool CanQueueDockAt(Actor target, bool forceEnter, bool isQueued)
|
||||
{
|
||||
if (Info.RequiresForceMove && !forceEnter)
|
||||
return false;
|
||||
|
||||
return (!IsTraitDisabled)
|
||||
&& target.TraitsImplementing<IDockHost>().Any(
|
||||
host => dockClients.Any(client => client.CanQueueDockAt(target, host, forceEnter, isQueued)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,9 +37,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public virtual bool CanDockAt(Actor hostActor, IDockHost host, bool forceEnter = false, bool ignoreOccupancy = false)
|
||||
{
|
||||
return (forceEnter || self.Owner.IsAlliedWith(hostActor.Owner)) &&
|
||||
CanDock(host.GetDockType, forceEnter) &&
|
||||
host.IsDockingPossible(self, this, ignoreOccupancy);
|
||||
return CanDock(host.GetDockType, forceEnter)
|
||||
&& host.IsDockingPossible(self, this, ignoreOccupancy);
|
||||
}
|
||||
|
||||
public virtual bool CanQueueDockAt(Actor hostActor, IDockHost host, bool forceEnter, bool isQueued)
|
||||
{
|
||||
return CanDock(host.GetDockType, true)
|
||||
&& host.IsDockingPossible(self, this, true);
|
||||
}
|
||||
|
||||
public virtual void OnDockStarted(Actor self, Actor hostActor, IDockHost host) { }
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Info.EnterCursor,
|
||||
Info.EnterBlockedCursor,
|
||||
() => requireForceMove,
|
||||
DockingPossible,
|
||||
CanQueueDockAt,
|
||||
(target, forceEnter) => CanDockAt(target, forceEnter, true));
|
||||
}
|
||||
}
|
||||
@@ -194,9 +194,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (order.Target.Type != TargetType.Actor || IsTraitDisabled)
|
||||
return null;
|
||||
|
||||
if (order.OrderString == "Dock" && CanDockAt(order.Target.Actor, false, true))
|
||||
return Info.Voice;
|
||||
else if (order.OrderString == "ForceDock" && CanDockAt(order.Target.Actor, true, true))
|
||||
if (order.OrderString != "Dock" && order.OrderString != "ForceDock")
|
||||
return null;
|
||||
|
||||
if (CanQueueDockAt(order.Target.Actor, order.OrderString == "ForceDock", order.Queued))
|
||||
return Info.Voice;
|
||||
|
||||
return null;
|
||||
@@ -225,13 +226,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
/// <summary>Do we have an enabled client with matching <paramref name="type"/>.</summary>
|
||||
public bool DockingPossible(BitSet<DockType> type, bool forceEnter = false)
|
||||
public bool CanDock(BitSet<DockType> type, bool forceEnter = false)
|
||||
{
|
||||
return !IsTraitDisabled && dockClients.Any(client => client.CanDock(type, forceEnter));
|
||||
}
|
||||
|
||||
/// <summary>Does this <paramref name="target"/> contain at least one enabled <see cref="IDockHost"/> with maching <see cref="DockType"/>.</summary>
|
||||
public bool DockingPossible(Actor target, bool forceEnter = false)
|
||||
public bool CanDock(Actor target, bool forceEnter = false)
|
||||
{
|
||||
return !IsTraitDisabled &&
|
||||
target.TraitsImplementing<IDockHost>()
|
||||
@@ -252,6 +253,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
host => dockClients.Any(client => client.CanDockAt(target, host, forceEnter, ignoreOccupancy)));
|
||||
}
|
||||
|
||||
/// <summary>Can we dock to this <paramref name="target"/>.</summary>
|
||||
public bool CanQueueDockAt(Actor target, bool forceEnter, bool isQueued)
|
||||
{
|
||||
return !IsTraitDisabled
|
||||
&& target.TraitsImplementing<IDockHost>()
|
||||
.Any(host => dockClients.Any(client => client.CanQueueDockAt(target, host, forceEnter, isQueued)));
|
||||
}
|
||||
|
||||
/// <summary>Find the closest viable <see cref="IDockHost"/>.</summary>
|
||||
/// <remarks>If <paramref name="type"/> is not set, scans all clients. Does not check if <see cref="DockClientManager"/> is enabled.</remarks>
|
||||
public TraitPair<IDockHost>? ClosestDock(IDockHost ignore, BitSet<DockType> type = default, bool forceEnter = false, bool ignoreOccupancy = false)
|
||||
@@ -292,11 +301,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly string enterCursor;
|
||||
readonly string enterBlockedCursor;
|
||||
readonly Func<bool> requireForceMove;
|
||||
readonly Func<Actor, bool, bool> canTarget;
|
||||
readonly Func<Actor, bool, bool, bool> canTarget;
|
||||
readonly Func<Actor, bool, bool> useEnterCursor;
|
||||
|
||||
public DockActorTargeter(int priority, string enterCursor, string enterBlockedCursor,
|
||||
Func<bool> requireForceMove, Func<Actor, bool, bool> canTarget, Func<Actor, bool, bool> useEnterCursor)
|
||||
Func<bool> requireForceMove, Func<Actor, bool, bool, bool> canTarget, Func<Actor, bool, bool> useEnterCursor)
|
||||
{
|
||||
OrderID = "Dock";
|
||||
OrderPriority = priority;
|
||||
@@ -325,10 +334,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (requireForceMove() && !forceEnter)
|
||||
return false;
|
||||
|
||||
if (!canTarget(target.Actor, forceEnter))
|
||||
if (!canTarget(target.Actor, forceEnter, IsQueued))
|
||||
return false;
|
||||
|
||||
cursor = useEnterCursor(target.Actor, forceEnter) ? enterCursor : enterBlockedCursor;
|
||||
cursor = IsQueued || useEnterCursor(target.Actor, forceEnter)
|
||||
? enterCursor
|
||||
: enterBlockedCursor;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -137,6 +137,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
&& (self.Owner == hostActor.Owner || (ignoreOccupancy && self.Owner.IsAlliedWith(hostActor.Owner)));
|
||||
}
|
||||
|
||||
public override bool CanQueueDockAt(Actor hostActor, IDockHost host, bool forceEnter, bool isQueued)
|
||||
{
|
||||
return base.CanQueueDockAt(hostActor, host, forceEnter, isQueued)
|
||||
&& self.Owner.IsAlliedWith(hostActor.Owner);
|
||||
}
|
||||
|
||||
void UpdateCondition(Actor self)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Info.EmptyCondition))
|
||||
|
||||
@@ -220,19 +220,26 @@ namespace OpenRA.Mods.Common.Traits
|
||||
bool OnDockTick(Actor self, Actor hostActor, IDockHost dock);
|
||||
void OnDockCompleted(Actor self, Actor hostActor, IDockHost host);
|
||||
|
||||
/// <summary>Is this client allowed to dock.</summary>
|
||||
/// <summary>Are we allowed to dock.</summary>
|
||||
/// <remarks>
|
||||
/// Does not check if <see cref="Traits.DockClientManager"/> is enabled.
|
||||
/// Function should only be called from within <see cref="IDockClient"/> or <see cref="Traits.DockClientManager"/>.
|
||||
/// </remarks>
|
||||
bool CanDock(BitSet<DockType> type, bool forceEnter = false);
|
||||
|
||||
/// <summary>Is this client allowed to dock to <paramref name="host"/>.</summary>
|
||||
/// <summary>Are we allowed to dock to this <paramref name="host"/>.</summary>
|
||||
/// <remarks>
|
||||
/// Does not check if <see cref="Traits.DockClientManager"/> is enabled.
|
||||
/// Function should only be called from within <see cref="IDockClient"/> or <see cref="Traits.DockClientManager"/>.
|
||||
/// </remarks>
|
||||
bool CanDockAt(Actor hostActor, IDockHost host, bool forceEnter = false, bool ignoreOccupancy = false);
|
||||
|
||||
/// <summary>Are we allowed to give a docking order for this <paramref name="host"/>.</summary>
|
||||
/// <remarks>
|
||||
/// Does not check if <see cref="Traits.DockClientManager"/> is enabled.
|
||||
/// Function should only be called from within <see cref="IDockClient"/> or <see cref="Traits.DockClientManager"/>.
|
||||
/// </remarks>
|
||||
bool CanQueueDockAt(Actor hostActor, IDockHost host, bool forceEnter, bool isQueued);
|
||||
}
|
||||
|
||||
public interface IDockHostInfo : ITraitInfoInterface { }
|
||||
|
||||
Reference in New Issue
Block a user