Files
tbd-station-14/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/VolumePumpComponent.cs
py01 9d5278ab0d Volume and pressure pump (#1955)
* PressurePump and VolumePump

* VolumePump fix

* PressurePump fix

* volume pump simplification

* Fixes GridAtmosphereComponent not updating pumps

Co-authored-by: py01 <pyronetics01@gmail.com>
2020-08-31 02:13:23 +02:00

47 lines
1.5 KiB
C#

using Content.Server.Atmos;
using Content.Shared.Atmos;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using System;
using System.Diagnostics;
namespace Content.Server.GameObjects.Components.Atmos.Piping.Pumps
{
[RegisterComponent]
[ComponentReference(typeof(BasePumpComponent))]
public class VolumePumpComponent : BasePumpComponent
{
[ViewVariables(VVAccess.ReadWrite)]
public int VolumePumpRate
{
get => _volumePumpRate;
set => _volumePumpRate = Math.Clamp(value, 0, MaxVolumePumpRate);
}
private int _volumePumpRate;
[ViewVariables(VVAccess.ReadWrite)]
public int MaxVolumePumpRate
{
get => _maxVolumePumpRate;
set => Math.Max(value, 0);
}
private int _maxVolumePumpRate;
public override string Name => "VolumePump";
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _volumePumpRate, "startingVolumePumpRate", 0);
serializer.DataField(ref _maxVolumePumpRate, "maxVolumePumpRate", 100);
}
protected override void PumpGas(GasMixture inletGas, GasMixture outletGas)
{
var volumeRatio = Math.Clamp(VolumePumpRate / inletGas.Volume, 0, 1);
outletGas.Merge(inletGas.RemoveRatio(volumeRatio));
}
}
}