From 69c68d8f4d2a772804a1273838871dd7df6a9adc Mon Sep 17 00:00:00 2001 From: HellCatten <126400932+HellCatten@users.noreply.github.com> Date: Thu, 22 Aug 2024 09:22:00 +0300 Subject: [PATCH] Code Review problems solved --- .../_White/EmpFlashlight/EmpOnHitComponent.cs | 2 +- .../{EmpHitSystem.cs => EmpOnHitSystem.cs} | 21 ++++++++----------- .../Entities/Objects/Tools/EmpFlashlight.yml | 4 ++-- 3 files changed, 12 insertions(+), 15 deletions(-) rename Content.Server/_White/EmpFlashlight/{EmpHitSystem.cs => EmpOnHitSystem.cs} (62%) diff --git a/Content.Server/_White/EmpFlashlight/EmpOnHitComponent.cs b/Content.Server/_White/EmpFlashlight/EmpOnHitComponent.cs index 298d5dd2de..071de4ce80 100644 --- a/Content.Server/_White/EmpFlashlight/EmpOnHitComponent.cs +++ b/Content.Server/_White/EmpFlashlight/EmpOnHitComponent.cs @@ -9,7 +9,7 @@ namespace Content.Server._White.EmpFlashlight; /// Upon being triggered will EMP target. /// [RegisterComponent] -[Access(typeof(EmpHitSystem))] +[Access(typeof(EmpOnHitSystem))] public sealed partial class EmpOnHitComponent: Component { diff --git a/Content.Server/_White/EmpFlashlight/EmpHitSystem.cs b/Content.Server/_White/EmpFlashlight/EmpOnHitSystem.cs similarity index 62% rename from Content.Server/_White/EmpFlashlight/EmpHitSystem.cs rename to Content.Server/_White/EmpFlashlight/EmpOnHitSystem.cs index 7b783f54ab..9fd86c20be 100644 --- a/Content.Server/_White/EmpFlashlight/EmpHitSystem.cs +++ b/Content.Server/_White/EmpFlashlight/EmpOnHitSystem.cs @@ -1,20 +1,17 @@ -using Content.Server.Power; -using Content.Shared.Emp; -using Robust.Shared.GameObjects; -using Content.Shared.Weapons.Melee.Events; -using Content.Server._White.EmpFlashlight; +using Content.Shared.Weapons.Melee.Events; using Content.Server.Emp; -using Robust.Shared.IoC; using Content.Shared.Charges.Systems; using Content.Shared.Charges.Components; namespace Content.Server._White.EmpFlashlight; -public sealed class EmpHitSystem : EntitySystem +public sealed class EmpOnHitSystem : EntitySystem { - [Dependency] private readonly EntityLookupSystem _lookup = default!; + [Dependency] private readonly EmpSystem _emp = default!; [Dependency] private readonly SharedChargesSystem _charges = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; + public override void Initialize() { base.Initialize(); @@ -23,14 +20,14 @@ public override void Initialize() public bool TryEmpHit(EntityUid uid, EmpOnHitComponent comp, MeleeHitEvent args) { - LimitedChargesComponent? charges; - if (!TryComp(uid, out charges)) + + if (!TryComp(uid, out LimitedChargesComponent? charges)) return false; if (_charges.IsEmpty(uid, charges)) return false; - if (charges != null && args.HitEntities.Count > 0) + if (args.HitEntities.Count > 0) { _charges.UseCharge(uid,charges); return true; @@ -46,7 +43,7 @@ private void HandleEmpHit(EntityUid uid, EmpOnHitComponent comp, MeleeHitEvent a foreach (var affected in args.HitEntities) { - _emp.EmpPulse(Transform(affected).MapPosition, comp.Range, comp.EnergyConsumption, comp.DisableDuration); + _emp.EmpPulse(_transform.GetMapCoordinates(affected), comp.Range, comp.EnergyConsumption, comp.DisableDuration); } args.Handled = true; diff --git a/Resources/Prototypes/_White/Entities/Objects/Tools/EmpFlashlight.yml b/Resources/Prototypes/_White/Entities/Objects/Tools/EmpFlashlight.yml index 597b78006f..1da304ba1a 100644 --- a/Resources/Prototypes/_White/Entities/Objects/Tools/EmpFlashlight.yml +++ b/Resources/Prototypes/_White/Entities/Objects/Tools/EmpFlashlight.yml @@ -14,7 +14,7 @@ wideAnimationRotation: -135 damage: types: - Blunt: 0 + Blunt: 12 angle: 60 animation: WeaponArcThrust - type: EmpOnHit @@ -23,4 +23,4 @@ disableDuration: 100 - type: LimitedCharges - type: AutoRecharge - rechargeDuration: 30 + rechargeDuration: 60