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:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user