From a7565b7651393ac5af429a94b846bd260c43d935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Aguilera=20Puerto?= Date: Tue, 7 Jul 2020 23:12:12 +0200 Subject: [PATCH] Fix stunbaton issues --- .../Weapon/Melee/StunbatonComponent.cs | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Content.Server/GameObjects/Components/Weapon/Melee/StunbatonComponent.cs b/Content.Server/GameObjects/Components/Weapon/Melee/StunbatonComponent.cs index 6914d71baf..9d77629431 100644 --- a/Content.Server/GameObjects/Components/Weapon/Melee/StunbatonComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Melee/StunbatonComponent.cs @@ -52,7 +52,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee [ViewVariables(VVAccess.ReadWrite)] private float _slowdownTime = 5f; - [ViewVariables(VVAccess.ReadWrite)] public float EnergyPerUse { get; set; } = 1000; + [ViewVariables(VVAccess.ReadWrite)] public float EnergyPerUse { get; set; } = 50; [ViewVariables] public bool Activated => _activated; @@ -88,13 +88,12 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee protected override bool OnHitEntities(IReadOnlyList entities, AttackEventArgs eventArgs) { - var cell = Cell; - if (!Activated || entities.Count == 0 || cell == null) - return false; - if (!cell.TryUseCharge(EnergyPerUse)) - { - return false; - } + if (!Activated || entities.Count == 0 || Cell == null) + return true; + + if (!Cell.TryUseCharge(EnergyPerUse)) + return true; + EntitySystem.Get().PlayAtCoords("/Audio/Weapons/egloves.ogg", Owner.Transform.GridPosition, AudioHelpers.WithVariation(0.25f)); foreach (var entity in entities) @@ -112,11 +111,11 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee else stunnable.Slowdown(_slowdownTime); } - if(cell.CurrentCharge < EnergyPerUse) - { - EntitySystem.Get().PlayAtCoords(AudioHelpers.GetRandomFileFromSoundCollection("sparks"), Owner.Transform.GridPosition, AudioHelpers.WithVariation(0.25f)); - TurnOff(); - } + + if (!(Cell.CurrentCharge < EnergyPerUse)) return true; + + EntitySystem.Get().PlayAtCoords(AudioHelpers.GetRandomFileFromSoundCollection("sparks"), Owner.Transform.GridPosition, AudioHelpers.WithVariation(0.25f)); + TurnOff(); return true; }