Skip to content

Commit 4474727

Browse files
authored
Fix air devices ignoring settings after power cycle (#34887)
* 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.
1 parent 3d1970f commit 4474727

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

Content.Server/Atmos/Piping/Unary/Components/GasVentPumpComponent.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ namespace Content.Server.Atmos.Piping.Unary.Components
1111
[RegisterComponent]
1212
public sealed partial class GasVentPumpComponent : Component
1313
{
14+
/// <summary>
15+
/// Identifies if the device is enabled by an air alarm. Does not indicate if the device is powered.
16+
/// By default, all air vents start enabled, whether linked to an alarm or not.
17+
/// </summary>
1418
[ViewVariables(VVAccess.ReadWrite)]
15-
public bool Enabled { get; set; } = false;
19+
public bool Enabled { get; set; } = true;
1620

1721
[ViewVariables]
1822
public bool IsDirty { get; set; } = false;

Content.Server/Atmos/Piping/Unary/Components/GasVentScrubberComponent.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ namespace Content.Server.Atmos.Piping.Unary.Components
99
[Access(typeof(GasVentScrubberSystem))]
1010
public sealed partial class GasVentScrubberComponent : Component
1111
{
12+
/// <summary>
13+
/// Identifies if the device is enabled by an air alarm. Does not indicate if the device is powered.
14+
/// By default, all air scrubbers start enabled, whether linked to an alarm or not.
15+
/// </summary>
1216
[DataField]
13-
public bool Enabled { get; set; } = false;
17+
public bool Enabled { get; set; } = true;
1418

1519
[DataField]
1620
public bool IsDirty { get; set; } = false;

Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentPumpSystem.cs

+7-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
using Content.Server.DeviceNetwork.Systems;
1010
using Content.Server.NodeContainer.EntitySystems;
1111
using Content.Server.NodeContainer.Nodes;
12+
using Content.Server.Power.Components;
13+
using Content.Server.Power.EntitySystems;
1214
using Content.Shared.Administration.Logs;
1315
using Content.Shared.Atmos;
1416
using Content.Shared.Atmos.Monitor;
@@ -43,6 +45,7 @@ public sealed class GasVentPumpSystem : EntitySystem
4345
[Dependency] private readonly SharedToolSystem _toolSystem = default!;
4446
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
4547
[Dependency] private readonly IGameTiming _timing = default!;
48+
[Dependency] private readonly PowerReceiverSystem _powerReceiverSystem = default!;
4649
public override void Initialize()
4750
{
4851
base.Initialize();
@@ -66,9 +69,10 @@ private void OnGasVentPumpUpdated(EntityUid uid, GasVentPumpComponent vent, ref
6669
{
6770
//Bingo waz here
6871
if (_weldable.IsWelded(uid))
69-
{
7072
return;
71-
}
73+
74+
if (!_powerReceiverSystem.IsPowered(uid))
75+
return;
7276

7377
var nodeName = vent.PumpDirection switch
7478
{
@@ -210,7 +214,6 @@ private void OnAtmosAlarm(EntityUid uid, GasVentPumpComponent component, AtmosAl
210214

211215
private void OnPowerChanged(EntityUid uid, GasVentPumpComponent component, ref PowerChangedEvent args)
212216
{
213-
component.Enabled = args.Powered;
214217
UpdateState(uid, component);
215218
}
216219

@@ -318,7 +321,7 @@ private void UpdateState(EntityUid uid, GasVentPumpComponent vent, AppearanceCom
318321
_ambientSoundSystem.SetAmbience(uid, false);
319322
_appearance.SetData(uid, VentPumpVisuals.State, VentPumpState.Welded, appearance);
320323
}
321-
else if (!vent.Enabled)
324+
else if (!_powerReceiverSystem.IsPowered(uid) || !vent.Enabled)
322325
{
323326
_ambientSoundSystem.SetAmbience(uid, false);
324327
_appearance.SetData(uid, VentPumpVisuals.State, VentPumpState.Off, appearance);

Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentScrubberSystem.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Content.Server.NodeContainer.EntitySystems;
1111
using Content.Server.NodeContainer.Nodes;
1212
using Content.Server.Power.Components;
13+
using Content.Server.Power.EntitySystems;
1314
using Content.Shared.Administration.Logs;
1415
using Content.Shared.Atmos;
1516
using Content.Shared.Atmos.Piping.Unary.Visuals;
@@ -37,6 +38,7 @@ public sealed class GasVentScrubberSystem : EntitySystem
3738
[Dependency] private readonly TransformSystem _transformSystem = default!;
3839
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
3940
[Dependency] private readonly WeldableSystem _weldable = default!;
41+
[Dependency] private readonly PowerReceiverSystem _powerReceiverSystem = default!;
4042

4143
public override void Initialize()
4244
{
@@ -58,6 +60,9 @@ private void OnVentScrubberUpdated(EntityUid uid, GasVentScrubberComponent scrub
5860

5961
var timeDelta = args.dt;
6062

63+
if (!_powerReceiverSystem.IsPowered(uid))
64+
return;
65+
6166
if (!scrubber.Enabled || !_nodeContainer.TryGetNode(uid, scrubber.OutletName, out PipeNode? outlet))
6267
return;
6368

@@ -141,7 +146,6 @@ private void OnAtmosAlarm(EntityUid uid, GasVentScrubberComponent component, Atm
141146

142147
private void OnPowerChanged(EntityUid uid, GasVentScrubberComponent component, ref PowerChangedEvent args)
143148
{
144-
component.Enabled = args.Powered;
145149
UpdateState(uid, component);
146150
}
147151

@@ -225,7 +229,7 @@ private void UpdateState(EntityUid uid, GasVentScrubberComponent scrubber,
225229
_ambientSoundSystem.SetAmbience(uid, false);
226230
_appearance.SetData(uid, ScrubberVisuals.State, ScrubberState.Welded, appearance);
227231
}
228-
else if (!scrubber.Enabled)
232+
else if (!_powerReceiverSystem.IsPowered(uid) || !scrubber.Enabled)
229233
{
230234
_ambientSoundSystem.SetAmbience(uid, false);
231235
_appearance.SetData(uid, ScrubberVisuals.State, ScrubberState.Off, appearance);

0 commit comments

Comments
 (0)