Fix melee animation exception (#12806)

This commit is contained in:
Leon Friedrich
2022-11-30 14:40:57 +13:00
committed by GitHub
parent 4f6ead57bf
commit 5f964f02b7

View File

@@ -125,22 +125,20 @@ public sealed partial class MeleeWeaponSystem
_animation.Stop(user, MeleeLungeKey);
_animation.Play(user, lunge, MeleeLungeKey);
// Clientside entity to spawn
if (animation != null)
{
if (!TryComp<TransformComponent>(user, out var userXform))
if (localPos == Vector2.Zero || animation == null)
return;
var coords = userXform.Coordinates;
var animationUid = Spawn(animation, coords);
if (!TryComp<TransformComponent>(user, out var userXform) || userXform.MapID == MapId.Nullspace)
return;
var animationUid = Spawn(animation, userXform.Coordinates);
if (!TryComp<SpriteComponent>(animationUid, out var sprite)
|| !TryComp<WeaponArcVisualsComponent>(animationUid, out var arcComponent))
return;
if (localPos != Vector2.Zero && TryComp<SpriteComponent>(animationUid, out var sprite))
{
if (TryComp<WeaponArcVisualsComponent>(animationUid, out var arcComponent))
{
sprite.NoRotation = true;
sprite.Rotation = localPos.ToWorldAngle();
var distance = Math.Clamp(localPos.Length / 2f, 0.2f, 1f);
switch (arcComponent.Animation)
@@ -165,9 +163,6 @@ public sealed partial class MeleeWeaponSystem
break;
}
}
}
}
}
private Animation GetSlashAnimation(SpriteComponent sprite, Angle arc)
{