Internals alert fix and adjustment (#12517)

* add low pressure data field

* resolve CheckSeverity bug, replace logic

* add configurable low pressure threshhold
This commit is contained in:
Bright0
2022-11-09 19:02:14 -06:00
committed by GitHub
parent 8afc52878d
commit ecc969d8f4
3 changed files with 14 additions and 4 deletions

View File

@@ -8,9 +8,11 @@ namespace Content.Server.Atmos.Components
public sealed class GasTankComponent : Component, IGasMixtureHolder public sealed class GasTankComponent : Component, IGasMixtureHolder
{ {
public const float MaxExplosionRange = 14f; public const float MaxExplosionRange = 14f;
private const float DefaultLowPressure = 0f;
private const float DefaultOutputPressure = Atmospherics.OneAtmosphere; private const float DefaultOutputPressure = Atmospherics.OneAtmosphere;
public int Integrity = 3; public int Integrity = 3;
public bool IsLowPressure => (Air?.Pressure ?? 0F) <= TankLowPressure;
[ViewVariables(VVAccess.ReadWrite), DataField("ruptureSound")] [ViewVariables(VVAccess.ReadWrite), DataField("ruptureSound")]
public SoundSpecifier RuptureSound = new SoundPathSpecifier("/Audio/Effects/spray.ogg"); public SoundSpecifier RuptureSound = new SoundPathSpecifier("/Audio/Effects/spray.ogg");
@@ -32,6 +34,13 @@ namespace Content.Server.Atmos.Components
[DataField("air")] [ViewVariables] public GasMixture Air { get; set; } = new(); [DataField("air")] [ViewVariables] public GasMixture Air { get; set; } = new();
/// <summary>
/// Pressure at which tank should be considered 'low' such as for internals.
/// </summary>
[DataField("tankLowPressure")]
[ViewVariables]
public float TankLowPressure { get; set; } = DefaultLowPressure;
/// <summary> /// <summary>
/// Distributed pressure. /// Distributed pressure.
/// </summary> /// </summary>

View File

@@ -208,10 +208,10 @@ public sealed class InternalsSystem : EntitySystem
{ {
if (component.BreathToolEntity == null || !AreInternalsWorking(component)) return 2; if (component.BreathToolEntity == null || !AreInternalsWorking(component)) return 2;
// What we are checking here is if there is more moles in tank than we need. // If pressure in the tank is below low pressure threshhold, flash warning on internals UI
if (TryComp<GasTankComponent>(component.GasTankEntity, out var gasTank) if (TryComp<GasTankComponent>(component.GasTankEntity, out var gasTank)
&& (gasTank.OutputPressure * Atmospherics.BreathVolume / Atmospherics.R * gasTank.Air.Temperature) >= gasTank.Air.TotalMoles) && gasTank.IsLowPressure)
return 0; return 0;
return 1; return 1;
} }

View File

@@ -1,4 +1,4 @@
- type: entity - type: entity
abstract: true abstract: true
parent: BaseItem parent: BaseItem
id: GasTankBase id: GasTankBase
@@ -44,6 +44,7 @@
air: air:
volume: 70 volume: 70
temperature: 293.15 temperature: 293.15
tankLowPressure: 30.0
- type: Clothing - type: Clothing
sprite: Objects/Tanks/oxygen.rsi sprite: Objects/Tanks/oxygen.rsi
slots: slots: