Make weapon arcs follow the player (#16796)
This commit is contained in:
@@ -140,23 +140,26 @@ public sealed partial class MeleeWeaponSystem
|
|||||||
sprite.Rotation = localPos.ToWorldAngle();
|
sprite.Rotation = localPos.ToWorldAngle();
|
||||||
var distance = Math.Clamp(localPos.Length / 2f, 0.2f, 1f);
|
var distance = Math.Clamp(localPos.Length / 2f, 0.2f, 1f);
|
||||||
|
|
||||||
|
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||||
|
var xform = xformQuery.GetComponent(animationUid);
|
||||||
|
|
||||||
switch (arcComponent.Animation)
|
switch (arcComponent.Animation)
|
||||||
{
|
{
|
||||||
case WeaponArcAnimation.Slash:
|
case WeaponArcAnimation.Slash:
|
||||||
_animation.Play(animationUid, GetSlashAnimation(sprite, angle), SlashAnimationKey);
|
_animation.Play(animationUid, GetSlashAnimation(sprite, angle), SlashAnimationKey);
|
||||||
|
TransformSystem.SetParent(animationUid, xform, user, userXform);
|
||||||
if (arcComponent.Fadeout)
|
if (arcComponent.Fadeout)
|
||||||
_animation.Play(animationUid, GetFadeAnimation(sprite, 0.065f, 0.065f + 0.05f), FadeAnimationKey);
|
_animation.Play(animationUid, GetFadeAnimation(sprite, 0.065f, 0.065f + 0.05f), FadeAnimationKey);
|
||||||
break;
|
break;
|
||||||
case WeaponArcAnimation.Thrust:
|
case WeaponArcAnimation.Thrust:
|
||||||
_animation.Play(animationUid, GetThrustAnimation(sprite, distance), ThrustAnimationKey);
|
_animation.Play(animationUid, GetThrustAnimation(sprite, distance), ThrustAnimationKey);
|
||||||
|
TransformSystem.SetParent(animationUid, xform, user, userXform);
|
||||||
if (arcComponent.Fadeout)
|
if (arcComponent.Fadeout)
|
||||||
_animation.Play(animationUid, GetFadeAnimation(sprite, 0.05f, 0.15f), FadeAnimationKey);
|
_animation.Play(animationUid, GetFadeAnimation(sprite, 0.05f, 0.15f), FadeAnimationKey);
|
||||||
break;
|
break;
|
||||||
case WeaponArcAnimation.None:
|
case WeaponArcAnimation.None:
|
||||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
|
||||||
var (mapPos, mapRot) = TransformSystem.GetWorldPositionRotation(userXform, xformQuery);
|
var (mapPos, mapRot) = TransformSystem.GetWorldPositionRotation(userXform, xformQuery);
|
||||||
var xform = xformQuery.GetComponent(animationUid);
|
TransformSystem.AttachToGridOrMap(animationUid, xform);
|
||||||
xform.AttachToGridOrMap();
|
|
||||||
var worldPos = mapPos + (mapRot - userXform.LocalRotation).RotateVec(localPos);
|
var worldPos = mapPos + (mapRot - userXform.LocalRotation).RotateVec(localPos);
|
||||||
var newLocalPos = TransformSystem.GetInvWorldMatrix(xform.ParentUid, xformQuery).Transform(worldPos);
|
var newLocalPos = TransformSystem.GetInvWorldMatrix(xform.ParentUid, xformQuery).Transform(worldPos);
|
||||||
TransformSystem.SetLocalPositionNoLerp(xform, newLocalPos);
|
TransformSystem.SetLocalPositionNoLerp(xform, newLocalPos);
|
||||||
|
|||||||
Reference in New Issue
Block a user