]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Predict EMP Examine (#39419)
authorKyle Tyo <36606155+VerinSenpai@users.noreply.github.com>
Wed, 6 Aug 2025 14:25:24 +0000 (10:25 -0400)
committerGitHub <noreply@github.com>
Wed, 6 Aug 2025 14:25:24 +0000 (16:25 +0200)
* another one bites the dust

* Update Content.Shared/Emp/SharedEmpSystem.cs

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Content.Server/Emp/EmpSystem.cs
Content.Shared/Emp/SharedEmpSystem.cs

index b8bfc63afefd3c373e4024dfcfc483c1c723ed29..67f9cabd4253c84bd9c2a81aa321e207cf33468f 100644 (file)
@@ -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<EmpDisabledComponent, ExaminedEvent>(OnExamine);
 
         SubscribeLocalEvent<EmpDisabledComponent, RadioSendAttemptEvent>(OnRadioSendAttempt);
         SubscribeLocalEvent<EmpDisabledComponent, RadioReceiveAttemptEvent>(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<EmpDisabledComponent>(uid);
-            disabled.DisabledUntil = Timing.CurTime + TimeSpan.FromSeconds(duration);
-        }
+
+        if (!ev.Disabled)
+            return;
+
+        var disabled = EnsureComp<EmpDisabledComponent>(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
 /// <summary>
 /// Raised on an entity before <see cref="EmpPulseEvent"/>. Cancel this to prevent the emp event being raised.
 /// </summary>
-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);
index 72dc874935ee16a5ee55774a8564da9cea8a7be9..deb2afd7092bfe09a89933d347b0d941aaa32761 100644 (file)
@@ -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<EmpDisabledComponent, ExaminedEvent>(OnExamine);
+    }
+
     protected const string EmpDisabledEffectPrototype = "EffectEmpDisabled";
 
     /// <summary>
@@ -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<EmpDisabledComponent> ent, ref ExaminedEvent args)
+    {
+        args.PushMarkup(Loc.GetString("emp-disabled-comp-on-examine"));
+    }
 }