Make thermomachines more thermodynamically sound (#18984)
Co-authored-by: Ilya246 <ilyukarno@gmail.com>
This commit is contained in:
@@ -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")
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user