From d1c980fe417765a6d0309527454d66ab80d4e89e Mon Sep 17 00:00:00 2001 From: mirrorcult Date: Mon, 4 Apr 2022 22:08:41 -0700 Subject: [PATCH] Gas tank minor opts (#7424) --- .../Atmos/Components/GasTankComponent.cs | 19 ++++++++++--------- .../Atmos/EntitySystems/GasTankSystem.cs | 8 ++++++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Content.Server/Atmos/Components/GasTankComponent.cs b/Content.Server/Atmos/Components/GasTankComponent.cs index f6182f8783..24a3df2528 100644 --- a/Content.Server/Atmos/Components/GasTankComponent.cs +++ b/Content.Server/Atmos/Components/GasTankComponent.cs @@ -31,7 +31,7 @@ namespace Content.Server.Atmos.Components private int _integrity = 3; - [ViewVariables] private BoundUserInterface? _userInterface; + [ViewVariables] public BoundUserInterface? UserInterface; [DataField("ruptureSound")] private SoundSpecifier _ruptureSound = new SoundPathSpecifier("Audio/Effects/spray.ogg"); @@ -84,10 +84,10 @@ namespace Content.Server.Atmos.Components protected override void Initialize() { base.Initialize(); - _userInterface = Owner.GetUIOrNull(SharedGasTankUiKey.Key); - if (_userInterface != null) + UserInterface = Owner.GetUIOrNull(SharedGasTankUiKey.Key); + if (UserInterface != null) { - _userInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage; + UserInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage; } } @@ -160,7 +160,7 @@ namespace Content.Server.Atmos.Components public void UpdateUserInterface(bool initialUpdate = false) { var internals = GetInternalsComponent(); - _userInterface?.SetState( + UserInterface?.SetState( new GasTankBoundUserInterfaceState { TankPressure = Air?.Pressure ?? 0, @@ -205,16 +205,17 @@ namespace Content.Server.Atmos.Components public void AssumeAir(GasMixture giver) { - EntitySystem.Get().Merge(Air, giver); - CheckStatus(); + var atmos = EntitySystem.Get(); + atmos.Merge(Air, giver); + CheckStatus(atmos); } - public void CheckStatus() + public void CheckStatus(AtmosphereSystem? atmosphereSystem=null) { if (Air == null) return; - var atmosphereSystem = EntitySystem.Get(); + atmosphereSystem ??= EntitySystem.Get(); var pressure = Air.Pressure; diff --git a/Content.Server/Atmos/EntitySystems/GasTankSystem.cs b/Content.Server/Atmos/EntitySystems/GasTankSystem.cs index 7451891023..00ff85c222 100644 --- a/Content.Server/Atmos/EntitySystems/GasTankSystem.cs +++ b/Content.Server/Atmos/EntitySystems/GasTankSystem.cs @@ -64,8 +64,12 @@ namespace Content.Server.Atmos.EntitySystems foreach (var gasTank in EntityManager.EntityQuery()) { _atmosphereSystem.React(gasTank.Air, gasTank); - gasTank.CheckStatus(); - gasTank.UpdateUserInterface(); + gasTank.CheckStatus(_atmosphereSystem); + + if (gasTank.UserInterface != null && gasTank.UserInterface.SubscribedSessions.Count > 0) + { + gasTank.UpdateUserInterface(); + } } } }