From b38b15253465c390f7e7cf4bb8efd20d3058e37d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Aguilera=20Puerto?= Date: Mon, 12 Oct 2020 13:17:38 +0200 Subject: [PATCH] Click attack arcs no longer follow the player. Fixes #2079. --- .../Weapons/Melee/MeleeWeaponArcAnimationComponent.cs | 5 +++-- .../GameObjects/EntitySystems/MeleeWeaponSystem.cs | 2 +- .../Components/Weapon/Melee/MeleeWeaponComponent.cs | 2 +- .../GameObjects/EntitySystems/MeleeWeaponSystem.cs | 4 ++-- .../EntitySystemMessages/MeleeWeaponSystemMessages.cs | 4 +++- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Content.Client/GameObjects/Components/Weapons/Melee/MeleeWeaponArcAnimationComponent.cs b/Content.Client/GameObjects/Components/Weapons/Melee/MeleeWeaponArcAnimationComponent.cs index ff166c8800..4536701926 100644 --- a/Content.Client/GameObjects/Components/Weapons/Melee/MeleeWeaponArcAnimationComponent.cs +++ b/Content.Client/GameObjects/Components/Weapons/Melee/MeleeWeaponArcAnimationComponent.cs @@ -25,12 +25,13 @@ namespace Content.Client.GameObjects.Components.Weapons.Melee _sprite = Owner.GetComponent(); } - public void SetData(MeleeWeaponAnimationPrototype prototype, Angle baseAngle, IEntity attacker) + public void SetData(MeleeWeaponAnimationPrototype prototype, Angle baseAngle, IEntity attacker, bool followAttacker = true) { _meleeWeaponAnimation = prototype; _sprite.AddLayer(new RSI.StateId(prototype.State)); _baseAngle = baseAngle; - Owner.Transform.AttachParent(attacker); + if(followAttacker) + Owner.Transform.AttachParent(attacker); } internal void Update(float frameTime) diff --git a/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs b/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs index d337fef5b5..d2280535e7 100644 --- a/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs @@ -56,7 +56,7 @@ namespace Content.Client.GameObjects.EntitySystems entity.Transform.LocalRotation = msg.Angle; var weaponArcAnimation = entity.GetComponent(); - weaponArcAnimation.SetData(weaponArc, msg.Angle, attacker); + weaponArcAnimation.SetData(weaponArc, msg.Angle, attacker, msg.ArcFollowAttacker); // Due to ISpriteComponent limitations, weapons that don't use an RSI won't have this effect. if (EntityManager.TryGetEntity(msg.Source, out var source) && msg.TextureEffect && source.TryGetComponent(out ISpriteComponent sourceSprite) diff --git a/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs b/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs index 6dcb6adfdb..cd9e7c0edb 100644 --- a/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs @@ -173,7 +173,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee if (ClickArc != null) { var sys = EntitySystem.Get(); - sys.SendAnimation(ClickArc, angle, eventArgs.User, Owner, targets, ClickAttackEffect); + sys.SendAnimation(ClickArc, angle, eventArgs.User, Owner, targets, ClickAttackEffect, false); } _lastAttackTime = curTime; diff --git a/Content.Server/GameObjects/EntitySystems/MeleeWeaponSystem.cs b/Content.Server/GameObjects/EntitySystems/MeleeWeaponSystem.cs index 0613f1ec58..b8d470975c 100644 --- a/Content.Server/GameObjects/EntitySystems/MeleeWeaponSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/MeleeWeaponSystem.cs @@ -9,10 +9,10 @@ namespace Content.Server.GameObjects.EntitySystems { public sealed class MeleeWeaponSystem : EntitySystem { - public void SendAnimation(string arc, Angle angle, IEntity attacker, IEntity source, IEnumerable hits, bool textureEffect = false) + public void SendAnimation(string arc, Angle angle, IEntity attacker, IEntity source, IEnumerable hits, bool textureEffect = false, bool arcFollowAttacker = true) { RaiseNetworkEvent(new MeleeWeaponSystemMessages.PlayMeleeWeaponAnimationMessage(arc, angle, attacker.Uid, source.Uid, - hits.Select(e => e.Uid).ToList(), textureEffect)); + hits.Select(e => e.Uid).ToList(), textureEffect, arcFollowAttacker)); } } } diff --git a/Content.Shared/GameObjects/EntitySystemMessages/MeleeWeaponSystemMessages.cs b/Content.Shared/GameObjects/EntitySystemMessages/MeleeWeaponSystemMessages.cs index 2f1bd231fa..1d16d09083 100644 --- a/Content.Shared/GameObjects/EntitySystemMessages/MeleeWeaponSystemMessages.cs +++ b/Content.Shared/GameObjects/EntitySystemMessages/MeleeWeaponSystemMessages.cs @@ -11,7 +11,7 @@ namespace Content.Shared.GameObjects.EntitySystemMessages [Serializable, NetSerializable] public sealed class PlayMeleeWeaponAnimationMessage : EntitySystemMessage { - public PlayMeleeWeaponAnimationMessage(string arcPrototype, Angle angle, EntityUid attacker, EntityUid source, List hits, bool textureEffect = false) + public PlayMeleeWeaponAnimationMessage(string arcPrototype, Angle angle, EntityUid attacker, EntityUid source, List hits, bool textureEffect = false, bool arcFollowAttacker = true) { ArcPrototype = arcPrototype; Angle = angle; @@ -19,6 +19,7 @@ namespace Content.Shared.GameObjects.EntitySystemMessages Source = source; Hits = hits; TextureEffect = textureEffect; + ArcFollowAttacker = arcFollowAttacker; } public string ArcPrototype { get; } @@ -27,6 +28,7 @@ namespace Content.Shared.GameObjects.EntitySystemMessages public EntityUid Source { get; } public List Hits { get; } public bool TextureEffect { get; } + public bool ArcFollowAttacker { get; } } } }