Fixed creatures seeking towards an incorrect position when trying to eat something (causing larger creatures like threshers and coelanths to swim around the target without ever reaching it), extra check for removed entities in AITarget

This commit is contained in:
Joonas Rikkonen
2017-11-01 20:58:37 +02:00
parent 69d0fac69d
commit ec020f43d3
2 changed files with 4 additions and 5 deletions

View File

@@ -33,7 +33,7 @@ namespace Barotrauma
{
get
{
if (Entity == null)
if (Entity == null || Entity.Removed)
{
#if DEBUG
DebugConsole.ThrowError("Attempted to access a removed AITarget\n" + Environment.StackTrace);
@@ -49,7 +49,7 @@ namespace Barotrauma
{
get
{
if (Entity == null)
if (Entity == null || Entity.Removed)
{
#if DEBUG
DebugConsole.ThrowError("Attempted to access a removed AITarget\n" + Environment.StackTrace);

View File

@@ -533,8 +533,7 @@ namespace Barotrauma
}
Vector2 attackSimPosition = Character.Submarine == null ? ConvertUnits.ToSimUnits(selectedAiTarget.WorldPosition) : selectedAiTarget.SimPosition;
Vector2 limbDiff = attackSimPosition - mouthPos;
float limbDist = limbDiff.Length();
if (limbDist < 1.0f)
@@ -577,7 +576,7 @@ namespace Barotrauma
}
else
{
steeringManager.SteeringSeek(attackSimPosition + (mouthPos - SimPosition), 3);
steeringManager.SteeringSeek(attackSimPosition - (mouthPos - SimPosition), 3);
}
}