machine upgrade for gas recycler (#12496)

This commit is contained in:
Nemanja
2022-11-09 20:11:23 -05:00
committed by GitHub
parent 99db8673ac
commit b0e7c6f2f4
4 changed files with 60 additions and 11 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.Piping.Binary.Components namespace Content.Server.Atmos.Piping.Binary.Components
{ {
@@ -16,5 +18,29 @@ namespace Content.Server.Atmos.Piping.Binary.Components
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
[DataField("outlet")] [DataField("outlet")]
public string OutletName { get; set; } = "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<MachinePartPrototype>))]
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<MachinePartPrototype>))]
public string MachinePartMinPressure = "Manipulator";
[DataField("partRatingMinPressureMultiplier")]
public float PartRatingMinPressureMultiplier = 0.8f;
} }
} }

View File

@@ -2,24 +2,24 @@ using Content.Server.Atmos.EntitySystems;
using Content.Shared.Atmos.Piping; using Content.Shared.Atmos.Piping;
using Content.Server.Atmos.Piping.Binary.Components; using Content.Server.Atmos.Piping.Binary.Components;
using Content.Server.Atmos.Piping.Components; using Content.Server.Atmos.Piping.Components;
using Content.Server.Construction;
using Content.Server.NodeContainer; using Content.Server.NodeContainer;
using Content.Server.NodeContainer.Nodes; using Content.Server.NodeContainer.Nodes;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Examine; using Content.Shared.Examine;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.GameObjects;
namespace Content.Server.Atmos.Piping.Binary.EntitySystems namespace Content.Server.Atmos.Piping.Binary.EntitySystems
{ {
[UsedImplicitly] [UsedImplicitly]
public sealed class GasReyclerSystem : EntitySystem public sealed class GasReyclerSystem : EntitySystem
{ {
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!; [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = 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() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
@@ -27,6 +27,8 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
SubscribeLocalEvent<GasRecyclerComponent, AtmosDeviceUpdateEvent>(OnUpdate); SubscribeLocalEvent<GasRecyclerComponent, AtmosDeviceUpdateEvent>(OnUpdate);
SubscribeLocalEvent<GasRecyclerComponent, AtmosDeviceDisabledEvent>(OnDisabled); SubscribeLocalEvent<GasRecyclerComponent, AtmosDeviceDisabledEvent>(OnDisabled);
SubscribeLocalEvent<GasRecyclerComponent, ExaminedEvent>(OnExamined); SubscribeLocalEvent<GasRecyclerComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<GasRecyclerComponent, RefreshPartsEvent>(OnRefreshParts);
SubscribeLocalEvent<GasRecyclerComponent, UpgradeExamineEvent>(OnUpgradeExamine);
} }
private void OnEnabled(EntityUid uid, GasRecyclerComponent comp, AtmosDeviceEnabledEvent args) 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) if (!EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer)
|| !nodeContainer.TryGetNode(comp.InletName, out PipeNode? inlet) || !nodeContainer.TryGetNode(comp.InletName, out PipeNode? inlet)
|| !nodeContainer.TryGetNode(comp.OutletName, out PipeNode? outlet)) || !nodeContainer.TryGetNode(comp.OutletName, out PipeNode? _))
{ {
return; return;
} }
@@ -52,12 +54,12 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
} }
else else
{ {
if (inlet.Air.Pressure < MinPressure) if (inlet.Air.Pressure < comp.MinPressure)
{ {
args.PushMarkup(Loc.GetString("gas-recycler-low-pressure")); 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")); 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. // 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)); var removed = inlet.Air.RemoveVolume(PassiveTransferVol(inlet.Air, outlet.Air));
if (comp.Reacting) if (comp.Reacting)
{ {
@@ -109,12 +111,27 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
UpdateAppearance(uid, comp); 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; 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);
} }
} }
} }

View File

@@ -1,3 +1,6 @@
gas-recycler-reacting = It is [color=green]converting[/color] waste gases. 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-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-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

View File

@@ -583,6 +583,9 @@
components: components:
- type: MachineBoard - type: MachineBoard
prototype: GasRecycler prototype: GasRecycler
requirements:
Laser: 2
Manipulator: 2
materialRequirements: materialRequirements:
Steel: 10 Steel: 10
Plasma: 10 Plasma: 5