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>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user