diff --git a/OpenRA.Mods.Common/Activities/Enter.cs b/OpenRA.Mods.Common/Activities/Enter.cs index da84b55710..4ee5237955 100644 --- a/OpenRA.Mods.Common/Activities/Enter.cs +++ b/OpenRA.Mods.Common/Activities/Enter.cs @@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Activities case EnterState.Entering: { // Check that we reached the requested position - var targetPos = target.Positions.ClosestToWithPathFrom(self); + var targetPos = target.Positions.ClosestToIgnoringPath(self.CenterPosition); if (!IsCanceling && self.CenterPosition == targetPos && target.Type == TargetType.Actor) OnEnterComplete(self, target.Actor); diff --git a/OpenRA.Mods.Common/Activities/Move/LocalMoveIntoTarget.cs b/OpenRA.Mods.Common/Activities/Move/LocalMoveIntoTarget.cs index a3958e1854..56c5a906c0 100644 --- a/OpenRA.Mods.Common/Activities/Move/LocalMoveIntoTarget.cs +++ b/OpenRA.Mods.Common/Activities/Move/LocalMoveIntoTarget.cs @@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Activities readonly Target target; readonly Color? targetLineColor; readonly WDist targetMovementThreshold; - WPos? targetStartPos; + WPos targetStartPos; public LocalMoveIntoTarget(Actor self, in Target target, WDist targetMovementThreshold, Color? targetLineColor = null) { @@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Activities protected override void OnFirstRun(Actor self) { - targetStartPos = target.Positions.ClosestToWithPathFrom(self); + targetStartPos = target.Positions.ClosestToIgnoringPath(self.CenterPosition); } public override bool Tick(Actor self) @@ -47,17 +47,14 @@ namespace OpenRA.Mods.Common.Activities return false; var currentPos = self.CenterPosition; - var targetPos = target.Positions.ClosestToWithPathFrom(self); - - if (targetStartPos == null || targetPos == null) - return true; + var targetPos = target.Positions.ClosestToIgnoringPath(currentPos); // Give up if the target has moved too far - if (targetMovementThreshold > WDist.Zero && (targetPos.Value - targetStartPos.Value).LengthSquared > targetMovementThreshold.LengthSquared) + if (targetMovementThreshold > WDist.Zero && (targetPos - targetStartPos).LengthSquared > targetMovementThreshold.LengthSquared) return true; // Turn if required - var delta = targetPos.Value - currentPos; + var delta = targetPos - currentPos; var facing = delta.HorizontalLengthSquared != 0 ? delta.Yaw : mobile.Facing; if (facing != mobile.Facing) { @@ -69,7 +66,7 @@ namespace OpenRA.Mods.Common.Activities var speed = mobile.MovementSpeedForCell(self.Location); if (delta.LengthSquared <= speed * speed) { - mobile.SetCenterPosition(self, targetPos.Value); + mobile.SetCenterPosition(self, targetPos); return true; }