Fix units considering terrain when entering other actors
This commit is contained in:
committed by
Matthias Mailänder
parent
e0df59464e
commit
b25146265d
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user