diff --git a/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/PressurePumpComponent.cs b/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/PressurePumpComponent.cs index c44fc5cdda..33c1ceaa2d 100644 --- a/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/PressurePumpComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/PressurePumpComponent.cs @@ -35,7 +35,7 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Pumps private int _maxPressurePumpTarget; /// - /// Every upate, this pump will only increase the outlet pressure by this fraction of the amount needed to reach the . + /// Every update, this pump will only increase the outlet pressure by this fraction of the amount needed to reach the . /// [ViewVariables(VVAccess.ReadWrite)] public float TransferRatio diff --git a/Content.Server/GameObjects/Components/Atmos/Piping/Vents/DebugVentComponent.cs b/Content.Server/GameObjects/Components/Atmos/Piping/Vents/DebugVentComponent.cs deleted file mode 100644 index 133d6e5b24..0000000000 --- a/Content.Server/GameObjects/Components/Atmos/Piping/Vents/DebugVentComponent.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Content.Server.Atmos; -using Robust.Shared.GameObjects; - -namespace Content.Server.GameObjects.Components.Atmos.Piping.Vents -{ - /// - /// Placeholder example of vent functionality. - /// - [RegisterComponent] - [ComponentReference(typeof(BaseVentComponent))] - public class DebugVentComponent : BaseVentComponent - { - public override string Name => "DebugVent"; - - protected override void VentGas(GasMixture inletGas, GasMixture outletGas) - { - outletGas.Merge(inletGas); - inletGas.Clear(); - } - } -} diff --git a/Content.Server/GameObjects/Components/Atmos/Piping/Vents/PressureVentComponent.cs b/Content.Server/GameObjects/Components/Atmos/Piping/Vents/PressureVentComponent.cs new file mode 100644 index 0000000000..7f853a7761 --- /dev/null +++ b/Content.Server/GameObjects/Components/Atmos/Piping/Vents/PressureVentComponent.cs @@ -0,0 +1,66 @@ +using Content.Server.Atmos; +using Content.Shared.Atmos; +using Robust.Shared.GameObjects; +using Robust.Shared.Serialization; +using Robust.Shared.ViewVariables; +using System; + +namespace Content.Server.GameObjects.Components.Atmos.Piping.Vents +{ + [RegisterComponent] + [ComponentReference(typeof(BaseVentComponent))] + public class PressureVentComponent : BaseVentComponent + { + public override string Name => "PressureVent"; + + /// + /// The pressure this vent will try to bring its oulet to. + /// + [ViewVariables(VVAccess.ReadWrite)] + public float VentPressureTarget + { + get => _ventPressureTarget; + set => _ventPressureTarget = Math.Clamp(value, 0, MaxVentPressureTarget); + } + private float _ventPressureTarget; + + /// + /// Max value can be set to. + /// + [ViewVariables(VVAccess.ReadWrite)] + public float MaxVentPressureTarget + { + get => _maxVentPressureTarget; + set => Math.Max(value, 0); + } + private float _maxVentPressureTarget; + + /// + /// Every update, this vent 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 _ventPressureTarget, "startingVentPressureTarget", Atmospherics.OneAtmosphere); + serializer.DataField(ref _maxVentPressureTarget, "maxVentPressureTarget", Atmospherics.OneAtmosphere * 2); + serializer.DataField(ref _transferRatio, "transferRatio", 0.5f); + } + + protected override void VentGas(GasMixture inletGas, GasMixture outletGas) + { + var goalDiff = VentPressureTarget - 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/Resources/Prototypes/Entities/Constructible/Ground/pipes.yml b/Resources/Prototypes/Entities/Constructible/Ground/pipes.yml index 03f38c496b..a2600c5efb 100644 --- a/Resources/Prototypes/Entities/Constructible/Ground/pipes.yml +++ b/Resources/Prototypes/Entities/Constructible/Ground/pipes.yml @@ -9,8 +9,6 @@ - type: Collidable - type: SnapGrid offset: Center - - type: Icon - texture: Constructible/Atmos/pipe.rsi/pipeLateral2.png - type: Sprite - type: Destructible thresholdvalue: 100 diff --git a/Resources/Prototypes/Entities/Constructible/Ground/vents.yml b/Resources/Prototypes/Entities/Constructible/Ground/vents.yml index 266ec92066..4316be138a 100644 --- a/Resources/Prototypes/Entities/Constructible/Ground/vents.yml +++ b/Resources/Prototypes/Entities/Constructible/Ground/vents.yml @@ -34,5 +34,5 @@ - !type:PipeNode nodeGroupID: Pipe pipeDirection: South - - type: DebugVent + - type: PressureVent ventInletDirection: South