From f23729511d20c167c4d4bfbd5e2e9e60c546daf5 Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Thu, 25 May 2023 00:04:15 -0400 Subject: [PATCH] Make weapon arcs follow the player (#16796) --- .../Weapons/Melee/MeleeWeaponSystem.Effects.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Content.Client/Weapons/Melee/MeleeWeaponSystem.Effects.cs b/Content.Client/Weapons/Melee/MeleeWeaponSystem.Effects.cs index e64545bc95..486c1df3af 100644 --- a/Content.Client/Weapons/Melee/MeleeWeaponSystem.Effects.cs +++ b/Content.Client/Weapons/Melee/MeleeWeaponSystem.Effects.cs @@ -140,23 +140,26 @@ public sealed partial class MeleeWeaponSystem sprite.Rotation = localPos.ToWorldAngle(); var distance = Math.Clamp(localPos.Length / 2f, 0.2f, 1f); + var xformQuery = GetEntityQuery(); + var xform = xformQuery.GetComponent(animationUid); + switch (arcComponent.Animation) { case WeaponArcAnimation.Slash: _animation.Play(animationUid, GetSlashAnimation(sprite, angle), SlashAnimationKey); + TransformSystem.SetParent(animationUid, xform, user, userXform); if (arcComponent.Fadeout) _animation.Play(animationUid, GetFadeAnimation(sprite, 0.065f, 0.065f + 0.05f), FadeAnimationKey); break; case WeaponArcAnimation.Thrust: _animation.Play(animationUid, GetThrustAnimation(sprite, distance), ThrustAnimationKey); + TransformSystem.SetParent(animationUid, xform, user, userXform); if (arcComponent.Fadeout) _animation.Play(animationUid, GetFadeAnimation(sprite, 0.05f, 0.15f), FadeAnimationKey); break; case WeaponArcAnimation.None: - var xformQuery = GetEntityQuery(); var (mapPos, mapRot) = TransformSystem.GetWorldPositionRotation(userXform, xformQuery); - var xform = xformQuery.GetComponent(animationUid); - xform.AttachToGridOrMap(); + TransformSystem.AttachToGridOrMap(animationUid, xform); var worldPos = mapPos + (mapRot - userXform.LocalRotation).RotateVec(localPos); var newLocalPos = TransformSystem.GetInvWorldMatrix(xform.ParentUid, xformQuery).Transform(worldPos); TransformSystem.SetLocalPositionNoLerp(xform, newLocalPos);