(965abc29d) If the target sub is not the same as the current sub, need to take the difference into account in sim positions.

This commit is contained in:
Joonas Rikkonen
2019-05-18 17:17:36 +03:00
parent 6055f10c5a
commit f077a92f5e
4 changed files with 84 additions and 118 deletions
@@ -114,11 +114,23 @@ namespace Barotrauma
{
Vector2 currTargetSimPos = Vector2.Zero;
currTargetSimPos = Target.SimPosition;
//if character is inside the sub and target isn't, transform the position
if (character.Submarine != null && Target.Submarine == null)
// Take the sub position into account in the sim pos
if (character.Submarine == null && Target.Submarine != null)
{
currTargetSimPos += Target.Submarine.SimPosition;
}
else if (character.Submarine != null && Target.Submarine == null)
{
currTargetSimPos -= character.Submarine.SimPosition;
}
else if (character.Submarine != Target.Submarine)
{
if (character.Submarine != null && Target.Submarine != null)
{
Vector2 diff = character.Submarine.SimPosition - Target.Submarine.SimPosition;
currTargetSimPos -= diff;
}
}
character.AIController.SteeringManager.SteeringSeek(currTargetSimPos);
if (getDivingGearIfNeeded)
{