(f6c34b377) Fix crawlers not reacting to any targets if properly latched on walls.

This commit is contained in:
Joonas Rikkonen
2019-04-11 18:26:42 +03:00
parent 9b0e0ab278
commit a57b7184fb
9 changed files with 41 additions and 41 deletions
@@ -54,6 +54,8 @@ namespace Barotrauma
get { return attachJoints.Count > 0; }
}
public bool IsAttachedToSub => IsAttached && attachTargetBody?.UserData is Entity entity && (entity is Submarine sub || entity?.Submarine != null);
public LatchOntoAI(XElement element, EnemyAIController enemyAI)
{
attachToWalls = element.GetAttributeBool("attachtowalls", false);
@@ -207,10 +209,10 @@ namespace Barotrauma
break;
}
if (attachTargetBody != null && deattachTimer < 0.0f)
if (IsAttached && attachTargetBody != null && deattachTimer < 0.0f)
{
Entity entity = attachTargetBody.UserData as Entity;
Submarine attachedSub = entity is Submarine ? (Submarine)entity : entity?.Submarine;
Submarine attachedSub = entity is Submarine sub ? sub : entity?.Submarine;
if (attachedSub != null)
{
float velocity = attachedSub.Velocity == Vector2.Zero ? 0.0f : attachedSub.Velocity.Length();