Gas tank minor opts (#7424)

This commit is contained in:
mirrorcult
2022-04-04 22:08:41 -07:00
committed by GitHub
parent 0123dc4c82
commit d1c980fe41
2 changed files with 16 additions and 11 deletions

View File

@@ -31,7 +31,7 @@ namespace Content.Server.Atmos.Components
private int _integrity = 3; private int _integrity = 3;
[ViewVariables] private BoundUserInterface? _userInterface; [ViewVariables] public BoundUserInterface? UserInterface;
[DataField("ruptureSound")] private SoundSpecifier _ruptureSound = new SoundPathSpecifier("Audio/Effects/spray.ogg"); [DataField("ruptureSound")] private SoundSpecifier _ruptureSound = new SoundPathSpecifier("Audio/Effects/spray.ogg");
@@ -84,10 +84,10 @@ namespace Content.Server.Atmos.Components
protected override void Initialize() protected override void Initialize()
{ {
base.Initialize(); base.Initialize();
_userInterface = Owner.GetUIOrNull(SharedGasTankUiKey.Key); UserInterface = Owner.GetUIOrNull(SharedGasTankUiKey.Key);
if (_userInterface != null) if (UserInterface != null)
{ {
_userInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage; UserInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage;
} }
} }
@@ -160,7 +160,7 @@ namespace Content.Server.Atmos.Components
public void UpdateUserInterface(bool initialUpdate = false) public void UpdateUserInterface(bool initialUpdate = false)
{ {
var internals = GetInternalsComponent(); var internals = GetInternalsComponent();
_userInterface?.SetState( UserInterface?.SetState(
new GasTankBoundUserInterfaceState new GasTankBoundUserInterfaceState
{ {
TankPressure = Air?.Pressure ?? 0, TankPressure = Air?.Pressure ?? 0,
@@ -205,16 +205,17 @@ namespace Content.Server.Atmos.Components
public void AssumeAir(GasMixture giver) public void AssumeAir(GasMixture giver)
{ {
EntitySystem.Get<AtmosphereSystem>().Merge(Air, giver); var atmos = EntitySystem.Get<AtmosphereSystem>();
CheckStatus(); atmos.Merge(Air, giver);
CheckStatus(atmos);
} }
public void CheckStatus() public void CheckStatus(AtmosphereSystem? atmosphereSystem=null)
{ {
if (Air == null) if (Air == null)
return; return;
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>(); atmosphereSystem ??= EntitySystem.Get<AtmosphereSystem>();
var pressure = Air.Pressure; var pressure = Air.Pressure;

View File

@@ -64,8 +64,12 @@ namespace Content.Server.Atmos.EntitySystems
foreach (var gasTank in EntityManager.EntityQuery<GasTankComponent>()) foreach (var gasTank in EntityManager.EntityQuery<GasTankComponent>())
{ {
_atmosphereSystem.React(gasTank.Air, gasTank); _atmosphereSystem.React(gasTank.Air, gasTank);
gasTank.CheckStatus(); gasTank.CheckStatus(_atmosphereSystem);
gasTank.UpdateUserInterface();
if (gasTank.UserInterface != null && gasTank.UserInterface.SubscribedSessions.Count > 0)
{
gasTank.UpdateUserInterface();
}
} }
} }
} }