]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fixes air sensors not accessing gas mixture on construction + visual fixes (#15224)
authorMenshin <Menshin@users.noreply.github.com>
Sun, 9 Apr 2023 02:25:38 +0000 (04:25 +0200)
committerGitHub <noreply@github.com>
Sun, 9 Apr 2023 02:25:38 +0000 (19:25 -0700)
Content.Server/Atmos/Monitor/Systems/AtmosMonitoringSystem.cs
Resources/Prototypes/Entities/Structures/Specific/Atmospherics/sensor.yml

index 079a9b691123e3b3842d1ab8bcd04c8908eff4ff..528c7289da8478844e90f701732e50ad5a555a17 100644 (file)
@@ -4,16 +4,12 @@ using Content.Server.Atmos.EntitySystems;
 using Content.Server.Atmos.Piping.EntitySystems;
 using Content.Server.Atmos.Piping.Components;
 using Content.Server.DeviceNetwork;
-using Content.Server.DeviceNetwork.Components;
 using Content.Server.DeviceNetwork.Systems;
 using Content.Server.Power.Components;
 using Content.Server.Power.EntitySystems;
 using Content.Shared.Atmos;
 using Content.Shared.Atmos.Monitor;
 using Content.Shared.Tag;
-using Robust.Server.GameObjects;
-using Robust.Shared.Audio;
-using Robust.Shared.Player;
 using Robust.Shared.Prototypes;
 
 namespace Content.Server.Atmos.Monitor.Systems;
@@ -48,6 +44,18 @@ public sealed class AtmosMonitorSystem : EntitySystem
         SubscribeLocalEvent<AtmosMonitorComponent, PowerChangedEvent>(OnPowerChangedEvent);
         SubscribeLocalEvent<AtmosMonitorComponent, BeforePacketSentEvent>(BeforePacketRecv);
         SubscribeLocalEvent<AtmosMonitorComponent, DeviceNetworkPacketEvent>(OnPacketRecv);
+        SubscribeLocalEvent<AtmosMonitorComponent, AtmosDeviceDisabledEvent>(OnAtmosDeviceLeaveAtmosphere);
+        SubscribeLocalEvent<AtmosMonitorComponent, AtmosDeviceEnabledEvent>(OnAtmosDeviceEnterAtmosphere);
+    }
+
+    private void OnAtmosDeviceLeaveAtmosphere(EntityUid uid, AtmosMonitorComponent atmosMonitor, AtmosDeviceDisabledEvent args)
+    {
+        atmosMonitor.TileGas = null;
+    }
+
+    private void OnAtmosDeviceEnterAtmosphere(EntityUid uid, AtmosMonitorComponent atmosMonitor, AtmosDeviceEnabledEvent args)
+    {
+        atmosMonitor.TileGas = _atmosphereSystem.GetContainingMixture(uid, true);
     }
 
     private void OnAtmosMonitorInit(EntityUid uid, AtmosMonitorComponent component, ComponentInit args)
@@ -148,21 +156,11 @@ public sealed class AtmosMonitorSystem : EntitySystem
         {
             if (!args.Powered)
             {
-                if (atmosDeviceComponent.JoinedGrid != null)
-                {
-                    _atmosDeviceSystem.LeaveAtmosphere(atmosDeviceComponent);
-                    component.TileGas = null;
-                }
+                _atmosDeviceSystem.LeaveAtmosphere(atmosDeviceComponent);
             }
-            else if (args.Powered)
+            else
             {
-                if (atmosDeviceComponent.JoinedGrid == null)
-                {
-                    _atmosDeviceSystem.JoinAtmosphere(atmosDeviceComponent);
-                    var air = _atmosphereSystem.GetContainingMixture(uid, true);
-                    component.TileGas = air;
-                }
-
+                _atmosDeviceSystem.JoinAtmosphere(atmosDeviceComponent);
                 Alert(uid, component.LastAlarmState);
             }
         }
index 774a8814fd7a75fe60e922aa0bd46ee6085ad28f..7e3d19eced6df5743e21a6df9f2680c2f35a3ce2 100644 (file)
         - AirSensor
     - type: AccessReader
       access: [ [ "Atmospherics" ] ]
-    - type: GenericVisualizer
-      visuals:
-        enum.PowerDeviceVisuals.Powered:
-          sensor:
-            True: { state: gsensor1 }
-            False: { state: gsensor0 }
     - type: Construction
       graph: AirSensor
       node: sensor
+    - type: Appearance
     - type: Sprite
       netsync: false
       drawdepth: FloorObjects
       sprite: Structures/Specific/Atmospherics/sensor.rsi
       layers:
         - state: gsensor1
-          map: [ "sensor" ]
+          map: [ "enum.PowerDeviceVisualLayers.Powered" ]
+    - type: GenericVisualizer
+      visuals:
+        enum.PowerDeviceVisuals.Powered:
+          enum.PowerDeviceVisualLayers.Powered:
+            True: { state: gsensor1 }
+            False: { state: gsensor0 }
 
 - type: entity
   parent: BaseItem