diff --git a/Content.Client/IgnoredComponents.cs b/Content.Client/IgnoredComponents.cs index d92e3d3e30..41b437d227 100644 --- a/Content.Client/IgnoredComponents.cs +++ b/Content.Client/IgnoredComponents.cs @@ -163,6 +163,8 @@ "AMEFuelContainer", "AMEShield", "DebugPump", + "PressurePump", + "VolumePump", "DebugVent", "DebugSiphon", "SignalReceiver", diff --git a/Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs b/Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs index fd56e9d34d..215243a877 100644 --- a/Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs @@ -755,7 +755,7 @@ namespace Content.Server.GameObjects.Components.Atmos _currentRunPipeNetDevice = new Queue(_pipeNetDevices); var number = 0; - while (_currentRunPipeNet.Count > 0) + while (_currentRunPipeNetDevice.Count > 0) { var device = _currentRunPipeNetDevice.Dequeue(); device.Update(); diff --git a/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/DebugPumpComponent.cs b/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/DebugPumpComponent.cs deleted file mode 100644 index dfddf21cab..0000000000 --- a/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/DebugPumpComponent.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Content.Server.Atmos; -using Robust.Shared.GameObjects; - -namespace Content.Server.GameObjects.Components.Atmos.Piping -{ - /// - /// Placeholder example of pump functionality. - /// - [RegisterComponent] - [ComponentReference(typeof(BasePumpComponent))] - public class DebugPumpComponent : BasePumpComponent - { - public override string Name => "DebugPump"; - - protected override void PumpGas(GasMixture inletGas, GasMixture outletGas) - { - outletGas.Merge(inletGas); - inletGas.Clear(); - } - } -} diff --git a/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/PressurePumpComponent.cs b/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/PressurePumpComponent.cs new file mode 100644 index 0000000000..53ee049b00 --- /dev/null +++ b/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/PressurePumpComponent.cs @@ -0,0 +1,65 @@ +using Content.Server.Atmos; +using Robust.Shared.GameObjects; +using Robust.Shared.Serialization; +using Robust.Shared.ViewVariables; +using System; + +namespace Content.Server.GameObjects.Components.Atmos.Piping.Pumps +{ + [RegisterComponent] + [ComponentReference(typeof(BasePumpComponent))] + public class PressurePumpComponent : BasePumpComponent + { + public override string Name => "PressurePump"; + + /// + /// The pressure this pump will try to bring its oulet too. + /// + [ViewVariables(VVAccess.ReadWrite)] + public int PressurePumpTarget + { + get => _pressurePumpTarget; + set => _pressurePumpTarget = Math.Clamp(value, 0, MaxPressurePumpTarget); + } + private int _pressurePumpTarget; + + /// + /// Max value can be set to. + /// + [ViewVariables(VVAccess.ReadWrite)] + public int MaxPressurePumpTarget + { + get => _maxPressurePumpTarget; + set => Math.Max(value, 0); + } + private int _maxPressurePumpTarget; + + /// + /// Every upate, this pump will only increase the outlet pressure by this fraction of the amount needed to reach the . + /// + [ViewVariables(VVAccess.ReadWrite)] + public float TransferRatio + { + get => _transferRatio; + set => _transferRatio = Math.Clamp(value, 0, 1); + } + private float _transferRatio; + + public override void ExposeData(ObjectSerializer serializer) + { + base.ExposeData(serializer); + serializer.DataField(ref _pressurePumpTarget, "startingPressurePumpTarget", 0); + serializer.DataField(ref _maxPressurePumpTarget, "maxPressurePumpTarget", 100); + serializer.DataField(ref _transferRatio, "transferRatio", 0.5f); + } + + protected override void PumpGas(GasMixture inletGas, GasMixture outletGas) + { + var goalDiff = PressurePumpTarget - outletGas.Pressure; + var realGoalPressureDiff = goalDiff * TransferRatio; + var realTargetPressure = outletGas.Pressure + realGoalPressureDiff; + var realCappedTargetPressure = Math.Max(realTargetPressure, outletGas.Pressure); //no lowering the outlet's pressure + inletGas.PumpGasTo(outletGas, realCappedTargetPressure); + } + } +} diff --git a/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/VolumePumpComponent.cs b/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/VolumePumpComponent.cs new file mode 100644 index 0000000000..1787cce772 --- /dev/null +++ b/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/VolumePumpComponent.cs @@ -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)); + } + } +} diff --git a/Resources/Prototypes/Entities/Constructible/Ground/pumps.yml b/Resources/Prototypes/Entities/Constructible/Ground/pumps.yml index e3741e762e..d1f2ac0b5c 100644 --- a/Resources/Prototypes/Entities/Constructible/Ground/pumps.yml +++ b/Resources/Prototypes/Entities/Constructible/Ground/pumps.yml @@ -17,9 +17,9 @@ thresholdvalue: 100 - type: entity + abstract: true parent: PumpBase - id: NorthFromSouthPipePump - name: North from south pipe pump + id: NorthwardLongitudinalPump components: - type: Sprite state: mvcable_3 @@ -27,10 +27,26 @@ nodes: - !type:PipeNode nodeGroupID: Pipe - pipeDirection: North + pipeDirection: South - !type:PipeNode nodeGroupID: Pipe - pipeDirection: South - - type: DebugPump - outletDirection: North + pipeDirection: North + +- type: entity + parent: NorthwardLongitudinalPump + id: NorthwardLongitudinalVolumePump + name: Northward Longitudinal Volume Pump + components: + - type: VolumePump inletDirection: South + outletDirection: North + +- type: entity + parent: NorthwardLongitudinalPump + id: NorthwardLongitudinalPressurePump + name: Northward Longitudinal Pressure Pump + components: + - type: PressurePump + inletDirection: South + outletDirection: North + \ No newline at end of file