Make thermomachines more thermodynamically sound (#18984)

Co-authored-by: Ilya246 <ilyukarno@gmail.com>
This commit is contained in:
Kevin Zheng
2023-08-22 00:34:45 -07:00
committed by GitHub
parent 8636234ff1
commit bb7a19d32e
5 changed files with 107 additions and 60 deletions

View File

@@ -1,4 +1,5 @@
using Content.Shared.Atmos.Piping.Unary.Components;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Piping.Unary.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
@@ -18,6 +19,9 @@ namespace Content.Client.Atmos.UI
[ViewVariables]
private float _maxTemp = 0.0f;
[ViewVariables]
private bool _isHeater = true;
public GasThermomachineBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
@@ -50,7 +54,12 @@ namespace Content.Client.Atmos.UI
private void OnTemperatureChanged(float value)
{
var actual = Math.Clamp(value, _minTemp, _maxTemp);
var actual = 0f;
if (_isHeater)
actual = Math.Min(value, _maxTemp);
else
actual = Math.Max(value, _minTemp);
actual = Math.Max(actual, Atmospherics.TCMB);
if (!MathHelper.CloseTo(actual, value, 0.09))
{
_window?.SetTemperature(actual);
@@ -72,14 +81,14 @@ namespace Content.Client.Atmos.UI
_minTemp = cast.MinTemperature;
_maxTemp = cast.MaxTemperature;
_isHeater = cast.IsHeater;
_window.SetTemperature(cast.Temperature);
_window.SetActive(cast.Enabled);
_window.Title = cast.Mode switch
_window.Title = _isHeater switch
{
ThermoMachineMode.Freezer => Loc.GetString("comp-gas-thermomachine-ui-title-freezer"),
ThermoMachineMode.Heater => Loc.GetString("comp-gas-thermomachine-ui-title-heater"),
_ => string.Empty
false => Loc.GetString("comp-gas-thermomachine-ui-title-freezer"),
true => Loc.GetString("comp-gas-thermomachine-ui-title-heater")
};
}