(db7e4d6d5) Fix "crawler balling" caused by crawlers taking damage when targeting the sub and not yet latched on it.

This commit is contained in:
Joonas Rikkonen
2019-04-11 18:25:58 +03:00
parent 16cc5c8bc2
commit e7e858c05b
3 changed files with 11 additions and 10 deletions
@@ -207,10 +207,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();