Fix clients acquiring hosts on order creations
This commit is contained in:
@@ -24,16 +24,37 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
IDockHost dockHost;
|
IDockHost dockHost;
|
||||||
readonly INotifyDockClientMoving[] notifyDockClientMoving;
|
readonly INotifyDockClientMoving[] notifyDockClientMoving;
|
||||||
readonly MoveCooldownHelper moveCooldownHelper;
|
readonly MoveCooldownHelper moveCooldownHelper;
|
||||||
|
readonly bool forceEnter;
|
||||||
|
readonly bool ignoreOccupancy;
|
||||||
|
|
||||||
public MoveToDock(Actor self, Actor dockHostActor = null, IDockHost dockHost = null)
|
public MoveToDock(Actor self, Actor dockHostActor = null, IDockHost dockHost = null,
|
||||||
|
bool forceEnter = false, bool ignoreOccupancy = false)
|
||||||
{
|
{
|
||||||
dockClient = self.Trait<DockClientManager>();
|
dockClient = self.Trait<DockClientManager>();
|
||||||
this.dockHostActor = dockHostActor;
|
this.dockHostActor = dockHostActor;
|
||||||
this.dockHost = dockHost;
|
this.dockHost = dockHost;
|
||||||
|
this.forceEnter = forceEnter;
|
||||||
|
this.ignoreOccupancy = ignoreOccupancy;
|
||||||
notifyDockClientMoving = self.TraitsImplementing<INotifyDockClientMoving>().ToArray();
|
notifyDockClientMoving = self.TraitsImplementing<INotifyDockClientMoving>().ToArray();
|
||||||
moveCooldownHelper = new MoveCooldownHelper(self.World, self.Trait<IMove>() as Mobile) { RetryIfDestinationBlocked = true };
|
moveCooldownHelper = new MoveCooldownHelper(self.World, self.Trait<IMove>() as Mobile) { RetryIfDestinationBlocked = true };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnFirstRun(Actor self)
|
||||||
|
{
|
||||||
|
if (IsCanceling || dockClient.IsTraitDisabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// We were ordered to dock to an actor but host was unspecified.
|
||||||
|
if (dockHostActor != null && dockHost == null)
|
||||||
|
{
|
||||||
|
var link = dockClient.AvailableDockHosts(dockHostActor, default, forceEnter, ignoreOccupancy)
|
||||||
|
.ClosestDock(self, dockClient);
|
||||||
|
|
||||||
|
if (link.HasValue)
|
||||||
|
dockHost = link.Value.Trait;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override bool Tick(Actor self)
|
public override bool Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (IsCanceling)
|
if (IsCanceling)
|
||||||
|
|||||||
@@ -177,16 +177,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (target.Type != TargetType.Actor)
|
if (target.Type != TargetType.Actor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (IsTraitDisabled)
|
self.QueueActivity(order.Queued, new MoveToDock(
|
||||||
return;
|
self,
|
||||||
|
target.Actor,
|
||||||
|
null,
|
||||||
|
order.OrderString == "ForceDock",
|
||||||
|
true));
|
||||||
|
|
||||||
var dock = AvailableDockHosts(target.Actor, default, order.OrderString == "ForceDock", true)
|
|
||||||
.ClosestDock(self, this);
|
|
||||||
|
|
||||||
if (!dock.HasValue)
|
|
||||||
return;
|
|
||||||
|
|
||||||
self.QueueActivity(order.Queued, new MoveToDock(self, dock.Value.Actor, dock.Value.Trait));
|
|
||||||
self.ShowTargetLines();
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user