Predict gasthermomachines (#33837)
* Predict gasthermomachines * despawn * smellby
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Client.Power.EntitySystems;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Atmos.Piping.Unary.Components;
|
||||
using Content.Shared.Atmos.Piping.Unary.Systems;
|
||||
using Content.Shared.Power.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.UserInterface;
|
||||
@@ -36,6 +39,8 @@ namespace Content.Client.Atmos.UI
|
||||
|
||||
_window.ToggleStatusButton.OnPressed += _ => OnToggleStatusButtonPressed();
|
||||
_window.TemperatureSpinbox.OnValueChanged += _ => OnTemperatureChanged(_window.TemperatureSpinbox.Value);
|
||||
_window.Entity = Owner;
|
||||
Update();
|
||||
}
|
||||
|
||||
private void OnToggleStatusButtonPressed()
|
||||
@@ -43,7 +48,7 @@ namespace Content.Client.Atmos.UI
|
||||
if (_window is null) return;
|
||||
|
||||
_window.SetActive(!_window.Active);
|
||||
SendMessage(new GasThermomachineToggleMessage());
|
||||
SendPredictedMessage(new GasThermomachineToggleMessage());
|
||||
}
|
||||
|
||||
private void OnTemperatureChanged(float value)
|
||||
@@ -60,25 +65,32 @@ namespace Content.Client.Atmos.UI
|
||||
return;
|
||||
}
|
||||
|
||||
SendMessage(new GasThermomachineChangeTemperatureMessage(actual));
|
||||
SendPredictedMessage(new GasThermomachineChangeTemperatureMessage(actual));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the UI state based on server-sent info
|
||||
/// </summary>
|
||||
/// <param name="state"></param>
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
public override void Update()
|
||||
{
|
||||
base.UpdateState(state);
|
||||
if (_window == null || state is not GasThermomachineBoundUserInterfaceState cast)
|
||||
if (_window == null || !EntMan.TryGetComponent(Owner, out GasThermoMachineComponent? thermo))
|
||||
return;
|
||||
|
||||
_minTemp = cast.MinTemperature;
|
||||
_maxTemp = cast.MaxTemperature;
|
||||
_isHeater = cast.IsHeater;
|
||||
var system = EntMan.System<SharedGasThermoMachineSystem>();
|
||||
_minTemp = thermo.MinTemperature;
|
||||
_maxTemp = thermo.MaxTemperature;
|
||||
_isHeater = system.IsHeater(thermo);
|
||||
|
||||
_window.SetTemperature(thermo.TargetTemperature);
|
||||
|
||||
var receiverSys = EntMan.System<PowerReceiverSystem>();
|
||||
SharedApcPowerReceiverComponent? receiver = null;
|
||||
|
||||
receiverSys.ResolveApc(Owner, ref receiver);
|
||||
|
||||
// Also set in frameupdates.
|
||||
if (receiver != null)
|
||||
{
|
||||
_window.SetActive(!receiver.PowerDisabled);
|
||||
}
|
||||
|
||||
_window.SetTemperature(cast.Temperature);
|
||||
_window.SetActive(cast.Enabled);
|
||||
_window.Title = _isHeater switch
|
||||
{
|
||||
false => Loc.GetString("comp-gas-thermomachine-ui-title-freezer"),
|
||||
|
||||
Reference in New Issue
Block a user