(f825eae18) Fix follow objective not keeping the distance.

This commit is contained in:
Joonas Rikkonen
2019-05-18 17:30:12 +03:00
parent 3660df1906
commit 2945d103f9
2 changed files with 84 additions and 100 deletions
@@ -159,7 +159,6 @@ namespace Barotrauma
// First check the distance
// Then the custom condition
// And finally check if can interact (heaviest)
if (repeat) { return false; }
if (isCompleted) { return true; }
if (Target == null)
{
@@ -167,7 +166,16 @@ namespace Barotrauma
return false;
}
bool closeEnough = Vector2.DistanceSquared(Target.WorldPosition, character.WorldPosition) < CloseEnough * CloseEnough;
if (closeEnough)
if (repeat)
{
if (closeEnough)
{
character.AIController.SteeringManager.Reset();
character.AnimController.TargetDir = Target.WorldPosition.X > character.WorldPosition.X ? Direction.Right : Direction.Left;
}
return false;
}
else if (closeEnough)
{
if (customCondition == null || customCondition())
{
@@ -175,7 +183,7 @@ namespace Barotrauma
{
if (character.CanInteractWith(item, out _, checkLinked: false)) { isCompleted = true; }
}
else if (Target is Character targetCharacter && !FollowControlledCharacter)
else if (Target is Character targetCharacter)
{
if (character.CanInteractWith(targetCharacter, CloseEnough)) { isCompleted = true; }
}