diff --git a/Content.Server/Atmos/Piping/Binary/Components/GasRecyclerComponent.cs b/Content.Server/Atmos/Piping/Binary/Components/GasRecyclerComponent.cs index 03d4d95ed8..f7e00f58da 100644 --- a/Content.Server/Atmos/Piping/Binary/Components/GasRecyclerComponent.cs +++ b/Content.Server/Atmos/Piping/Binary/Components/GasRecyclerComponent.cs @@ -1,4 +1,6 @@ using Content.Shared.Atmos; +using Content.Shared.Construction.Prototypes; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; namespace Content.Server.Atmos.Piping.Binary.Components { @@ -16,5 +18,29 @@ namespace Content.Server.Atmos.Piping.Binary.Components [ViewVariables(VVAccess.ReadWrite)] [DataField("outlet")] public string OutletName { get; set; } = "outlet"; + + [ViewVariables(VVAccess.ReadWrite)] + public float MinTemp = 300 + Atmospherics.T0C; + + [DataField("BaseMinTemp")] + public float BaseMinTemp = 300 + Atmospherics.T0C; + + [DataField("machinePartMinTemp", customTypeSerializer: typeof(PrototypeIdSerializer))] + public string MachinePartMinTemp = "Laser"; + + [DataField("partRatingMinTempMultiplier")] + public float PartRatingMinTempMultiplier = 0.95f; + + [ViewVariables(VVAccess.ReadWrite)] + public float MinPressure = 30 * Atmospherics.OneAtmosphere; + + [DataField("BaseMinPressure")] + public float BaseMinPressure = 30 * Atmospherics.OneAtmosphere; + + [DataField("machinePartMinPressure", customTypeSerializer: typeof(PrototypeIdSerializer))] + public string MachinePartMinPressure = "Manipulator"; + + [DataField("partRatingMinPressureMultiplier")] + public float PartRatingMinPressureMultiplier = 0.8f; } } diff --git a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasRecyclerSystem.cs b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasRecyclerSystem.cs index 13aeb5ece5..adf947a2c0 100644 --- a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasRecyclerSystem.cs +++ b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasRecyclerSystem.cs @@ -2,24 +2,24 @@ using Content.Server.Atmos.EntitySystems; using Content.Shared.Atmos.Piping; using Content.Server.Atmos.Piping.Binary.Components; using Content.Server.Atmos.Piping.Components; +using Content.Server.Construction; using Content.Server.NodeContainer; using Content.Server.NodeContainer.Nodes; using Content.Shared.Atmos; using Content.Shared.Audio; using Content.Shared.Examine; using JetBrains.Annotations; +using Robust.Server.GameObjects; namespace Content.Server.Atmos.Piping.Binary.EntitySystems { [UsedImplicitly] public sealed class GasReyclerSystem : EntitySystem { + [Dependency] private readonly AppearanceSystem _appearance = default!; [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!; [Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!; - private const float MinTemp = 300 + Atmospherics.T0C; // 300 C - private const float MinPressure = 30 * Atmospherics.OneAtmosphere; // 3 MPa - public override void Initialize() { base.Initialize(); @@ -27,6 +27,8 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems SubscribeLocalEvent(OnUpdate); SubscribeLocalEvent(OnDisabled); SubscribeLocalEvent(OnExamined); + SubscribeLocalEvent(OnRefreshParts); + SubscribeLocalEvent(OnUpgradeExamine); } private void OnEnabled(EntityUid uid, GasRecyclerComponent comp, AtmosDeviceEnabledEvent args) @@ -41,7 +43,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems if (!EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer) || !nodeContainer.TryGetNode(comp.InletName, out PipeNode? inlet) - || !nodeContainer.TryGetNode(comp.OutletName, out PipeNode? outlet)) + || !nodeContainer.TryGetNode(comp.OutletName, out PipeNode? _)) { return; } @@ -52,12 +54,12 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems } else { - if (inlet.Air.Pressure < MinPressure) + if (inlet.Air.Pressure < comp.MinPressure) { args.PushMarkup(Loc.GetString("gas-recycler-low-pressure")); } - if (inlet.Air.Temperature < MinTemp) + if (inlet.Air.Temperature < comp.MinTemp) { args.PushMarkup(Loc.GetString("gas-recycler-low-temperature")); } @@ -75,7 +77,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems } // The gas recycler is a passive device, so it permits gas flow even if nothing is being reacted. - comp.Reacting = inlet.Air.Temperature >= MinTemp && inlet.Air.Pressure >= MinPressure; + comp.Reacting = inlet.Air.Temperature >= comp.MinTemp && inlet.Air.Pressure >= comp.MinPressure; var removed = inlet.Air.RemoveVolume(PassiveTransferVol(inlet.Air, outlet.Air)); if (comp.Reacting) { @@ -109,12 +111,27 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems UpdateAppearance(uid, comp); } - private void UpdateAppearance(EntityUid uid, GasRecyclerComponent? comp = null, AppearanceComponent? appearance = null) + private void UpdateAppearance(EntityUid uid, GasRecyclerComponent? comp = null) { - if (!Resolve(uid, ref comp, ref appearance, false)) + if (!Resolve(uid, ref comp, false)) return; - appearance.SetData(PumpVisuals.Enabled, comp.Reacting); + _appearance.SetData(uid, PumpVisuals.Enabled, comp.Reacting); + } + + private void OnRefreshParts(EntityUid uid, GasRecyclerComponent component, RefreshPartsEvent args) + { + var ratingTemp = args.PartRatings[component.MachinePartMinTemp]; + var ratingPressure = args.PartRatings[component.MachinePartMinPressure]; + + component.MinTemp = component.BaseMinTemp * MathF.Pow(component.PartRatingMinTempMultiplier, ratingTemp - 1); + component.MinPressure = component.BaseMinPressure * MathF.Pow(component.PartRatingMinPressureMultiplier, ratingPressure - 1); + } + + private void OnUpgradeExamine(EntityUid uid, GasRecyclerComponent component, UpgradeExamineEvent args) + { + args.AddPercentageUpgrade("gas-recycler-upgrade-min-temp", component.MinTemp / component.BaseMinTemp); + args.AddPercentageUpgrade("gas-recycler-upgrade-min-pressure", component.MinPressure / component.BaseMinPressure); } } } diff --git a/Resources/Locale/en-US/atmos/gas-recycler-system.ftl b/Resources/Locale/en-US/atmos/gas-recycler-system.ftl index cc527adf5c..a72e137732 100644 --- a/Resources/Locale/en-US/atmos/gas-recycler-system.ftl +++ b/Resources/Locale/en-US/atmos/gas-recycler-system.ftl @@ -1,3 +1,6 @@ gas-recycler-reacting = It is [color=green]converting[/color] waste gases. gas-recycler-low-pressure = The input pressure is [color=darkred]too low[/color]. gas-recycler-low-temperature = The input temperature is [color=darkred]too low[/color]. + +gas-recycler-upgrade-min-temp = Minimum temperature +gas-recycler-upgrade-min-pressure = Minimum pressure diff --git a/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml b/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml index 664eb9f55c..f834d422b7 100644 --- a/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml +++ b/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml @@ -583,6 +583,9 @@ components: - type: MachineBoard prototype: GasRecycler + requirements: + Laser: 2 + Manipulator: 2 materialRequirements: Steel: 10 - Plasma: 10 + Plasma: 5