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.
This commit is contained in:
Kyle Tyo
2025-02-15 01:07:15 -05:00
committed by GitHub
parent 3d1970fc44
commit 4474727886
4 changed files with 23 additions and 8 deletions

View File

@@ -11,8 +11,12 @@ namespace Content.Server.Atmos.Piping.Unary.Components
[RegisterComponent] [RegisterComponent]
public sealed partial class GasVentPumpComponent : Component 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)] [ViewVariables(VVAccess.ReadWrite)]
public bool Enabled { get; set; } = false; public bool Enabled { get; set; } = true;
[ViewVariables] [ViewVariables]
public bool IsDirty { get; set; } = false; public bool IsDirty { get; set; } = false;

View File

@@ -9,8 +9,12 @@ namespace Content.Server.Atmos.Piping.Unary.Components
[Access(typeof(GasVentScrubberSystem))] [Access(typeof(GasVentScrubberSystem))]
public sealed partial class GasVentScrubberComponent : Component 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] [DataField]
public bool Enabled { get; set; } = false; public bool Enabled { get; set; } = true;
[DataField] [DataField]
public bool IsDirty { get; set; } = false; public bool IsDirty { get; set; } = false;

View File

@@ -9,6 +9,8 @@ using Content.Server.DeviceNetwork.Components;
using Content.Server.DeviceNetwork.Systems; using Content.Server.DeviceNetwork.Systems;
using Content.Server.NodeContainer.EntitySystems; using Content.Server.NodeContainer.EntitySystems;
using Content.Server.NodeContainer.Nodes; using Content.Server.NodeContainer.Nodes;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Shared.Administration.Logs; using Content.Shared.Administration.Logs;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Content.Shared.Atmos.Monitor; 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 SharedToolSystem _toolSystem = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!; [Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly PowerReceiverSystem _powerReceiverSystem = default!;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
@@ -66,9 +69,10 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
{ {
//Bingo waz here //Bingo waz here
if (_weldable.IsWelded(uid)) if (_weldable.IsWelded(uid))
{
return; return;
}
if (!_powerReceiverSystem.IsPowered(uid))
return;
var nodeName = vent.PumpDirection switch 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) private void OnPowerChanged(EntityUid uid, GasVentPumpComponent component, ref PowerChangedEvent args)
{ {
component.Enabled = args.Powered;
UpdateState(uid, component); UpdateState(uid, component);
} }
@@ -318,7 +321,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
_ambientSoundSystem.SetAmbience(uid, false); _ambientSoundSystem.SetAmbience(uid, false);
_appearance.SetData(uid, VentPumpVisuals.State, VentPumpState.Welded, appearance); _appearance.SetData(uid, VentPumpVisuals.State, VentPumpState.Welded, appearance);
} }
else if (!vent.Enabled) else if (!_powerReceiverSystem.IsPowered(uid) || !vent.Enabled)
{ {
_ambientSoundSystem.SetAmbience(uid, false); _ambientSoundSystem.SetAmbience(uid, false);
_appearance.SetData(uid, VentPumpVisuals.State, VentPumpState.Off, appearance); _appearance.SetData(uid, VentPumpVisuals.State, VentPumpState.Off, appearance);

View File

@@ -10,6 +10,7 @@ using Content.Server.NodeContainer;
using Content.Server.NodeContainer.EntitySystems; using Content.Server.NodeContainer.EntitySystems;
using Content.Server.NodeContainer.Nodes; using Content.Server.NodeContainer.Nodes;
using Content.Server.Power.Components; using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Shared.Administration.Logs; using Content.Shared.Administration.Logs;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Content.Shared.Atmos.Piping.Unary.Visuals; 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 TransformSystem _transformSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly WeldableSystem _weldable = default!; [Dependency] private readonly WeldableSystem _weldable = default!;
[Dependency] private readonly PowerReceiverSystem _powerReceiverSystem = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -58,6 +60,9 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
var timeDelta = args.dt; var timeDelta = args.dt;
if (!_powerReceiverSystem.IsPowered(uid))
return;
if (!scrubber.Enabled || !_nodeContainer.TryGetNode(uid, scrubber.OutletName, out PipeNode? outlet)) if (!scrubber.Enabled || !_nodeContainer.TryGetNode(uid, scrubber.OutletName, out PipeNode? outlet))
return; return;
@@ -141,7 +146,6 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
private void OnPowerChanged(EntityUid uid, GasVentScrubberComponent component, ref PowerChangedEvent args) private void OnPowerChanged(EntityUid uid, GasVentScrubberComponent component, ref PowerChangedEvent args)
{ {
component.Enabled = args.Powered;
UpdateState(uid, component); UpdateState(uid, component);
} }
@@ -225,7 +229,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
_ambientSoundSystem.SetAmbience(uid, false); _ambientSoundSystem.SetAmbience(uid, false);
_appearance.SetData(uid, ScrubberVisuals.State, ScrubberState.Welded, appearance); _appearance.SetData(uid, ScrubberVisuals.State, ScrubberState.Welded, appearance);
} }
else if (!scrubber.Enabled) else if (!_powerReceiverSystem.IsPowered(uid) || !scrubber.Enabled)
{ {
_ambientSoundSystem.SetAmbience(uid, false); _ambientSoundSystem.SetAmbience(uid, false);
_appearance.SetData(uid, ScrubberVisuals.State, ScrubberState.Off, appearance); _appearance.SetData(uid, ScrubberVisuals.State, ScrubberState.Off, appearance);