Limit atmos device rates (#6533)
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
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
|
||||
{
|
||||
@@ -28,6 +25,7 @@ namespace Content.Server.Atmos.Piping.Binary.Components
|
||||
public string OutletName { get; set; } = "outlet";
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("targetPressure")]
|
||||
public float TargetPressure { get; set; } = Atmospherics.OneAtmosphere;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
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
|
||||
{
|
||||
@@ -20,6 +17,14 @@ namespace Content.Server.Atmos.Piping.Binary.Components
|
||||
public string OutletName { get; set; } = "outlet";
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("targetPressure")]
|
||||
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 Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Atmos.Piping.Binary.Components
|
||||
{
|
||||
@@ -23,8 +20,13 @@ namespace Content.Server.Atmos.Piping.Binary.Components
|
||||
public string OutletName { get; set; } = "outlet";
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("transferRate")]
|
||||
public float TransferRate { get; set; } = Atmospherics.MaxTransferRate;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("maxTransferRate")]
|
||||
public float MaxTransferRate { get; set; } = Atmospherics.MaxTransferRate;
|
||||
|
||||
[DataField("leakRatio")]
|
||||
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;
|
||||
|
||||
[DataField("higherThreshold")]
|
||||
public float HigherThreshold { get; set; } = 9000f;
|
||||
public float HigherThreshold { get; set; } = 2 * Atmospherics.MaxOutputPressure;
|
||||
|
||||
[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 JetBrains.Annotations;
|
||||
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
|
||||
{
|
||||
@@ -62,7 +58,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
||||
|| !nodeContainer.TryGetNode(pump.InletName, out PipeNode? inlet)
|
||||
|| !nodeContainer.TryGetNode(pump.OutletName, out PipeNode? outlet))
|
||||
{
|
||||
appearance?.SetData(PressurePumpVisuals.Enabled, false);
|
||||
appearance?.SetData(PumpVisuals.Enabled, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -70,13 +66,13 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
||||
|
||||
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.
|
||||
}
|
||||
|
||||
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.
|
||||
var pressureDelta = pump.TargetPressure - outputStartingPressure;
|
||||
@@ -91,7 +87,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
||||
{
|
||||
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.Atmos.EntitySystems;
|
||||
using Content.Server.Atmos.Piping.Binary.Components;
|
||||
using Content.Server.Atmos.Piping.Components;
|
||||
using Content.Server.NodeContainer;
|
||||
using Content.Server.NodeContainer.Nodes;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Atmos.Piping;
|
||||
using Content.Shared.Atmos.Piping.Binary.Components;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Examine;
|
||||
@@ -13,9 +12,6 @@ using Content.Shared.Interaction;
|
||||
using Content.Shared.Popups;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
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)
|
||||
{
|
||||
if (!pump.Enabled)
|
||||
return;
|
||||
TryComp(uid, out AppearanceComponent? appearance);
|
||||
|
||||
if (!EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer))
|
||||
return;
|
||||
|
||||
if (!EntityManager.TryGetComponent(uid, out AtmosDeviceComponent? device))
|
||||
return;
|
||||
|
||||
if (!nodeContainer.TryGetNode(pump.InletName, out PipeNode? inlet)
|
||||
if (!pump.Enabled
|
||||
|| !TryComp(uid, out NodeContainerComponent? nodeContainer)
|
||||
|| !TryComp(uid, out AtmosDeviceComponent? device)
|
||||
|| !nodeContainer.TryGetNode(pump.InletName, out PipeNode? inlet)
|
||||
|| !nodeContainer.TryGetNode(pump.OutletName, out PipeNode? outlet))
|
||||
{
|
||||
appearance?.SetData(PumpVisuals.Enabled, false);
|
||||
return;
|
||||
}
|
||||
|
||||
var inputStartingPressure = inlet.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)
|
||||
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.
|
||||
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)
|
||||
{
|
||||
pump.TransferRate = Math.Clamp(args.TransferRate, 0f, Atmospherics.MaxTransferRate);
|
||||
pump.TransferRate = Math.Clamp(args.TransferRate, 0f, pump.MaxTransferRate);
|
||||
_adminLogSystem.Add(LogType.AtmosVolumeChanged, LogImpact.Medium,
|
||||
$"{ToPrettyString(args.Session.AttachedEntity!.Value):player} set the transfer rate on {ToPrettyString(uid):device} to {args.TransferRate}");
|
||||
DirtyUI(uid, pump);
|
||||
|
||||
Reference in New Issue
Block a user