From 24a3c8aef6018106ac34bdb39ee310642399c503 Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Sat, 22 Oct 2022 18:49:30 -0400 Subject: [PATCH] portable scrubber machine upgrading (#12037) --- .../Portable/PortableScrubberComponent.cs | 65 +++++++++++++++---- .../Atmos/Portable/PortableScrubberSystem.cs | 51 ++++++++------- .../Circuitboards/Machine/production.yml | 4 +- 3 files changed, 82 insertions(+), 38 deletions(-) diff --git a/Content.Server/Atmos/Portable/PortableScrubberComponent.cs b/Content.Server/Atmos/Portable/PortableScrubberComponent.cs index 822022e2bb..4dab51e734 100644 --- a/Content.Server/Atmos/Portable/PortableScrubberComponent.cs +++ b/Content.Server/Atmos/Portable/PortableScrubberComponent.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.Portable { @@ -8,12 +10,10 @@ namespace Content.Server.Atmos.Portable /// /// The air inside this machine. /// - [ViewVariables(VVAccess.ReadWrite)] - [DataField("gasMixture")] + [DataField("gasMixture"), ViewVariables(VVAccess.ReadWrite)] public GasMixture Air { get; } = new(); - [ViewVariables(VVAccess.ReadWrite)] - [DataField("port")] + [DataField("port"), ViewVariables(VVAccess.ReadWrite)] public string PortName { get; set; } = "port"; /// @@ -33,18 +33,57 @@ namespace Content.Server.Atmos.Portable Gas.Frezon }; - /// - /// Can this scrubber hold more gas? - /// - public bool Full => Air.Pressure >= MaxPressure; + [ViewVariables(VVAccess.ReadWrite)] + public bool Enabled = true; /// /// Maximum internal pressure before it refuses to take more. /// - [DataField("maxPressure")] - public float MaxPressure = 3000f; - [DataField("transferRate")] - public float TransferRate = 1000f; - public bool Enabled = true; + [ViewVariables(VVAccess.ReadWrite)] + public float MaxPressure = 2500; + + /// + /// The base amount of maximum internal pressure + /// + [DataField("baseMaxPressure")] + public float BaseMaxPressure = 2500; + + /// + /// The machine part that modifies the maximum internal pressure + /// + [DataField("machinePartMaxPressure", customTypeSerializer: typeof(PrototypeIdSerializer))] + public string MachinePartMaxPressure = "MatterBin"; + + /// + /// How much the will affect the pressure. + /// The value will be multiplied by this amount for each increasing part tier. + /// + [DataField("partRatingMaxPressureModifier")] + public float PartRatingMaxPressureModifier = 1.5f; + + /// + /// The speed at which gas is scrubbed from the environment. + /// + [ViewVariables(VVAccess.ReadWrite)] + public float TransferRate = 800; + + /// + /// The base speed at which gas is scrubbed from the environment. + /// + [DataField("baseTransferRate")] + public float BaseTransferRate = 800; + + /// + /// The machine part which modifies the speed of + /// + [DataField("machinePartTransferRate", customTypeSerializer: typeof(PrototypeIdSerializer))] + public string MachinePartTransferRate = "Manipulator"; + + /// + /// How much the will modify the rate. + /// The value will be multiplied by this amount for each increasing part tier. + /// + [DataField("partRatingTransferRateModifier")] + public float PartRatingTransferRateModifier = 1.4f; } } diff --git a/Content.Server/Atmos/Portable/PortableScrubberSystem.cs b/Content.Server/Atmos/Portable/PortableScrubberSystem.cs index e4b6c92da7..a9cf9d9d2a 100644 --- a/Content.Server/Atmos/Portable/PortableScrubberSystem.cs +++ b/Content.Server/Atmos/Portable/PortableScrubberSystem.cs @@ -13,10 +13,9 @@ using Content.Server.NodeContainer.Nodes; using Content.Server.NodeContainer.NodeGroups; using Content.Server.Audio; using Content.Server.Administration.Logs; +using Content.Server.Construction; using Content.Shared.Database; - - namespace Content.Server.Atmos.Portable { public sealed class PortableScrubberSystem : EntitySystem @@ -29,6 +28,7 @@ namespace Content.Server.Atmos.Portable [Dependency] private readonly TransformSystem _transformSystem = default!; [Dependency] private readonly IAdminLogManager _adminLogger = default!; [Dependency] private readonly AmbientSoundSystem _ambientSound = default!; + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; public override void Initialize() { @@ -39,6 +39,12 @@ namespace Content.Server.Atmos.Portable SubscribeLocalEvent(OnExamined); SubscribeLocalEvent(OnDestroyed); SubscribeLocalEvent(OnScrubberAnalyzed); + SubscribeLocalEvent(OnRefreshParts); + } + + private bool IsFull(PortableScrubberComponent component) + { + return component.Air.Pressure >= component.MaxPressure; } private void OnDeviceUpdated(EntityUid uid, PortableScrubberComponent component, AtmosDeviceUpdateEvent args) @@ -51,7 +57,7 @@ namespace Content.Server.Atmos.Portable if (!component.Enabled) return; - /// If we are on top of a connector port, empty into it. + // If we are on top of a connector port, empty into it. if (TryComp(uid, out var nodeContainer) && nodeContainer.TryGetNode(component.PortName, out PortablePipeNode? portableNode) && portableNode.ConnectionsEnabled) @@ -61,7 +67,7 @@ namespace Content.Server.Atmos.Portable _canisterSystem.MixContainerWithPipeNet(component.Air, net.Air); } - if (component.Full) + if (IsFull(component)) { UpdateAppearance(uid, true, false); return; @@ -79,13 +85,13 @@ namespace Content.Server.Atmos.Portable var running = Scrub(timeDelta, component, environment); UpdateAppearance(uid, false, running); - /// We scrub once to see if we can and set the animation + // We scrub once to see if we can and set the animation if (!running) return; - /// widenet + // widenet foreach (var adjacent in _atmosphereSystem.GetAdjacentTileMixtures(xform.GridUid.Value, position, false, true)) { - Scrub(timeDelta, component, environment); + Scrub(timeDelta, component, adjacent); } } @@ -102,11 +108,12 @@ namespace Content.Server.Atmos.Portable portableNode.ConnectionsEnabled = (args.Anchored && _gasPortableSystem.FindGasPortIn(Transform(uid).GridUid, Transform(uid).Coordinates, out _)); - UpdateDrainingAppearance(uid, portableNode.ConnectionsEnabled); + _appearance.SetData(uid, PortableScrubberVisuals.IsDraining, portableNode.ConnectionsEnabled); } + private void OnPowerChanged(EntityUid uid, PortableScrubberComponent component, ref PowerChangedEvent args) { - UpdateAppearance(uid, component.Full, args.Powered); + UpdateAppearance(uid, IsFull(component), args.Powered); component.Enabled = args.Powered; } @@ -132,7 +139,7 @@ namespace Content.Server.Atmos.Portable if (environment != null) _atmosphereSystem.Merge(environment, component.Air); - _adminLogger.Add(LogType.CanisterPurged, LogImpact.Medium, $"Portable scrubber {ToPrettyString(uid):canister} purged its contents of {component.Air:gas} into the environment."); + _adminLogger.Add(LogType.CanisterPurged, LogImpact.Medium, $"Portable scrubber {ToPrettyString(uid):canister} purged its contents of {component.Air} into the environment."); component.Air.Clear(); } @@ -143,21 +150,10 @@ namespace Content.Server.Atmos.Portable private void UpdateAppearance(EntityUid uid, bool isFull, bool isRunning) { - if (!TryComp(uid, out var appearance)) - return; - _ambientSound.SetAmbience(uid, isRunning); - appearance.SetData(PortableScrubberVisuals.IsFull, isFull); - appearance.SetData(PortableScrubberVisuals.IsRunning, isRunning); - } - - private void UpdateDrainingAppearance(EntityUid uid, bool isDraining) - { - if (!TryComp(uid, out var appearance)) - return; - - appearance.SetData(PortableScrubberVisuals.IsDraining, isDraining); + _appearance.SetData(uid, PortableScrubberVisuals.IsFull, isFull); + _appearance.SetData(uid, PortableScrubberVisuals.IsRunning, isRunning); } /// @@ -174,5 +170,14 @@ namespace Content.Server.Atmos.Portable } args.GasMixtures = gasMixDict; } + + private void OnRefreshParts(EntityUid uid, PortableScrubberComponent component, RefreshPartsEvent args) + { + var pressureRating = args.PartRatings[component.MachinePartMaxPressure]; + var transferRating = args.PartRatings[component.MachinePartTransferRate]; + + component.MaxPressure = component.BaseMaxPressure * MathF.Pow(component.PartRatingMaxPressureModifier, pressureRating - 1); + component.TransferRate = component.BaseTransferRate * MathF.Pow(component.PartRatingTransferRateModifier, transferRating - 1); + } } } diff --git a/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml b/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml index 5c01376e5d..c90b978dbd 100644 --- a/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml +++ b/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml @@ -182,10 +182,10 @@ prototype: PortableScrubber requirements: MatterBin: 3 - Laser: 2 - ScanningModule: 1 + Manipulator: 2 materialRequirements: Cable: 5 + Glass: 2 - type: entity id: CloningPodMachineCircuitboard