portable scrubber machine upgrading (#12037)
This commit is contained in:
parent
cc0b610333
commit
24a3c8aef6
|
|
@ -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
|
|||
/// <summary>
|
||||
/// The air inside this machine.
|
||||
/// </summary>
|
||||
[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";
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -33,18 +33,57 @@ namespace Content.Server.Atmos.Portable
|
|||
Gas.Frezon
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Can this scrubber hold more gas?
|
||||
/// </summary>
|
||||
public bool Full => Air.Pressure >= MaxPressure;
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool Enabled = true;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum internal pressure before it refuses to take more.
|
||||
/// </summary>
|
||||
[DataField("maxPressure")]
|
||||
public float MaxPressure = 3000f;
|
||||
[DataField("transferRate")]
|
||||
public float TransferRate = 1000f;
|
||||
public bool Enabled = true;
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float MaxPressure = 2500;
|
||||
|
||||
/// <summary>
|
||||
/// 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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<PortableScrubberComponent, ExaminedEvent>(OnExamined);
|
||||
SubscribeLocalEvent<PortableScrubberComponent, DestructionEventArgs>(OnDestroyed);
|
||||
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)
|
||||
|
|
@ -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<NodeContainerComponent>(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<AppearanceComponent>(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<AppearanceComponent>(uid, out var appearance))
|
||||
return;
|
||||
|
||||
appearance.SetData(PortableScrubberVisuals.IsDraining, isDraining);
|
||||
_appearance.SetData(uid, PortableScrubberVisuals.IsFull, isFull);
|
||||
_appearance.SetData(uid, PortableScrubberVisuals.IsRunning, isRunning);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,10 +182,10 @@
|
|||
prototype: PortableScrubber
|
||||
requirements:
|
||||
MatterBin: 3
|
||||
Laser: 2
|
||||
ScanningModule: 1
|
||||
Manipulator: 2
|
||||
materialRequirements:
|
||||
Cable: 5
|
||||
Glass: 2
|
||||
|
||||
- type: entity
|
||||
id: CloningPodMachineCircuitboard
|
||||
|
|
|
|||
Loading…
Reference in New Issue