Show volume on the gas analyzer (#25720)
The gas analyzer now shows the volume of pipes, tanks, canisters and the environment. Adjust gas analyzers so that the volume and number of moles shown corresponds to only the scanned element, e.g. a canister or single pipe in a pipenet.
This commit is contained in:
@@ -132,7 +132,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
/// </summary>
|
||||
private void OnDisabledMessage(EntityUid uid, GasAnalyzerComponent component, GasAnalyzerDisableMessage message)
|
||||
{
|
||||
if (message.Session.AttachedEntity is not {Valid: true})
|
||||
if (message.Session.AttachedEntity is not { Valid: true })
|
||||
return;
|
||||
DisableAnalyzer(uid, component);
|
||||
}
|
||||
@@ -169,7 +169,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
// Check if position is out of range => don't update and disable
|
||||
if (!component.LastPosition.Value.InRange(EntityManager, _transform, userPos, SharedInteractionSystem.InteractionRange))
|
||||
{
|
||||
if(component.User is { } userId && component.Enabled)
|
||||
if (component.User is { } userId && component.Enabled)
|
||||
_popup.PopupEntity(Loc.GetString("gas-analyzer-shutoff"), userId, userId);
|
||||
DisableAnalyzer(uid, component, component.User);
|
||||
return false;
|
||||
@@ -182,13 +182,13 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
var tileMixture = _atmo.GetContainingMixture(uid, true);
|
||||
if (tileMixture != null)
|
||||
{
|
||||
gasMixList.Add(new GasMixEntry(Loc.GetString("gas-analyzer-window-environment-tab-label"), tileMixture.Pressure, tileMixture.Temperature,
|
||||
gasMixList.Add(new GasMixEntry(Loc.GetString("gas-analyzer-window-environment-tab-label"), tileMixture.Volume, tileMixture.Pressure, tileMixture.Temperature,
|
||||
GenerateGasEntryArray(tileMixture)));
|
||||
}
|
||||
else
|
||||
{
|
||||
// No gases were found
|
||||
gasMixList.Add(new GasMixEntry(Loc.GetString("gas-analyzer-window-environment-tab-label"), 0f, 0f));
|
||||
gasMixList.Add(new GasMixEntry(Loc.GetString("gas-analyzer-window-environment-tab-label"), 0f, 0f, 0f));
|
||||
}
|
||||
|
||||
var deviceFlipped = false;
|
||||
@@ -209,8 +209,8 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
{
|
||||
foreach (var mixes in ev.GasMixtures)
|
||||
{
|
||||
if(mixes.Value != null)
|
||||
gasMixList.Add(new GasMixEntry(mixes.Key, mixes.Value.Pressure, mixes.Value.Temperature, GenerateGasEntryArray(mixes.Value)));
|
||||
if (mixes.Item2 != null)
|
||||
gasMixList.Add(new GasMixEntry(mixes.Item1, mixes.Item2.Volume, mixes.Item2.Pressure, mixes.Item2.Temperature, GenerateGasEntryArray(mixes.Item2)));
|
||||
}
|
||||
|
||||
deviceFlipped = ev.DeviceFlipped;
|
||||
@@ -223,7 +223,16 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
foreach (var pair in node.Nodes)
|
||||
{
|
||||
if (pair.Value is PipeNode pipeNode)
|
||||
gasMixList.Add(new GasMixEntry(pair.Key, pipeNode.Air.Pressure, pipeNode.Air.Temperature, GenerateGasEntryArray(pipeNode.Air)));
|
||||
{
|
||||
// check if the volume is zero for some reason so we don't divide by zero
|
||||
if (pipeNode.Air.Volume == 0f)
|
||||
continue;
|
||||
// only display the gas in the analyzed pipe element, not the whole system
|
||||
var pipeAir = pipeNode.Air.Clone();
|
||||
pipeAir.Multiply(pipeNode.Volume / pipeNode.Air.Volume);
|
||||
pipeAir.Volume = pipeNode.Volume;
|
||||
gasMixList.Add(new GasMixEntry(pair.Key, pipeAir.Volume, pipeAir.Pressure, pipeAir.Temperature, GenerateGasEntryArray(pipeAir)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -286,9 +295,9 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
public sealed class GasAnalyzerScanEvent : EntityEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Key is the mix name (ex "pipe", "inlet", "filter"), value is the pipe direction and GasMixture. Add all mixes that should be reported when scanned.
|
||||
/// The string is for the name (ex "pipe", "inlet", "filter"), GasMixture for the corresponding gas mix. Add all mixes that should be reported when scanned.
|
||||
/// </summary>
|
||||
public Dictionary<string, GasMixture?>? GasMixtures;
|
||||
public List<(string, GasMixture?)>? GasMixtures;
|
||||
|
||||
/// <summary>
|
||||
/// If the device is flipped. Flipped is defined as when the inline input is 90 degrees CW to the side input
|
||||
|
||||
Reference in New Issue
Block a user