]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix air devices ignoring settings after power cycle (#34887)
authorKyle Tyo <36606155+VerinSenpai@users.noreply.github.com>
Sat, 15 Feb 2025 06:07:15 +0000 (01:07 -0500)
committerGitHub <noreply@github.com>
Sat, 15 Feb 2025 06:07:15 +0000 (07:07 +0100)
* add powered variable to vent components

* add checks for powered to vent systems

also corrected onpowerchanged methods to update powered arg.

* removed powered from components

* Use ApcPowerReceieverComponent for power state.

* removed unneeded code from OnPowerChanged

* document what enabled is used for in components

* only you can prevent oopsie daisies.

* add check for powered in OnGasVentPumpUpdated

* apcPowerReceiverComponent BEGONE

* CODE RED EVERYTHINGS ON FIRE wait we're fine now.

Content.Server/Atmos/Piping/Unary/Components/GasVentPumpComponent.cs
Content.Server/Atmos/Piping/Unary/Components/GasVentScrubberComponent.cs
Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentPumpSystem.cs
Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentScrubberSystem.cs

index 25b15f0ed55b53f0b878e50646c0ecdf26f20a3f..a9aa40611dcfe0a65f0581ed47b6878ae7188cff 100644 (file)
@@ -11,8 +11,12 @@ namespace Content.Server.Atmos.Piping.Unary.Components
     [RegisterComponent]
     public sealed partial class GasVentPumpComponent : Component
     {
+        /// <summary>
+        /// Identifies if the device is enabled by an air alarm. Does not indicate if the device is powered.
+        /// By default, all air vents start enabled, whether linked to an alarm or not.
+        /// </summary>
         [ViewVariables(VVAccess.ReadWrite)]
-        public bool Enabled { get; set; } = false;
+        public bool Enabled { get; set; } = true;
 
         [ViewVariables]
         public bool IsDirty { get; set; } = false;
index b2143283f731829bd7e0c3bb8706597f89fdff28..4a9437bc1fc9dad36cff3f281a518b7929d1a6ad 100644 (file)
@@ -9,8 +9,12 @@ namespace Content.Server.Atmos.Piping.Unary.Components
     [Access(typeof(GasVentScrubberSystem))]
     public sealed partial class GasVentScrubberComponent : Component
     {
+        /// <summary>
+        /// Identifies if the device is enabled by an air alarm. Does not indicate if the device is powered.
+        /// By default, all air scrubbers start enabled, whether linked to an alarm or not.
+        /// </summary>
         [DataField]
-        public bool Enabled { get; set; } = false;
+        public bool Enabled { get; set; } = true;
 
         [DataField]
         public bool IsDirty { get; set; } = false;
index c58d6eb14bc64c58c703fe62c2a9c2395e126d83..93f7dcf11106612f839cb20a4a591076c800c1fd 100644 (file)
@@ -9,6 +9,8 @@ using Content.Server.DeviceNetwork.Components;
 using Content.Server.DeviceNetwork.Systems;
 using Content.Server.NodeContainer.EntitySystems;
 using Content.Server.NodeContainer.Nodes;
+using Content.Server.Power.Components;
+using Content.Server.Power.EntitySystems;
 using Content.Shared.Administration.Logs;
 using Content.Shared.Atmos;
 using Content.Shared.Atmos.Monitor;
@@ -43,6 +45,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
         [Dependency] private readonly SharedToolSystem _toolSystem = default!;
         [Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
         [Dependency] private readonly IGameTiming _timing = default!;
+        [Dependency] private readonly PowerReceiverSystem _powerReceiverSystem = default!;
         public override void Initialize()
         {
             base.Initialize();
@@ -66,9 +69,10 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
         {
             //Bingo waz here
             if (_weldable.IsWelded(uid))
-            {
                 return;
-            }
+
+            if (!_powerReceiverSystem.IsPowered(uid))
+                return;
 
             var nodeName = vent.PumpDirection switch
             {
@@ -210,7 +214,6 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
 
         private void OnPowerChanged(EntityUid uid, GasVentPumpComponent component, ref PowerChangedEvent args)
         {
-            component.Enabled = args.Powered;
             UpdateState(uid, component);
         }
 
@@ -318,7 +321,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
                 _ambientSoundSystem.SetAmbience(uid, false);
                 _appearance.SetData(uid, VentPumpVisuals.State, VentPumpState.Welded, appearance);
             }
-            else if (!vent.Enabled)
+            else if (!_powerReceiverSystem.IsPowered(uid) || !vent.Enabled)
             {
                 _ambientSoundSystem.SetAmbience(uid, false);
                 _appearance.SetData(uid, VentPumpVisuals.State, VentPumpState.Off, appearance);
index 020753539818c52abb6cb932a3f16dcf6a4aab43..38d75701d737d2b12b52dc9869e64eb9f0e91368 100644 (file)
@@ -10,6 +10,7 @@ using Content.Server.NodeContainer;
 using Content.Server.NodeContainer.EntitySystems;
 using Content.Server.NodeContainer.Nodes;
 using Content.Server.Power.Components;
+using Content.Server.Power.EntitySystems;
 using Content.Shared.Administration.Logs;
 using Content.Shared.Atmos;
 using Content.Shared.Atmos.Piping.Unary.Visuals;
@@ -37,6 +38,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
         [Dependency] private readonly TransformSystem _transformSystem = default!;
         [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
         [Dependency] private readonly WeldableSystem _weldable = default!;
+        [Dependency] private readonly PowerReceiverSystem _powerReceiverSystem = default!;
 
         public override void Initialize()
         {
@@ -58,6 +60,9 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
 
             var timeDelta = args.dt;
 
+            if (!_powerReceiverSystem.IsPowered(uid))
+                return;
+
             if (!scrubber.Enabled || !_nodeContainer.TryGetNode(uid, scrubber.OutletName, out PipeNode? outlet))
                 return;
 
@@ -141,7 +146,6 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
 
         private void OnPowerChanged(EntityUid uid, GasVentScrubberComponent component, ref PowerChangedEvent args)
         {
-            component.Enabled = args.Powered;
             UpdateState(uid, component);
         }
 
@@ -225,7 +229,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
                 _ambientSoundSystem.SetAmbience(uid, false);
                 _appearance.SetData(uid, ScrubberVisuals.State, ScrubberState.Welded, appearance);
             }
-            else if (!scrubber.Enabled)
+            else if (!_powerReceiverSystem.IsPowered(uid) || !scrubber.Enabled)
             {
                 _ambientSoundSystem.SetAmbience(uid, false);
                 _appearance.SetData(uid, ScrubberVisuals.State, ScrubberState.Off, appearance);