]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
EMP disables suit sensors (#24869)
authorthemias <89101928+themias@users.noreply.github.com>
Sun, 4 Feb 2024 00:50:23 +0000 (19:50 -0500)
committerGitHub <noreply@github.com>
Sun, 4 Feb 2024 00:50:23 +0000 (11:50 +1100)
* EMP disables suit sensors

* update to supersede and not disable

* Revert "update to supersede and not disable"

This reverts commit 337028c31af1c0fa2b1838bcf5d6759bfd7ed97c.

* separate logic out into just emp events

Content.Server/Medical/SuitSensors/SuitSensorComponent.cs
Content.Server/Medical/SuitSensors/SuitSensorSystem.cs

index 32b81e2921a322ca941fccf2b6e2d3bf23b739f7..5de11f848cde4100a6835a69ff3ee132a5fb9325 100644 (file)
@@ -72,4 +72,17 @@ public sealed partial class SuitSensorComponent : Component
     /// </summary>
     [DataField("server")]
     public string? ConnectedServer = null;
+
+    /// <summary>
+    /// The previous mode of the suit. This is used to restore the state when an EMP effect ends.
+    /// </summary>
+    [DataField, ViewVariables]
+    public SuitSensorMode PreviousMode = SuitSensorMode.SensorOff;
+
+    /// <summary>
+    ///  The previous locked status of the controls.  This is used to restore the state when an EMP effect ends.
+    ///  This keeps prisoner jumpsuits/internal implants from becoming unlocked after an EMP.
+    /// </summary>
+    [DataField, ViewVariables]
+    public bool PreviousControlsLocked = false;
 }
index bb662a15ea22fec17cb47f87abbb5af66a262640..aa6dca718d5228b098a9858dd74e516a8eaaae0b 100644 (file)
@@ -2,11 +2,13 @@ using Content.Server.Access.Systems;
 using Content.Server.DeviceNetwork;
 using Content.Server.DeviceNetwork.Components;
 using Content.Server.DeviceNetwork.Systems;
+using Content.Server.Emp;
 using Content.Server.GameTicking;
 using Content.Server.Medical.CrewMonitoring;
 using Content.Server.Popups;
 using Content.Server.Station.Systems;
 using Content.Shared.Damage;
+using Content.Shared.Emp;
 using Content.Shared.Examine;
 using Content.Shared.Inventory.Events;
 using Content.Shared.Medical.SuitSensor;
@@ -44,6 +46,8 @@ public sealed class SuitSensorSystem : EntitySystem
         SubscribeLocalEvent<SuitSensorComponent, GetVerbsEvent<Verb>>(OnVerb);
         SubscribeLocalEvent<SuitSensorComponent, EntGotInsertedIntoContainerMessage>(OnInsert);
         SubscribeLocalEvent<SuitSensorComponent, EntGotRemovedFromContainerMessage>(OnRemove);
+        SubscribeLocalEvent<SuitSensorComponent, EmpPulseEvent>(OnEmpPulse);
+        SubscribeLocalEvent<SuitSensorComponent, EmpDisabledRemoved>(OnEmpFinished);
     }
 
     private void OnUnpaused(EntityUid uid, SuitSensorComponent component, ref EntityUnpausedEvent args)
@@ -239,6 +243,24 @@ public sealed class SuitSensorSystem : EntitySystem
         component.User = null;
     }
 
+    private void OnEmpPulse(EntityUid uid, SuitSensorComponent component, ref EmpPulseEvent args)
+    {
+        args.Affected = true;
+        args.Disabled = true;
+
+        component.PreviousMode = component.Mode;
+        SetSensor(uid, SuitSensorMode.SensorOff, null, component);
+
+        component.PreviousControlsLocked = component.ControlsLocked;
+        component.ControlsLocked = true;
+    }
+
+    private void OnEmpFinished(EntityUid uid, SuitSensorComponent component, ref EmpDisabledRemoved args)
+    {
+        SetSensor(uid, component.PreviousMode, null, component);
+        component.ControlsLocked = component.PreviousControlsLocked;
+    }
+
     private Verb CreateVerb(EntityUid uid, SuitSensorComponent component, EntityUid userUid, SuitSensorMode mode)
     {
         return new Verb()