diff --git a/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs b/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs index daefa7c8c9..1a4b1212ee 100644 --- a/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs @@ -21,8 +21,7 @@ namespace Content.Client.GameObjects.EntitySystems public override void Initialize() { - SubscribeNetworkEvent(PlayWeaponArc); - SubscribeNetworkEvent(PlayWeapon); + SubscribeNetworkEvent(PlayWeaponArc); } public override void FrameUpdate(float frameTime) @@ -35,7 +34,7 @@ namespace Content.Client.GameObjects.EntitySystems } } - private void PlayWeaponArc(PlayMeleeWeaponArcAnimationMessage msg) + private void PlayWeaponArc(PlayMeleeWeaponAnimationMessage msg) { if (!_prototypeManager.TryIndex(msg.ArcPrototype, out MeleeWeaponAnimationPrototype weaponArc)) { @@ -81,32 +80,5 @@ namespace Content.Client.GameObjects.EntitySystems }); } } - - private void PlayWeapon(PlayMeleeWeaponAnimationMessage msg) - { - var attacker = EntityManager.GetEntity(msg.Attacker); - - var lunge = attacker.EnsureComponent(); - lunge.SetData(msg.Angle); - - if (!EntityManager.TryGetEntity(msg.Hit, out var hitEntity) - || !hitEntity.TryGetComponent(out ISpriteComponent sprite)) - { - return; - } - - var originalColor = sprite.Color; - var newColor = Color.Red * originalColor; - sprite.Color = newColor; - - Timer.Spawn(100, () => - { - // Only reset back to the original color if something else didn't change the color in the mean time. - if (sprite.Color == newColor) - { - sprite.Color = originalColor; - } - }); - } } } diff --git a/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs b/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs index 7f4f536b0f..06d4338b7c 100644 --- a/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs @@ -36,6 +36,9 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee public float ArcCooldownTime { get; private set; } = 1f; public float CooldownTime { get; private set; } = 0.5f; + [ViewVariables(VVAccess.ReadWrite)] + public string ClickArc { get; set; } + [ViewVariables(VVAccess.ReadWrite)] public string Arc { get; set; } @@ -59,6 +62,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee serializer.DataField(this, x => x.Range, "range", 1); serializer.DataField(this, x => x.ArcWidth, "arcwidth", 90); serializer.DataField(this, x => x.Arc, "arc", "default"); + serializer.DataField(this, x => x.ClickArc, "clickArc", "punch"); serializer.DataField(this, x => x._hitSound, "hitSound", "/Audio/Weapons/genhit1.ogg"); serializer.DataField(this, x => x._missSound, "hitSound", "/Audio/Weapons/punchmiss.ogg"); serializer.DataField(this, x => x.ArcCooldownTime, "arcCooldownTime", 1f); @@ -159,11 +163,16 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee damageComponent.ChangeDamage(DamageType, Damage, false, Owner); } - if (!OnHitEntities(new[] {target}, eventArgs)) + var targets = new[] {target}; + + if (!OnHitEntities(targets, eventArgs)) return true; - var sys = _entitySystemManager.GetEntitySystem(); - sys.SendAnimation(angle, eventArgs.User, target); + if (ClickArc != null) + { + var sys = _entitySystemManager.GetEntitySystem(); + sys.SendAnimation(ClickArc, angle, eventArgs.User, targets); + } _lastAttackTime = curTime; _cooldownEnd = _lastAttackTime + TimeSpan.FromSeconds(CooldownTime); diff --git a/Content.Server/GameObjects/EntitySystems/MeleeWeaponSystem.cs b/Content.Server/GameObjects/EntitySystems/MeleeWeaponSystem.cs index 986a278535..82ba72537a 100644 --- a/Content.Server/GameObjects/EntitySystems/MeleeWeaponSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/MeleeWeaponSystem.cs @@ -11,13 +11,8 @@ namespace Content.Server.GameObjects.EntitySystems { public void SendAnimation(string arc, Angle angle, IEntity attacker, IEnumerable hits) { - RaiseNetworkEvent(new MeleeWeaponSystemMessages.PlayMeleeWeaponArcAnimationMessage(arc, angle, attacker.Uid, + RaiseNetworkEvent(new MeleeWeaponSystemMessages.PlayMeleeWeaponAnimationMessage(arc, angle, attacker.Uid, hits.Select(e => e.Uid).ToList())); } - - public void SendAnimation(Angle angle, IEntity attacker, IEntity hit) - { - RaiseNetworkEvent(new MeleeWeaponSystemMessages.PlayMeleeWeaponAnimationMessage(angle, attacker.Uid, hit.Uid)); - } } } diff --git a/Content.Shared/GameObjects/EntitySystemMessages/MeleeWeaponSystemMessages.cs b/Content.Shared/GameObjects/EntitySystemMessages/MeleeWeaponSystemMessages.cs index 849ba09936..989defae06 100644 --- a/Content.Shared/GameObjects/EntitySystemMessages/MeleeWeaponSystemMessages.cs +++ b/Content.Shared/GameObjects/EntitySystemMessages/MeleeWeaponSystemMessages.cs @@ -9,9 +9,9 @@ namespace Content.Shared.GameObjects.EntitySystemMessages public static class MeleeWeaponSystemMessages { [Serializable, NetSerializable] - public sealed class PlayMeleeWeaponArcAnimationMessage : EntitySystemMessage + public sealed class PlayMeleeWeaponAnimationMessage : EntitySystemMessage { - public PlayMeleeWeaponArcAnimationMessage(string arcPrototype, Angle angle, EntityUid attacker, List hits) + public PlayMeleeWeaponAnimationMessage(string arcPrototype, Angle angle, EntityUid attacker, List hits) { ArcPrototype = arcPrototype; Angle = angle; @@ -24,19 +24,5 @@ namespace Content.Shared.GameObjects.EntitySystemMessages public EntityUid Attacker { get; } public List Hits { get; } } - - [Serializable, NetSerializable] - public sealed class PlayMeleeWeaponAnimationMessage : EntitySystemMessage - { - public PlayMeleeWeaponAnimationMessage(Angle angle, EntityUid attacker, EntityUid hit) - { - Attacker = attacker; - Hit = hit; - } - - public Angle Angle { get; } - public EntityUid Attacker { get; } - public EntityUid Hit { get; } - } } }