diff --git a/Content.Server/Emp/EmpSystem.cs b/Content.Server/Emp/EmpSystem.cs index b8bfc63afe..67f9cabd42 100644 --- a/Content.Server/Emp/EmpSystem.cs +++ b/Content.Server/Emp/EmpSystem.cs @@ -2,8 +2,6 @@ using Content.Server.Power.EntitySystems; using Content.Server.Radio; using Content.Server.SurveillanceCamera; using Content.Shared.Emp; -using Content.Shared.Examine; -using Robust.Server.GameObjects; using Robust.Shared.Map; namespace Content.Server.Emp; @@ -11,14 +9,12 @@ namespace Content.Server.Emp; public sealed class EmpSystem : SharedEmpSystem { [Dependency] private readonly EntityLookupSystem _lookup = default!; - [Dependency] private readonly TransformSystem _transform = default!; public const string EmpPulseEffectPrototype = "EffectEmpPulse"; public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnExamine); SubscribeLocalEvent(OnRadioSendAttempt); SubscribeLocalEvent(OnRadioReceiveAttempt); @@ -77,15 +73,15 @@ public sealed class EmpSystem : SharedEmpSystem { var ev = new EmpPulseEvent(energyConsumption, false, false, TimeSpan.FromSeconds(duration)); RaiseLocalEvent(uid, ref ev); + if (ev.Affected) - { Spawn(EmpDisabledEffectPrototype, Transform(uid).Coordinates); - } - if (ev.Disabled) - { - var disabled = EnsureComp(uid); - disabled.DisabledUntil = Timing.CurTime + TimeSpan.FromSeconds(duration); - } + + if (!ev.Disabled) + return; + + var disabled = EnsureComp(uid); + disabled.DisabledUntil = Timing.CurTime + TimeSpan.FromSeconds(duration); } public override void Update(float frameTime) @@ -104,11 +100,6 @@ public sealed class EmpSystem : SharedEmpSystem } } - private void OnExamine(EntityUid uid, EmpDisabledComponent component, ExaminedEvent args) - { - args.PushMarkup(Loc.GetString("emp-disabled-comp-on-examine")); - } - private void OnRadioSendAttempt(EntityUid uid, EmpDisabledComponent component, ref RadioSendAttemptEvent args) { args.Cancelled = true; @@ -133,9 +124,7 @@ public sealed class EmpSystem : SharedEmpSystem /// /// Raised on an entity before . Cancel this to prevent the emp event being raised. /// -public sealed partial class EmpAttemptEvent : CancellableEntityEventArgs -{ -} +public sealed partial class EmpAttemptEvent : CancellableEntityEventArgs; [ByRefEvent] public record struct EmpPulseEvent(float EnergyConsumption, bool Affected, bool Disabled, TimeSpan Duration); diff --git a/Content.Shared/Emp/SharedEmpSystem.cs b/Content.Shared/Emp/SharedEmpSystem.cs index 72dc874935..deb2afd709 100644 --- a/Content.Shared/Emp/SharedEmpSystem.cs +++ b/Content.Shared/Emp/SharedEmpSystem.cs @@ -1,3 +1,4 @@ +using Content.Shared.Examine; using Robust.Shared.Map; using Robust.Shared.Timing; @@ -7,6 +8,13 @@ public abstract class SharedEmpSystem : EntitySystem { [Dependency] protected readonly IGameTiming Timing = default!; + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnExamine); + } + protected const string EmpDisabledEffectPrototype = "EffectEmpDisabled"; /// @@ -19,4 +27,9 @@ public abstract class SharedEmpSystem : EntitySystem public virtual void EmpPulse(MapCoordinates coordinates, float range, float energyConsumption, float duration) { } + + private void OnExamine(Entity ent, ref ExaminedEvent args) + { + args.PushMarkup(Loc.GetString("emp-disabled-comp-on-examine")); + } }