From 63c7bca04eb8bcfb4ce4aa4edafc9ded8c80d6a1 Mon Sep 17 00:00:00 2001
From: Errant <35878406+Errant-4@users.noreply.github.com>
Date: Thu, 7 Sep 2023 07:37:23 +0200
Subject: [PATCH] Add pressure limit to gas tanks (#19879)
---
Content.Server/Atmos/Components/GasTankComponent.cs | 6 ++++++
Content.Server/Atmos/EntitySystems/GasTankSystem.cs | 6 +++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/Content.Server/Atmos/Components/GasTankComponent.cs b/Content.Server/Atmos/Components/GasTankComponent.cs
index 82e6483ae4..5815fba489 100644
--- a/Content.Server/Atmos/Components/GasTankComponent.cs
+++ b/Content.Server/Atmos/Components/GasTankComponent.cs
@@ -47,6 +47,12 @@ namespace Content.Server.Atmos.Components
[DataField("outputPressure"), ViewVariables(VVAccess.ReadWrite)]
public float OutputPressure = DefaultOutputPressure;
+ ///
+ /// The maximum allowed output pressure.
+ ///
+ [DataField("maxOutputPressure"), ViewVariables(VVAccess.ReadWrite)]
+ public float MaxOutputPressure = 3 * DefaultOutputPressure;
+
///
/// Tank is connected to internals.
///
diff --git a/Content.Server/Atmos/EntitySystems/GasTankSystem.cs b/Content.Server/Atmos/EntitySystems/GasTankSystem.cs
index eea5e6cf53..cdd174ce18 100644
--- a/Content.Server/Atmos/EntitySystems/GasTankSystem.cs
+++ b/Content.Server/Atmos/EntitySystems/GasTankSystem.cs
@@ -69,7 +69,11 @@ namespace Content.Server.Atmos.EntitySystems
private void OnGasTankSetPressure(EntityUid uid, GasTankComponent component, GasTankSetPressureMessage args)
{
- component.OutputPressure = args.Pressure;
+ var pressure = Math.Min(args.Pressure, component.MaxOutputPressure);
+
+ component.OutputPressure = pressure;
+
+ UpdateUserInterface(component, true);
}
public void UpdateUserInterface(GasTankComponent component, bool initialUpdate = false)