Limit atmos device rates (#6533)
This commit is contained in:
@@ -8,7 +8,7 @@ namespace Content.Client.Atmos.Visualizers
|
|||||||
public sealed class PressurePumpVisualizer : EnabledAtmosDeviceVisualizer
|
public sealed class PressurePumpVisualizer : EnabledAtmosDeviceVisualizer
|
||||||
{
|
{
|
||||||
protected override object LayerMap => Layers.Enabled;
|
protected override object LayerMap => Layers.Enabled;
|
||||||
protected override Enum DataKey => PressurePumpVisuals.Enabled;
|
protected override Enum DataKey => PumpVisuals.Enabled;
|
||||||
|
|
||||||
enum Layers : byte
|
enum Layers : byte
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
|
||||||
using Robust.Shared.ViewVariables;
|
|
||||||
|
|
||||||
namespace Content.Server.Atmos.Piping.Binary.Components
|
namespace Content.Server.Atmos.Piping.Binary.Components
|
||||||
{
|
{
|
||||||
@@ -28,6 +25,7 @@ namespace Content.Server.Atmos.Piping.Binary.Components
|
|||||||
public string OutletName { get; set; } = "outlet";
|
public string OutletName { get; set; } = "outlet";
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("targetPressure")]
|
||||||
public float TargetPressure { get; set; } = Atmospherics.OneAtmosphere;
|
public float TargetPressure { get; set; } = Atmospherics.OneAtmosphere;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
|
||||||
using Robust.Shared.ViewVariables;
|
|
||||||
|
|
||||||
namespace Content.Server.Atmos.Piping.Binary.Components
|
namespace Content.Server.Atmos.Piping.Binary.Components
|
||||||
{
|
{
|
||||||
@@ -20,6 +17,14 @@ namespace Content.Server.Atmos.Piping.Binary.Components
|
|||||||
public string OutletName { get; set; } = "outlet";
|
public string OutletName { get; set; } = "outlet";
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("targetPressure")]
|
||||||
public float TargetPressure { get; set; } = Atmospherics.OneAtmosphere;
|
public float TargetPressure { get; set; } = Atmospherics.OneAtmosphere;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Max pressure of the target gas (NOT relative to source).
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("maxTargetPressure")]
|
||||||
|
public float MaxTargetPressure = Atmospherics.MaxOutputPressure;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
|
||||||
using Robust.Shared.ViewVariables;
|
|
||||||
|
|
||||||
namespace Content.Server.Atmos.Piping.Binary.Components
|
namespace Content.Server.Atmos.Piping.Binary.Components
|
||||||
{
|
{
|
||||||
@@ -23,8 +20,13 @@ namespace Content.Server.Atmos.Piping.Binary.Components
|
|||||||
public string OutletName { get; set; } = "outlet";
|
public string OutletName { get; set; } = "outlet";
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("transferRate")]
|
||||||
public float TransferRate { get; set; } = Atmospherics.MaxTransferRate;
|
public float TransferRate { get; set; } = Atmospherics.MaxTransferRate;
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("maxTransferRate")]
|
||||||
|
public float MaxTransferRate { get; set; } = Atmospherics.MaxTransferRate;
|
||||||
|
|
||||||
[DataField("leakRatio")]
|
[DataField("leakRatio")]
|
||||||
public float LeakRatio { get; set; } = 0.1f;
|
public float LeakRatio { get; set; } = 0.1f;
|
||||||
|
|
||||||
@@ -32,9 +34,9 @@ namespace Content.Server.Atmos.Piping.Binary.Components
|
|||||||
public float LowerThreshold { get; set; } = 0.01f;
|
public float LowerThreshold { get; set; } = 0.01f;
|
||||||
|
|
||||||
[DataField("higherThreshold")]
|
[DataField("higherThreshold")]
|
||||||
public float HigherThreshold { get; set; } = 9000f;
|
public float HigherThreshold { get; set; } = 2 * Atmospherics.MaxOutputPressure;
|
||||||
|
|
||||||
[DataField("overclockThreshold")]
|
[DataField("overclockThreshold")]
|
||||||
public float OverclockThreshold { get; set; } = 1000f;
|
public float OverclockThreshold { get; set; } = 1000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,6 @@ using Content.Shared.Interaction;
|
|||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Localization;
|
|
||||||
using Robust.Shared.Maths;
|
|
||||||
|
|
||||||
namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
||||||
{
|
{
|
||||||
@@ -62,7 +58,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
|||||||
|| !nodeContainer.TryGetNode(pump.InletName, out PipeNode? inlet)
|
|| !nodeContainer.TryGetNode(pump.InletName, out PipeNode? inlet)
|
||||||
|| !nodeContainer.TryGetNode(pump.OutletName, out PipeNode? outlet))
|
|| !nodeContainer.TryGetNode(pump.OutletName, out PipeNode? outlet))
|
||||||
{
|
{
|
||||||
appearance?.SetData(PressurePumpVisuals.Enabled, false);
|
appearance?.SetData(PumpVisuals.Enabled, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,13 +66,13 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
|||||||
|
|
||||||
if (MathHelper.CloseToPercent(pump.TargetPressure, outputStartingPressure))
|
if (MathHelper.CloseToPercent(pump.TargetPressure, outputStartingPressure))
|
||||||
{
|
{
|
||||||
appearance?.SetData(PressurePumpVisuals.Enabled, false);
|
appearance?.SetData(PumpVisuals.Enabled, false);
|
||||||
return; // No need to pump gas if target has been reached.
|
return; // No need to pump gas if target has been reached.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inlet.Air.TotalMoles > 0 && inlet.Air.Temperature > 0)
|
if (inlet.Air.TotalMoles > 0 && inlet.Air.Temperature > 0)
|
||||||
{
|
{
|
||||||
appearance?.SetData(PressurePumpVisuals.Enabled, true);
|
appearance?.SetData(PumpVisuals.Enabled, true);
|
||||||
|
|
||||||
// We calculate the necessary moles to transfer using our good ol' friend PV=nRT.
|
// We calculate the necessary moles to transfer using our good ol' friend PV=nRT.
|
||||||
var pressureDelta = pump.TargetPressure - outputStartingPressure;
|
var pressureDelta = pump.TargetPressure - outputStartingPressure;
|
||||||
@@ -91,7 +87,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
|||||||
{
|
{
|
||||||
if (EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
|
if (EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
|
||||||
{
|
{
|
||||||
appearance.SetData(PressurePumpVisuals.Enabled, false);
|
appearance.SetData(PumpVisuals.Enabled, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
using System;
|
|
||||||
using Content.Server.Administration.Logs;
|
using Content.Server.Administration.Logs;
|
||||||
using Content.Server.Atmos.EntitySystems;
|
using Content.Server.Atmos.EntitySystems;
|
||||||
using Content.Server.Atmos.Piping.Binary.Components;
|
using Content.Server.Atmos.Piping.Binary.Components;
|
||||||
using Content.Server.Atmos.Piping.Components;
|
using Content.Server.Atmos.Piping.Components;
|
||||||
using Content.Server.NodeContainer;
|
using Content.Server.NodeContainer;
|
||||||
using Content.Server.NodeContainer.Nodes;
|
using Content.Server.NodeContainer.Nodes;
|
||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos.Piping;
|
||||||
using Content.Shared.Atmos.Piping.Binary.Components;
|
using Content.Shared.Atmos.Piping.Binary.Components;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
@@ -13,9 +12,6 @@ using Content.Shared.Interaction;
|
|||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Localization;
|
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
||||||
@@ -54,18 +50,17 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
|||||||
|
|
||||||
private void OnVolumePumpUpdated(EntityUid uid, GasVolumePumpComponent pump, AtmosDeviceUpdateEvent args)
|
private void OnVolumePumpUpdated(EntityUid uid, GasVolumePumpComponent pump, AtmosDeviceUpdateEvent args)
|
||||||
{
|
{
|
||||||
if (!pump.Enabled)
|
TryComp(uid, out AppearanceComponent? appearance);
|
||||||
return;
|
|
||||||
|
|
||||||
if (!EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer))
|
if (!pump.Enabled
|
||||||
return;
|
|| !TryComp(uid, out NodeContainerComponent? nodeContainer)
|
||||||
|
|| !TryComp(uid, out AtmosDeviceComponent? device)
|
||||||
if (!EntityManager.TryGetComponent(uid, out AtmosDeviceComponent? device))
|
|| !nodeContainer.TryGetNode(pump.InletName, out PipeNode? inlet)
|
||||||
return;
|
|
||||||
|
|
||||||
if (!nodeContainer.TryGetNode(pump.InletName, out PipeNode? inlet)
|
|
||||||
|| !nodeContainer.TryGetNode(pump.OutletName, out PipeNode? outlet))
|
|| !nodeContainer.TryGetNode(pump.OutletName, out PipeNode? outlet))
|
||||||
|
{
|
||||||
|
appearance?.SetData(PumpVisuals.Enabled, false);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var inputStartingPressure = inlet.Air.Pressure;
|
var inputStartingPressure = inlet.Air.Pressure;
|
||||||
var outputStartingPressure = outlet.Air.Pressure;
|
var outputStartingPressure = outlet.Air.Pressure;
|
||||||
@@ -78,6 +73,8 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
|||||||
if ((outputStartingPressure - inputStartingPressure > pump.OverclockThreshold) && pump.Overclocked)
|
if ((outputStartingPressure - inputStartingPressure > pump.OverclockThreshold) && pump.Overclocked)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
appearance?.SetData(PumpVisuals.Enabled, true);
|
||||||
|
|
||||||
// We multiply the transfer rate in L/s by the seconds passed since the last process to get the liters.
|
// We multiply the transfer rate in L/s by the seconds passed since the last process to get the liters.
|
||||||
var transferRatio = (float)(pump.TransferRate * (_gameTiming.CurTime - device.LastProcess).TotalSeconds) / inlet.Air.Volume;
|
var transferRatio = (float)(pump.TransferRate * (_gameTiming.CurTime - device.LastProcess).TotalSeconds) / inlet.Air.Volume;
|
||||||
|
|
||||||
@@ -126,7 +123,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
|||||||
|
|
||||||
private void OnTransferRateChangeMessage(EntityUid uid, GasVolumePumpComponent pump, GasVolumePumpChangeTransferRateMessage args)
|
private void OnTransferRateChangeMessage(EntityUid uid, GasVolumePumpComponent pump, GasVolumePumpChangeTransferRateMessage args)
|
||||||
{
|
{
|
||||||
pump.TransferRate = Math.Clamp(args.TransferRate, 0f, Atmospherics.MaxTransferRate);
|
pump.TransferRate = Math.Clamp(args.TransferRate, 0f, pump.MaxTransferRate);
|
||||||
_adminLogSystem.Add(LogType.AtmosVolumeChanged, LogImpact.Medium,
|
_adminLogSystem.Add(LogType.AtmosVolumeChanged, LogImpact.Medium,
|
||||||
$"{ToPrettyString(args.Session.AttachedEntity!.Value):player} set the transfer rate on {ToPrettyString(uid):device} to {args.TransferRate}");
|
$"{ToPrettyString(args.Session.AttachedEntity!.Value):player} set the transfer rate on {ToPrettyString(uid):device} to {args.TransferRate}");
|
||||||
DirtyUI(uid, pump);
|
DirtyUI(uid, pump);
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
using System;
|
|
||||||
using Content.Server.Atmos.Piping.Trinary.EntitySystems;
|
|
||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
|
||||||
using Robust.Shared.ViewVariables;
|
|
||||||
|
|
||||||
namespace Content.Server.Atmos.Piping.Trinary.Components
|
namespace Content.Server.Atmos.Piping.Trinary.Components
|
||||||
{
|
{
|
||||||
@@ -26,8 +21,13 @@ namespace Content.Server.Atmos.Piping.Trinary.Components
|
|||||||
public string OutletName { get; set; } = "outlet";
|
public string OutletName { get; set; } = "outlet";
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
|
||||||
|
[DataField("transferRate")]
|
||||||
public float TransferRate { get; set; } = Atmospherics.MaxTransferRate;
|
public float TransferRate { get; set; } = Atmospherics.MaxTransferRate;
|
||||||
|
|
||||||
|
[DataField("maxTransferRate")]
|
||||||
|
public float MaxTransferRate { get; set; } = Atmospherics.MaxTransferRate;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public Gas? FilteredGas { get; set; }
|
public Gas? FilteredGas { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,13 @@ namespace Content.Server.Atmos.Piping.Trinary.Components
|
|||||||
public string OutletName = "outlet";
|
public string OutletName = "outlet";
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("targetPressure")]
|
||||||
public float TargetPressure = Atmospherics.OneAtmosphere;
|
public float TargetPressure = Atmospherics.OneAtmosphere;
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("maxTargetPressure")]
|
||||||
|
public float MaxTargetPressure = Atmospherics.MaxOutputPressure;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
[DataField("inletOneConcentration")]
|
[DataField("inletOneConcentration")]
|
||||||
public float InletOneConcentration = 0.5f;
|
public float InletOneConcentration = 0.5f;
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
|
|||||||
|
|
||||||
private void OnTransferRateChangeMessage(EntityUid uid, GasFilterComponent filter, GasFilterChangeRateMessage args)
|
private void OnTransferRateChangeMessage(EntityUid uid, GasFilterComponent filter, GasFilterChangeRateMessage args)
|
||||||
{
|
{
|
||||||
filter.TransferRate = Math.Clamp(args.Rate, 0f, Atmospherics.MaxTransferRate);
|
filter.TransferRate = Math.Clamp(args.Rate, 0f, filter.MaxTransferRate);
|
||||||
_adminLogSystem.Add(LogType.AtmosVolumeChanged, LogImpact.Medium,
|
_adminLogSystem.Add(LogType.AtmosVolumeChanged, LogImpact.Medium,
|
||||||
$"{ToPrettyString(args.Session.AttachedEntity!.Value):player} set the transfer rate on {ToPrettyString(uid):device} to {args.Rate}");
|
$"{ToPrettyString(args.Session.AttachedEntity!.Value):player} set the transfer rate on {ToPrettyString(uid):device} to {args.Rate}");
|
||||||
DirtyUI(uid, filter);
|
DirtyUI(uid, filter);
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
|
|||||||
|
|
||||||
private void OnOutputPressureChangeMessage(EntityUid uid, GasMixerComponent mixer, GasMixerChangeOutputPressureMessage args)
|
private void OnOutputPressureChangeMessage(EntityUid uid, GasMixerComponent mixer, GasMixerChangeOutputPressureMessage args)
|
||||||
{
|
{
|
||||||
mixer.TargetPressure = Math.Clamp(args.Pressure, 0f, Atmospherics.MaxOutputPressure);
|
mixer.TargetPressure = Math.Clamp(args.Pressure, 0f, mixer.MaxTargetPressure);
|
||||||
_adminLogSystem.Add(LogType.AtmosPressureChanged, LogImpact.Medium,
|
_adminLogSystem.Add(LogType.AtmosPressureChanged, LogImpact.Medium,
|
||||||
$"{ToPrettyString(args.Session.AttachedEntity!.Value):player} set the pressure on {ToPrettyString(uid):device} to {args.Pressure}kPa");
|
$"{ToPrettyString(args.Session.AttachedEntity!.Value):player} set the pressure on {ToPrettyString(uid):device} to {args.Pressure}kPa");
|
||||||
DirtyUI(uid, mixer);
|
DirtyUI(uid, mixer);
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using Robust.Shared.GameObjects;
|
using Content.Server.Atmos.Piping.Unary.EntitySystems;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Content.Shared.Atmos;
|
||||||
using Robust.Shared.ViewVariables;
|
|
||||||
|
|
||||||
namespace Content.Server.Atmos.Piping.Unary.Components
|
namespace Content.Server.Atmos.Piping.Unary.Components
|
||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
|
[Friend(typeof(GasOutletInjectorSystem))]
|
||||||
public sealed class GasOutletInjectorComponent : Component
|
public sealed class GasOutletInjectorComponent : Component
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -14,12 +14,26 @@ namespace Content.Server.Atmos.Piping.Unary.Components
|
|||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public bool Injecting { get; set; } = false;
|
public bool Injecting { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Target volume to transfer. If <see cref="WideNet"/> is enabled, actual transfer rate will be much higher.
|
||||||
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public float VolumeRate { get; set; } = 50f;
|
public float TransferRate
|
||||||
|
{
|
||||||
|
get => _transferRate;
|
||||||
|
set => _transferRate = Math.Clamp(value, 0f, MaxTransferRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
private float _transferRate = 50;
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("maxTransferRate")]
|
||||||
|
public float MaxTransferRate = Atmospherics.MaxTransferRate;
|
||||||
|
|
||||||
|
[DataField("maxPressure")]
|
||||||
|
public float MaxPressure { get; set; } = 2 * Atmospherics.MaxOutputPressure;
|
||||||
|
|
||||||
[DataField("inlet")]
|
[DataField("inlet")]
|
||||||
public string InletName { get; set; } = "pipe";
|
public string InletName { get; set; } = "pipe";
|
||||||
|
|
||||||
// TODO ATMOS: Inject method.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
using System;
|
|
||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
using Content.Shared.Atmos.Piping.Unary.Components;
|
using Content.Shared.Atmos.Piping.Unary.Components;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
|
||||||
using Robust.Shared.ViewVariables;
|
|
||||||
|
|
||||||
namespace Content.Server.Atmos.Piping.Unary.Components
|
namespace Content.Server.Atmos.Piping.Unary.Components
|
||||||
{
|
{
|
||||||
@@ -24,17 +20,57 @@ namespace Content.Server.Atmos.Piping.Unary.Components
|
|||||||
public string InletName { get; set; } = "pipe";
|
public string InletName { get; set; } = "pipe";
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("pumpDirection")]
|
||||||
public VentPumpDirection PumpDirection { get; set; } = VentPumpDirection.Releasing;
|
public VentPumpDirection PumpDirection { get; set; } = VentPumpDirection.Releasing;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("pressureChecks")]
|
||||||
public VentPressureBound PressureChecks { get; set; } = VentPressureBound.ExternalBound;
|
public VentPressureBound PressureChecks { get; set; } = VentPressureBound.ExternalBound;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
[DataField("externalPressureBound")]
|
[DataField("externalPressureBound")]
|
||||||
public float ExternalPressureBound { get; set; } = Atmospherics.OneAtmosphere;
|
public float ExternalPressureBound
|
||||||
|
{
|
||||||
|
get => _externalPressureBound;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_externalPressureBound = Math.Clamp(value, 0, MaxPressure);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float _externalPressureBound = Atmospherics.OneAtmosphere;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public float InternalPressureBound { get; set; } = 0f;
|
[DataField("internalPressureBound")]
|
||||||
|
public float InternalPressureBound
|
||||||
|
{
|
||||||
|
get => _internalPressureBound;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_internalPressureBound = Math.Clamp(value, 0, MaxPressure);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float _internalPressureBound = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Max pressure of the target gas (NOT relative to source).
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("maxPressure")]
|
||||||
|
public float MaxPressure = Atmospherics.MaxOutputPressure;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Pressure pump speed in kPa/s. Determines how much gas is moved.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The pump will attempt to modify the destination's final pressure by this quantity every second. If this
|
||||||
|
/// is too high, and the vent is connected to a large pipe-net, then someone can nearly instantly flood a
|
||||||
|
/// room with gas.
|
||||||
|
/// </remarks>
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("targetPressureChange")]
|
||||||
|
public float TargetPressureChange = Atmospherics.OneAtmosphere;
|
||||||
|
|
||||||
public GasVentPumpData ToAirAlarmData()
|
public GasVentPumpData ToAirAlarmData()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Content.Server.Atmos.Piping.Unary.EntitySystems;
|
||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
using Content.Shared.Atmos.Piping.Unary.Components;
|
using Content.Shared.Atmos.Piping.Unary.Components;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
|
||||||
using Robust.Shared.ViewVariables;
|
|
||||||
|
|
||||||
namespace Content.Server.Atmos.Piping.Unary.Components
|
namespace Content.Server.Atmos.Piping.Unary.Components
|
||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
|
[Friend(typeof(GasVentScrubberSystem))]
|
||||||
public sealed class GasVentScrubberComponent : Component
|
public sealed class GasVentScrubberComponent : Component
|
||||||
{
|
{
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
@@ -30,8 +28,28 @@ namespace Content.Server.Atmos.Piping.Unary.Components
|
|||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public ScrubberPumpDirection PumpDirection { get; set; } = ScrubberPumpDirection.Scrubbing;
|
public ScrubberPumpDirection PumpDirection { get; set; } = ScrubberPumpDirection.Scrubbing;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Target volume to transfer. If <see cref="WideNet"/> is enabled, actual transfer rate will be much higher.
|
||||||
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public float VolumeRate { get; set; } = 200f;
|
public float TransferRate
|
||||||
|
{
|
||||||
|
get => _transferRate;
|
||||||
|
set => _transferRate = Math.Clamp(value, 0f, MaxTransferRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
private float _transferRate = Atmospherics.MaxTransferRate;
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("maxTransferRate")]
|
||||||
|
public float MaxTransferRate = Atmospherics.MaxTransferRate;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// As pressure difference approaches this number, the effective volume rate may be smaller than <see
|
||||||
|
/// cref="TransferRate"/>
|
||||||
|
/// </summary>
|
||||||
|
[DataField("maxPressure")]
|
||||||
|
public float MaxPressure = Atmospherics.MaxOutputPressure;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public bool WideNet { get; set; } = false;
|
public bool WideNet { get; set; } = false;
|
||||||
@@ -46,7 +64,7 @@ namespace Content.Server.Atmos.Piping.Unary.Components
|
|||||||
Dirty = IsDirty,
|
Dirty = IsDirty,
|
||||||
FilterGases = FilterGases,
|
FilterGases = FilterGases,
|
||||||
PumpDirection = PumpDirection,
|
PumpDirection = PumpDirection,
|
||||||
VolumeRate = VolumeRate,
|
VolumeRate = TransferRate,
|
||||||
WideNet = WideNet
|
WideNet = WideNet
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -56,7 +74,7 @@ namespace Content.Server.Atmos.Piping.Unary.Components
|
|||||||
Enabled = data.Enabled;
|
Enabled = data.Enabled;
|
||||||
IsDirty = data.Dirty;
|
IsDirty = data.Dirty;
|
||||||
PumpDirection = (ScrubberPumpDirection) data.PumpDirection!;
|
PumpDirection = (ScrubberPumpDirection) data.PumpDirection!;
|
||||||
VolumeRate = (float) data.VolumeRate!;
|
TransferRate = (float) data.VolumeRate!;
|
||||||
WideNet = data.WideNet;
|
WideNet = data.WideNet;
|
||||||
|
|
||||||
if (!data.FilterGases!.SequenceEqual(FilterGases))
|
if (!data.FilterGases!.SequenceEqual(FilterGases))
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ using Content.Server.Atmos.Piping.Components;
|
|||||||
using Content.Server.Atmos.Piping.Unary.Components;
|
using Content.Server.Atmos.Piping.Unary.Components;
|
||||||
using Content.Server.NodeContainer;
|
using Content.Server.NodeContainer;
|
||||||
using Content.Server.NodeContainer.Nodes;
|
using Content.Server.NodeContainer.Nodes;
|
||||||
using Content.Shared.Atmos;
|
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.Timing;
|
||||||
using Robust.Shared.IoC;
|
|
||||||
|
|
||||||
namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||||
{
|
{
|
||||||
@@ -14,6 +12,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
|||||||
public sealed class GasOutletInjectorSystem : EntitySystem
|
public sealed class GasOutletInjectorSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||||
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -32,6 +31,9 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
|||||||
if (!EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer))
|
if (!EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!TryComp(uid, out AtmosDeviceComponent? device))
|
||||||
|
return;
|
||||||
|
|
||||||
if (!nodeContainer.TryGetNode(injector.InletName, out PipeNode? inlet))
|
if (!nodeContainer.TryGetNode(injector.InletName, out PipeNode? inlet))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -40,14 +42,14 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
|||||||
if (environment == null)
|
if (environment == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (inlet.Air.Temperature > 0)
|
if (inlet.Air.Temperature < 0)
|
||||||
{
|
return;
|
||||||
var transferMoles = inlet.Air.Pressure * injector.VolumeRate / (inlet.Air.Temperature * Atmospherics.R);
|
|
||||||
|
|
||||||
var removed = inlet.Air.Remove(transferMoles);
|
var timeDelta = (float) (_gameTiming.CurTime - device.LastProcess).TotalSeconds;
|
||||||
|
var ratio = MathF.Min(1f, timeDelta * injector.TransferRate / inlet.Air.Volume);
|
||||||
|
var removed = inlet.Air.RemoveRatio(ratio);
|
||||||
|
|
||||||
_atmosphereSystem.Merge(environment, removed);
|
_atmosphereSystem.Merge(environment, removed);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using System;
|
|
||||||
using Content.Server.Atmos.EntitySystems;
|
using Content.Server.Atmos.EntitySystems;
|
||||||
using Content.Server.Atmos.Monitor.Components;
|
using Content.Server.Atmos.Monitor.Components;
|
||||||
using Content.Server.Atmos.Monitor.Systems;
|
using Content.Server.Atmos.Monitor.Systems;
|
||||||
@@ -12,12 +11,10 @@ using Content.Server.NodeContainer.Nodes;
|
|||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
using Content.Shared.Atmos.Monitor;
|
using Content.Shared.Atmos.Monitor;
|
||||||
using Content.Shared.Atmos.Monitor.Components;
|
|
||||||
using Content.Shared.Atmos.Piping.Unary.Components;
|
using Content.Shared.Atmos.Piping.Unary.Components;
|
||||||
using Content.Shared.Atmos.Visuals;
|
using Content.Shared.Atmos.Visuals;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.Timing;
|
||||||
using Robust.Shared.IoC;
|
|
||||||
|
|
||||||
namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||||
{
|
{
|
||||||
@@ -26,6 +23,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||||
[Dependency] private readonly DeviceNetworkSystem _deviceNetSystem = default!;
|
[Dependency] private readonly DeviceNetworkSystem _deviceNetSystem = default!;
|
||||||
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -49,7 +47,8 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!vent.Enabled
|
if (!vent.Enabled
|
||||||
|| !EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer)
|
|| !TryComp(uid, out AtmosDeviceComponent? device)
|
||||||
|
|| !TryComp(uid, out NodeContainerComponent? nodeContainer)
|
||||||
|| !nodeContainer.TryGetNode(vent.InletName, out PipeNode? pipe))
|
|| !nodeContainer.TryGetNode(vent.InletName, out PipeNode? pipe))
|
||||||
{
|
{
|
||||||
appearance?.SetData(VentPumpVisuals.State, VentPumpState.Off);
|
appearance?.SetData(VentPumpVisuals.State, VentPumpState.Off);
|
||||||
@@ -65,43 +64,71 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vent.PumpDirection == VentPumpDirection.Releasing)
|
var timeDelta = (_gameTiming.CurTime - device.LastProcess).TotalSeconds;
|
||||||
|
var pressureDelta = (float) timeDelta * vent.TargetPressureChange;
|
||||||
|
|
||||||
|
if (vent.PumpDirection == VentPumpDirection.Releasing && pipe.Air.Pressure > 0)
|
||||||
{
|
{
|
||||||
appearance?.SetData(VentPumpVisuals.State, VentPumpState.Out);
|
appearance?.SetData(VentPumpVisuals.State, VentPumpState.Out);
|
||||||
var pressureDelta = 10000f;
|
|
||||||
|
if (environment.Pressure > vent.MaxPressure)
|
||||||
|
return;
|
||||||
|
|
||||||
if ((vent.PressureChecks & VentPressureBound.ExternalBound) != 0)
|
if ((vent.PressureChecks & VentPressureBound.ExternalBound) != 0)
|
||||||
pressureDelta = MathF.Min(pressureDelta, vent.ExternalPressureBound - environment.Pressure);
|
pressureDelta = MathF.Min(pressureDelta, vent.ExternalPressureBound - environment.Pressure);
|
||||||
|
|
||||||
|
if (pressureDelta <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// how many moles to transfer to change external pressure by pressureDelta
|
||||||
|
// (ignoring temperature differences because I am lazy)
|
||||||
|
var transferMoles = pressureDelta * environment.Volume / (pipe.Air.Temperature * Atmospherics.R);
|
||||||
|
|
||||||
|
// limit transferMoles so the source doesn't go below its bound.
|
||||||
if ((vent.PressureChecks & VentPressureBound.InternalBound) != 0)
|
if ((vent.PressureChecks & VentPressureBound.InternalBound) != 0)
|
||||||
pressureDelta = MathF.Min(pressureDelta, pipe.Air.Pressure - vent.InternalPressureBound);
|
|
||||||
|
|
||||||
if (pressureDelta > 0 && pipe.Air.Temperature > 0)
|
|
||||||
{
|
{
|
||||||
var transferMoles = pressureDelta * environment.Volume / (pipe.Air.Temperature * Atmospherics.R);
|
var internalDelta = pipe.Air.Pressure - vent.InternalPressureBound;
|
||||||
|
|
||||||
_atmosphereSystem.Merge(environment, pipe.Air.Remove(transferMoles));
|
if (internalDelta <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var maxTransfer = internalDelta * pipe.Air.Volume / (pipe.Air.Temperature * Atmospherics.R);
|
||||||
|
transferMoles = MathF.Min(transferMoles, maxTransfer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_atmosphereSystem.Merge(environment, pipe.Air.Remove(transferMoles));
|
||||||
}
|
}
|
||||||
else if (vent.PumpDirection == VentPumpDirection.Siphoning && environment.Pressure > 0)
|
else if (vent.PumpDirection == VentPumpDirection.Siphoning && environment.Pressure > 0)
|
||||||
{
|
{
|
||||||
appearance?.SetData(VentPumpVisuals.State, VentPumpState.In);
|
appearance?.SetData(VentPumpVisuals.State, VentPumpState.In);
|
||||||
var ourMultiplier = pipe.Air.Volume / (environment.Temperature * Atmospherics.R);
|
|
||||||
var molesDelta = 10000f * ourMultiplier;
|
|
||||||
|
|
||||||
if ((vent.PressureChecks & VentPressureBound.ExternalBound) != 0)
|
if (pipe.Air.Pressure > vent.MaxPressure)
|
||||||
molesDelta = MathF.Min(molesDelta,
|
return;
|
||||||
(environment.Pressure - vent.ExternalPressureBound) * environment.Volume /
|
|
||||||
(environment.Temperature * Atmospherics.R));
|
|
||||||
|
|
||||||
if ((vent.PressureChecks & VentPressureBound.InternalBound) != 0)
|
if ((vent.PressureChecks & VentPressureBound.InternalBound) != 0)
|
||||||
molesDelta = MathF.Min(molesDelta, (vent.InternalPressureBound - pipe.Air.Pressure) * ourMultiplier);
|
pressureDelta = MathF.Min(pressureDelta, vent.InternalPressureBound - pipe.Air.Pressure);
|
||||||
|
|
||||||
if (molesDelta > 0)
|
if (pressureDelta <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// how many moles to transfer to change internal pressure by pressureDelta
|
||||||
|
// (ignoring temperature differences because I am lazy)
|
||||||
|
var transferMoles = pressureDelta * pipe.Air.Volume / (environment.Temperature * Atmospherics.R);
|
||||||
|
|
||||||
|
// limit transferMoles so the source doesn't go below its bound.
|
||||||
|
if ((vent.PressureChecks & VentPressureBound.ExternalBound) != 0)
|
||||||
{
|
{
|
||||||
var removed = environment.Remove(molesDelta);
|
var externalDelta = environment.Pressure - vent.ExternalPressureBound;
|
||||||
_atmosphereSystem.Merge(pipe.Air, removed);
|
|
||||||
|
if (externalDelta <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var maxTransfer = externalDelta * environment.Volume / (environment.Temperature * Atmospherics.R);
|
||||||
|
|
||||||
|
transferMoles = MathF.Min(transferMoles, maxTransfer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_atmosphereSystem.Merge(pipe.Air, environment.Remove(transferMoles));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,15 +15,14 @@ using Content.Shared.Atmos.Piping.Unary.Visuals;
|
|||||||
using Content.Shared.Atmos.Monitor;
|
using Content.Shared.Atmos.Monitor;
|
||||||
using Content.Shared.Atmos.Piping.Unary.Components;
|
using Content.Shared.Atmos.Piping.Unary.Components;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.Timing;
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Maths;
|
|
||||||
|
|
||||||
namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||||
{
|
{
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class GasVentScrubberSystem : EntitySystem
|
public sealed class GasVentScrubberSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||||
[Dependency] private readonly DeviceNetworkSystem _deviceNetSystem = default!;
|
[Dependency] private readonly DeviceNetworkSystem _deviceNetSystem = default!;
|
||||||
|
|
||||||
@@ -36,7 +35,6 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
|||||||
SubscribeLocalEvent<GasVentScrubberComponent, AtmosMonitorAlarmEvent>(OnAtmosAlarm);
|
SubscribeLocalEvent<GasVentScrubberComponent, AtmosMonitorAlarmEvent>(OnAtmosAlarm);
|
||||||
SubscribeLocalEvent<GasVentScrubberComponent, PowerChangedEvent>(OnPowerChanged);
|
SubscribeLocalEvent<GasVentScrubberComponent, PowerChangedEvent>(OnPowerChanged);
|
||||||
SubscribeLocalEvent<GasVentScrubberComponent, PacketSentEvent>(OnPacketRecv);
|
SubscribeLocalEvent<GasVentScrubberComponent, PacketSentEvent>(OnPacketRecv);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnVentScrubberUpdated(EntityUid uid, GasVentScrubberComponent scrubber, AtmosDeviceUpdateEvent args)
|
private void OnVentScrubberUpdated(EntityUid uid, GasVentScrubberComponent scrubber, AtmosDeviceUpdateEvent args)
|
||||||
@@ -49,6 +47,11 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!TryComp(uid, out AtmosDeviceComponent? device))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var timeDelta = (float) (_gameTiming.CurTime - device.LastProcess).TotalSeconds;
|
||||||
|
|
||||||
if (!scrubber.Enabled
|
if (!scrubber.Enabled
|
||||||
|| !EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer)
|
|| !EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer)
|
||||||
|| !nodeContainer.TryGetNode(scrubber.OutletName, out PipeNode? outlet))
|
|| !nodeContainer.TryGetNode(scrubber.OutletName, out PipeNode? outlet))
|
||||||
@@ -59,14 +62,14 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
|||||||
|
|
||||||
var environment = _atmosphereSystem.GetTileMixture(EntityManager.GetComponent<TransformComponent>(scrubber.Owner).Coordinates, true);
|
var environment = _atmosphereSystem.GetTileMixture(EntityManager.GetComponent<TransformComponent>(scrubber.Owner).Coordinates, true);
|
||||||
|
|
||||||
Scrub(_atmosphereSystem, scrubber, appearance, environment, outlet);
|
Scrub(timeDelta, scrubber, appearance, environment, outlet);
|
||||||
|
|
||||||
if (!scrubber.WideNet) return;
|
if (!scrubber.WideNet) return;
|
||||||
|
|
||||||
// Scrub adjacent tiles too.
|
// Scrub adjacent tiles too.
|
||||||
foreach (var adjacent in _atmosphereSystem.GetAdjacentTileMixtures(EntityManager.GetComponent<TransformComponent>(scrubber.Owner).Coordinates, false, true))
|
foreach (var adjacent in _atmosphereSystem.GetAdjacentTileMixtures(EntityManager.GetComponent<TransformComponent>(scrubber.Owner).Coordinates, false, true))
|
||||||
{
|
{
|
||||||
Scrub(_atmosphereSystem, scrubber, null, adjacent, outlet);
|
Scrub(timeDelta, scrubber, null, adjacent, outlet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +81,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Scrub(AtmosphereSystem atmosphereSystem, GasVentScrubberComponent scrubber, AppearanceComponent? appearance, GasMixture? tile, PipeNode outlet)
|
private void Scrub(float timeDelta, GasVentScrubberComponent scrubber, AppearanceComponent? appearance, GasMixture? tile, PipeNode outlet)
|
||||||
{
|
{
|
||||||
// Cannot scrub if tile is null or air-blocked.
|
// Cannot scrub if tile is null or air-blocked.
|
||||||
if (tile == null
|
if (tile == null
|
||||||
@@ -88,29 +91,26 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Take a gas sample.
|
||||||
|
var ratio = MathF.Min(1f, timeDelta * scrubber.TransferRate / tile.Volume);
|
||||||
|
var removed = tile.RemoveRatio(ratio);
|
||||||
|
|
||||||
|
// Nothing left to remove from the tile.
|
||||||
|
if (MathHelper.CloseToPercent(removed.TotalMoles, 0f))
|
||||||
|
return;
|
||||||
|
|
||||||
if (scrubber.PumpDirection == ScrubberPumpDirection.Scrubbing)
|
if (scrubber.PumpDirection == ScrubberPumpDirection.Scrubbing)
|
||||||
{
|
{
|
||||||
appearance?.SetData(ScrubberVisuals.State, scrubber.WideNet ? ScrubberState.WideScrub : ScrubberState.Scrub);
|
appearance?.SetData(ScrubberVisuals.State, scrubber.WideNet ? ScrubberState.WideScrub : ScrubberState.Scrub);
|
||||||
var transferMoles = MathF.Min(1f, scrubber.VolumeRate / tile.Volume) * tile.TotalMoles;
|
|
||||||
|
|
||||||
// Take a gas sample.
|
_atmosphereSystem.ScrubInto(removed, outlet.Air, scrubber.FilterGases);
|
||||||
var removed = tile.Remove(transferMoles);
|
|
||||||
|
|
||||||
// Nothing left to remove from the tile.
|
|
||||||
if (MathHelper.CloseToPercent(removed.TotalMoles, 0f))
|
|
||||||
return;
|
|
||||||
|
|
||||||
atmosphereSystem.ScrubInto(removed, outlet.Air, scrubber.FilterGases);
|
|
||||||
|
|
||||||
// Remix the gases.
|
// Remix the gases.
|
||||||
atmosphereSystem.Merge(tile, removed);
|
_atmosphereSystem.Merge(tile, removed);
|
||||||
}
|
}
|
||||||
else if (scrubber.PumpDirection == ScrubberPumpDirection.Siphoning)
|
else if (scrubber.PumpDirection == ScrubberPumpDirection.Siphoning)
|
||||||
{
|
{
|
||||||
appearance?.SetData(ScrubberVisuals.State, ScrubberState.Siphon);
|
appearance?.SetData(ScrubberVisuals.State, ScrubberState.Siphon);
|
||||||
var transferMoles = tile.TotalMoles * (scrubber.VolumeRate / tile.Volume);
|
|
||||||
|
|
||||||
var removed = tile.Remove(transferMoles);
|
|
||||||
|
|
||||||
_atmosphereSystem.Merge(outlet.Air, removed);
|
_atmosphereSystem.Merge(outlet.Air, removed);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,12 +263,12 @@ namespace Content.Shared.Atmos
|
|||||||
#region Pipes
|
#region Pipes
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The pressure pumps and powered equipment max out at, in kPa.
|
/// The default pressure at which pumps and powered equipment max out at, in kPa.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const float MaxOutputPressure = 4500;
|
public const float MaxOutputPressure = 4500;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum speed powered equipment can work at, in L/s.
|
/// The default maximum speed powered equipment can work at, in L/s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const float MaxTransferRate = 200;
|
public const float MaxTransferRate = 200;
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace Content.Shared.Atmos.Piping
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public enum PressurePumpVisuals : byte
|
public enum PumpVisuals : byte
|
||||||
{
|
{
|
||||||
Enabled,
|
Enabled,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,5 +73,6 @@ namespace Content.Shared.Atmos.Piping.Unary.Components
|
|||||||
NoBound = 0,
|
NoBound = 0,
|
||||||
InternalBound = 1,
|
InternalBound = 1,
|
||||||
ExternalBound = 2,
|
ExternalBound = 2,
|
||||||
|
Both = 3,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,10 +67,13 @@
|
|||||||
state: pipeStraight
|
state: pipeStraight
|
||||||
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
map: [ "enum.PipeColorVisualizer+Layers.Pipe" ]
|
||||||
- state: pumpVolume
|
- state: pumpVolume
|
||||||
map: [ "enum.SubfloorLayers.FirstLayer" ]
|
map: [ "enum.SubfloorLayers.FirstLayer", "enum.PressurePumpVisualizer+Layers.Enabled" ]
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
visuals:
|
||||||
- type: PipeColorVisualizer
|
- type: PipeColorVisualizer
|
||||||
|
- type: PressurePumpVisualizer
|
||||||
|
disabledState: pumpVolume
|
||||||
|
enabledState: pumpVolumeOn
|
||||||
- type: GasVolumePump
|
- type: GasVolumePump
|
||||||
- type: UserInterface
|
- type: UserInterface
|
||||||
interfaces:
|
interfaces:
|
||||||
|
|||||||
Reference in New Issue
Block a user