mirror of
https://github.com/corvax-team/ss14-wl.git
synced 2026-06-09 10:06:46 +02:00
118b83165b
* Switch button for gas filter power * Switch button for gas mixer power * Switch button for gas pump power * Switch button for thermomachine power * Switch button for space heater power * Remove redundant switch labels
55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
using Content.Shared.Atmos;
|
|
using Content.Shared.Atmos.Components;
|
|
using Content.Shared.Atmos.Piping.Binary.Components;
|
|
using Content.Shared.IdentityManagement;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.UserInterface;
|
|
|
|
namespace Content.Client.Atmos.UI;
|
|
|
|
/// <summary>
|
|
/// Initializes a <see cref="GasPressurePumpWindow"/> and updates it when new server messages are received.
|
|
/// </summary>
|
|
[UsedImplicitly]
|
|
public sealed class GasPressurePumpBoundUserInterface(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey)
|
|
{
|
|
[ViewVariables]
|
|
private GasPressurePumpWindow? _window;
|
|
|
|
protected override void Open()
|
|
{
|
|
base.Open();
|
|
|
|
_window = this.CreateWindow<GasPressurePumpWindow>();
|
|
|
|
_window.ToggleStatusButtonPressed += OnToggleStatusButtonPressed;
|
|
_window.PumpOutputPressureChanged += OnPumpOutputPressurePressed;
|
|
Update();
|
|
}
|
|
|
|
public override void Update()
|
|
{
|
|
if (_window == null)
|
|
return;
|
|
|
|
_window.Title = Identity.Name(Owner, EntMan);
|
|
|
|
if (!EntMan.TryGetComponent(Owner, out GasPressurePumpComponent? pump))
|
|
return;
|
|
|
|
_window.SetPumpStatus(pump.Enabled);
|
|
_window.MaxPressure = pump.MaxTargetPressure;
|
|
_window.SetOutputPressure(pump.TargetPressure);
|
|
}
|
|
|
|
private void OnToggleStatusButtonPressed(bool status)
|
|
{
|
|
SendPredictedMessage(new GasPressurePumpToggleStatusMessage(status));
|
|
}
|
|
|
|
private void OnPumpOutputPressurePressed(float value)
|
|
{
|
|
SendPredictedMessage(new GasPressurePumpChangeOutputPressureMessage(value));
|
|
}
|
|
}
|