Fix GasThermoMachine upgrading (#8313)

This commit is contained in:
Leon Friedrich
2022-05-29 07:10:37 +12:00
committed by GitHub
parent 9cd323e519
commit 2b2bef5947
3 changed files with 71 additions and 25 deletions

View File

@@ -46,7 +46,6 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
var airHeatCapacity = _atmosphereSystem.GetHeatCapacity(inlet.Air);
var combinedHeatCapacity = airHeatCapacity + thermoMachine.HeatCapacity;
var oldTemperature = inlet.Air.Temperature;
if (!MathHelper.CloseTo(combinedHeatCapacity, 0, 0.001f))
{
@@ -70,6 +69,9 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
private void OnGasThermoRefreshParts(EntityUid uid, GasThermoMachineComponent component, RefreshPartsEvent args)
{
// Here we evaluate the average quality of relevant machine parts.
var nLasers = 0;
var nBins= 0;
var matterBinRating = 0;
var laserRating = 0;
@@ -78,25 +80,32 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
switch (part.PartType)
{
case MachinePart.MatterBin:
nBins += 1;
matterBinRating += part.Rating;
break;
case MachinePart.Laser:
nLasers += 1;
laserRating += part.Rating;
break;
}
}
laserRating /= nLasers;
matterBinRating /= nBins;
component.HeatCapacity = 5000 * MathF.Pow((matterBinRating - 1), 2);
component.HeatCapacity = 5000 * MathF.Pow(matterBinRating, 2);
switch (component.Mode)
{
// 573.15K with stock parts.
// 593.15K with stock parts.
case ThermoMachineMode.Heater:
component.MaxTemperature = Atmospherics.T20C + (component.InitialMaxTemperature * laserRating);
component.MaxTemperature = component.BaseMaxTemperature + component.MaxTemperatureDelta * laserRating;
component.MinTemperature = Atmospherics.T20C;
break;
// 73.15K with stock parts.
case ThermoMachineMode.Freezer:
component.MinTemperature = MathF.Max(Atmospherics.T0C - component.InitialMinTemperature + laserRating * 15f, Atmospherics.TCMB);
component.MinTemperature = MathF.Max(
component.BaseMinTemperature - component.MinTemperatureDelta * laserRating, Atmospherics.TCMB);
component.MaxTemperature = Atmospherics.T20C;
break;
}