From b417c022bf95ee101a104b627783ab1a6e4b9cbf Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Thu, 10 Feb 2022 16:28:11 +1300 Subject: [PATCH] Disable mixer and filter on unanchor (#6577) --- .../Trinary/EntitySystems/GasFilterSystem.cs | 15 +++++++++++++++ .../Trinary/EntitySystems/GasMixerSystem.cs | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasFilterSystem.cs b/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasFilterSystem.cs index 6946b8e682..bfbcb1a73a 100644 --- a/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasFilterSystem.cs +++ b/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasFilterSystem.cs @@ -39,6 +39,21 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems SubscribeLocalEvent(OnTransferRateChangeMessage); SubscribeLocalEvent(OnSelectGasMessage); SubscribeLocalEvent(OnToggleStatusMessage); + + SubscribeLocalEvent(OnAnchorChanged); + } + + private void OnAnchorChanged(EntityUid uid, GasFilterComponent component, ref AnchorStateChangedEvent args) + { + if (args.Anchored) + return; + + component.Enabled = false; + if (TryComp(uid, out AppearanceComponent? appearance)) + appearance.SetData(FilterVisuals.Enabled, false); + + DirtyUI(uid, component); + _userInterfaceSystem.TryCloseAll(uid, GasFilterUiKey.Key); } private void OnFilterUpdated(EntityUid uid, GasFilterComponent filter, AtmosDeviceUpdateEvent args) diff --git a/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasMixerSystem.cs b/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasMixerSystem.cs index 708168239f..0c6da97641 100644 --- a/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasMixerSystem.cs +++ b/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasMixerSystem.cs @@ -33,6 +33,20 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems SubscribeLocalEvent(OnOutputPressureChangeMessage); SubscribeLocalEvent(OnChangeNodePercentageMessage); SubscribeLocalEvent(OnToggleStatusMessage); + + SubscribeLocalEvent(OnAnchorChanged); + } + + private void OnAnchorChanged(EntityUid uid, GasMixerComponent component, ref AnchorStateChangedEvent args) + { + if (args.Anchored) + return; + + component.Enabled = false; + + DirtyUI(uid, component); + UpdateAppearance(uid, component); + _userInterfaceSystem.TryCloseAll(uid, GasFilterUiKey.Key); } private void OnInit(EntityUid uid, GasMixerComponent component, ComponentInit args)