Limit atmos device rates (#6533)

This commit is contained in:
Leon Friedrich
2022-03-01 03:39:30 +13:00
committed by GitHub
parent ffed5eec81
commit ee7d0440f3
20 changed files with 220 additions and 116 deletions

View File

@@ -1,14 +1,12 @@
using System.Collections.Generic;
using System.Linq;
using Content.Server.Atmos.Piping.Unary.EntitySystems;
using Content.Shared.Atmos;
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
{
[RegisterComponent]
[Friend(typeof(GasVentScrubberSystem))]
public sealed class GasVentScrubberComponent : Component
{
[ViewVariables(VVAccess.ReadWrite)]
@@ -30,8 +28,28 @@ namespace Content.Server.Atmos.Piping.Unary.Components
[ViewVariables(VVAccess.ReadWrite)]
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)]
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)]
public bool WideNet { get; set; } = false;
@@ -46,7 +64,7 @@ namespace Content.Server.Atmos.Piping.Unary.Components
Dirty = IsDirty,
FilterGases = FilterGases,
PumpDirection = PumpDirection,
VolumeRate = VolumeRate,
VolumeRate = TransferRate,
WideNet = WideNet
};
}
@@ -56,7 +74,7 @@ namespace Content.Server.Atmos.Piping.Unary.Components
Enabled = data.Enabled;
IsDirty = data.Dirty;
PumpDirection = (ScrubberPumpDirection) data.PumpDirection!;
VolumeRate = (float) data.VolumeRate!;
TransferRate = (float) data.VolumeRate!;
WideNet = data.WideNet;
if (!data.FilterGases!.SequenceEqual(FilterGases))