machine upgrade for gas recycler (#12496)
This commit is contained in:
@@ -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<GasRecyclerComponent, AtmosDeviceUpdateEvent>(OnUpdate);
|
||||
SubscribeLocalEvent<GasRecyclerComponent, AtmosDeviceDisabledEvent>(OnDisabled);
|
||||
SubscribeLocalEvent<GasRecyclerComponent, ExaminedEvent>(OnExamined);
|
||||
SubscribeLocalEvent<GasRecyclerComponent, RefreshPartsEvent>(OnRefreshParts);
|
||||
SubscribeLocalEvent<GasRecyclerComponent, UpgradeExamineEvent>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user