Thermomachine fix + machine boards (#6803)

This commit is contained in:
mirrorcult
2022-02-20 17:17:45 -07:00
committed by GitHub
parent 9834c1f806
commit d91f969451
8 changed files with 123 additions and 50 deletions

View File

@@ -1,8 +1,10 @@
using Content.Server.Atmos.EntitySystems;
using Content.Server.Atmos.Piping.Components;
using Content.Server.Atmos.Piping.Unary.Components;
using Content.Server.Construction;
using Content.Server.NodeContainer;
using Content.Server.NodeContainer.Nodes;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Piping;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
@@ -21,6 +23,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
SubscribeLocalEvent<GasThermoMachineComponent, AtmosDeviceUpdateEvent>(OnThermoMachineUpdated);
SubscribeLocalEvent<GasThermoMachineComponent, AtmosDeviceDisabledEvent>(OnThermoMachineLeaveAtmosphere);
SubscribeLocalEvent<GasThermoMachineComponent, RefreshPartsEvent>(OnGasThermoRefreshParts);
}
private void OnThermoMachineUpdated(EntityUid uid, GasThermoMachineComponent thermoMachine, AtmosDeviceUpdateEvent args)
@@ -39,7 +42,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
var combinedHeatCapacity = airHeatCapacity + thermoMachine.HeatCapacity;
var oldTemperature = inlet.Air.Temperature;
if (combinedHeatCapacity > 0)
if (!MathHelper.CloseTo(combinedHeatCapacity, 0, 0.001f))
{
appearance?.SetData(ThermoMachineVisuals.Enabled, true);
var combinedEnergy = thermoMachine.HeatCapacity * thermoMachine.TargetTemperature + airHeatCapacity * inlet.Air.Temperature;
@@ -56,5 +59,38 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
appearance.SetData(ThermoMachineVisuals.Enabled, false);
}
}
private void OnGasThermoRefreshParts(EntityUid uid, GasThermoMachineComponent component, RefreshPartsEvent args)
{
var matterBinRating = 0;
var laserRating = 0;
foreach (var part in args.Parts)
{
switch (part.PartType)
{
case MachinePart.MatterBin:
matterBinRating += part.Rating;
break;
case MachinePart.Laser:
laserRating += part.Rating;
break;
}
}
component.HeatCapacity = 5000 * MathF.Pow((matterBinRating - 1), 2);
switch (component.Mode)
{
// 573.15K with stock parts.
case ThermoMachineMode.Heater:
component.MaxTemperature = Atmospherics.T20C + (component.InitialMaxTemperature * laserRating);
break;
// 73.15K with stock parts.
case ThermoMachineMode.Freezer:
component.MinTemperature = MathF.Max(Atmospherics.T0C - component.InitialMinTemperature + laserRating * 15f, Atmospherics.TCMB);
break;
}
}
}
}