portable scrubber machine upgrading (#12037)

This commit is contained in:
Nemanja
2022-10-22 18:49:30 -04:00
committed by GitHub
parent cc0b610333
commit 24a3c8aef6
3 changed files with 82 additions and 38 deletions

View File

@@ -1,4 +1,6 @@
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Content.Shared.Construction.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Atmos.Portable namespace Content.Server.Atmos.Portable
{ {
@@ -8,12 +10,10 @@ namespace Content.Server.Atmos.Portable
/// <summary> /// <summary>
/// The air inside this machine. /// The air inside this machine.
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite)] [DataField("gasMixture"), ViewVariables(VVAccess.ReadWrite)]
[DataField("gasMixture")]
public GasMixture Air { get; } = new(); public GasMixture Air { get; } = new();
[ViewVariables(VVAccess.ReadWrite)] [DataField("port"), ViewVariables(VVAccess.ReadWrite)]
[DataField("port")]
public string PortName { get; set; } = "port"; public string PortName { get; set; } = "port";
/// <summary> /// <summary>
@@ -33,18 +33,57 @@ namespace Content.Server.Atmos.Portable
Gas.Frezon Gas.Frezon
}; };
/// <summary> [ViewVariables(VVAccess.ReadWrite)]
/// Can this scrubber hold more gas? public bool Enabled = true;
/// </summary>
public bool Full => Air.Pressure >= MaxPressure;
/// <summary> /// <summary>
/// Maximum internal pressure before it refuses to take more. /// Maximum internal pressure before it refuses to take more.
/// </summary> /// </summary>
[DataField("maxPressure")] [ViewVariables(VVAccess.ReadWrite)]
public float MaxPressure = 3000f; public float MaxPressure = 2500;
[DataField("transferRate")]
public float TransferRate = 1000f; /// <summary>
public bool Enabled = true; /// The base amount of maximum internal pressure
/// </summary>
[DataField("baseMaxPressure")]
public float BaseMaxPressure = 2500;
/// <summary>
/// The machine part that modifies the maximum internal pressure
/// </summary>
[DataField("machinePartMaxPressure", customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>))]
public string MachinePartMaxPressure = "MatterBin";
/// <summary>
/// How much the <see cref="MachinePartMaxPressure"/> will affect the pressure.
/// The value will be multiplied by this amount for each increasing part tier.
/// </summary>
[DataField("partRatingMaxPressureModifier")]
public float PartRatingMaxPressureModifier = 1.5f;
/// <summary>
/// The speed at which gas is scrubbed from the environment.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public float TransferRate = 800;
/// <summary>
/// The base speed at which gas is scrubbed from the environment.
/// </summary>
[DataField("baseTransferRate")]
public float BaseTransferRate = 800;
/// <summary>
/// The machine part which modifies the speed of <see cref="TransferRate"/>
/// </summary>
[DataField("machinePartTransferRate", customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>))]
public string MachinePartTransferRate = "Manipulator";
/// <summary>
/// How much the <see cref="MachinePartTransferRate"/> will modify the rate.
/// The value will be multiplied by this amount for each increasing part tier.
/// </summary>
[DataField("partRatingTransferRateModifier")]
public float PartRatingTransferRateModifier = 1.4f;
} }
} }

View File

@@ -13,10 +13,9 @@ using Content.Server.NodeContainer.Nodes;
using Content.Server.NodeContainer.NodeGroups; using Content.Server.NodeContainer.NodeGroups;
using Content.Server.Audio; using Content.Server.Audio;
using Content.Server.Administration.Logs; using Content.Server.Administration.Logs;
using Content.Server.Construction;
using Content.Shared.Database; using Content.Shared.Database;
namespace Content.Server.Atmos.Portable namespace Content.Server.Atmos.Portable
{ {
public sealed class PortableScrubberSystem : EntitySystem public sealed class PortableScrubberSystem : EntitySystem
@@ -29,6 +28,7 @@ namespace Content.Server.Atmos.Portable
[Dependency] private readonly TransformSystem _transformSystem = default!; [Dependency] private readonly TransformSystem _transformSystem = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!; [Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly AmbientSoundSystem _ambientSound = default!; [Dependency] private readonly AmbientSoundSystem _ambientSound = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -39,6 +39,12 @@ namespace Content.Server.Atmos.Portable
SubscribeLocalEvent<PortableScrubberComponent, ExaminedEvent>(OnExamined); SubscribeLocalEvent<PortableScrubberComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<PortableScrubberComponent, DestructionEventArgs>(OnDestroyed); SubscribeLocalEvent<PortableScrubberComponent, DestructionEventArgs>(OnDestroyed);
SubscribeLocalEvent<PortableScrubberComponent, GasAnalyzerScanEvent>(OnScrubberAnalyzed); SubscribeLocalEvent<PortableScrubberComponent, GasAnalyzerScanEvent>(OnScrubberAnalyzed);
SubscribeLocalEvent<PortableScrubberComponent, RefreshPartsEvent>(OnRefreshParts);
}
private bool IsFull(PortableScrubberComponent component)
{
return component.Air.Pressure >= component.MaxPressure;
} }
private void OnDeviceUpdated(EntityUid uid, PortableScrubberComponent component, AtmosDeviceUpdateEvent args) private void OnDeviceUpdated(EntityUid uid, PortableScrubberComponent component, AtmosDeviceUpdateEvent args)
@@ -51,7 +57,7 @@ namespace Content.Server.Atmos.Portable
if (!component.Enabled) if (!component.Enabled)
return; 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<NodeContainerComponent>(uid, out var nodeContainer) if (TryComp<NodeContainerComponent>(uid, out var nodeContainer)
&& nodeContainer.TryGetNode(component.PortName, out PortablePipeNode? portableNode) && nodeContainer.TryGetNode(component.PortName, out PortablePipeNode? portableNode)
&& portableNode.ConnectionsEnabled) && portableNode.ConnectionsEnabled)
@@ -61,7 +67,7 @@ namespace Content.Server.Atmos.Portable
_canisterSystem.MixContainerWithPipeNet(component.Air, net.Air); _canisterSystem.MixContainerWithPipeNet(component.Air, net.Air);
} }
if (component.Full) if (IsFull(component))
{ {
UpdateAppearance(uid, true, false); UpdateAppearance(uid, true, false);
return; return;
@@ -79,13 +85,13 @@ namespace Content.Server.Atmos.Portable
var running = Scrub(timeDelta, component, environment); var running = Scrub(timeDelta, component, environment);
UpdateAppearance(uid, false, running); 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) if (!running)
return; return;
/// widenet // widenet
foreach (var adjacent in _atmosphereSystem.GetAdjacentTileMixtures(xform.GridUid.Value, position, false, true)) 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 _)); 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) 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; component.Enabled = args.Powered;
} }
@@ -132,7 +139,7 @@ namespace Content.Server.Atmos.Portable
if (environment != null) if (environment != null)
_atmosphereSystem.Merge(environment, component.Air); _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(); component.Air.Clear();
} }
@@ -143,21 +150,10 @@ namespace Content.Server.Atmos.Portable
private void UpdateAppearance(EntityUid uid, bool isFull, bool isRunning) private void UpdateAppearance(EntityUid uid, bool isFull, bool isRunning)
{ {
if (!TryComp<AppearanceComponent>(uid, out var appearance))
return;
_ambientSound.SetAmbience(uid, isRunning); _ambientSound.SetAmbience(uid, isRunning);
appearance.SetData(PortableScrubberVisuals.IsFull, isFull); _appearance.SetData(uid, PortableScrubberVisuals.IsFull, isFull);
appearance.SetData(PortableScrubberVisuals.IsRunning, isRunning); _appearance.SetData(uid, PortableScrubberVisuals.IsRunning, isRunning);
}
private void UpdateDrainingAppearance(EntityUid uid, bool isDraining)
{
if (!TryComp<AppearanceComponent>(uid, out var appearance))
return;
appearance.SetData(PortableScrubberVisuals.IsDraining, isDraining);
} }
/// <summary> /// <summary>
@@ -174,5 +170,14 @@ namespace Content.Server.Atmos.Portable
} }
args.GasMixtures = gasMixDict; 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);
}
} }
} }

View File

@@ -182,10 +182,10 @@
prototype: PortableScrubber prototype: PortableScrubber
requirements: requirements:
MatterBin: 3 MatterBin: 3
Laser: 2 Manipulator: 2
ScanningModule: 1
materialRequirements: materialRequirements:
Cable: 5 Cable: 5
Glass: 2
- type: entity - type: entity
id: CloningPodMachineCircuitboard id: CloningPodMachineCircuitboard