Files
tbd-station-14/Content.Client/UserInterface/Systems/Atmos/GasTank/GasTankBoundUserInterface.cs
Nemanja cb0ba66be3 Revert "Remove some BUI boilerplate" (#30214)
Revert "Remove some BUI boilerplate (#28399)"

This reverts commit cbf329a82d.
2024-07-20 20:42:27 -04:00

53 lines
1.3 KiB
C#

using Content.Shared.Atmos.Components;
using JetBrains.Annotations;
namespace Content.Client.UserInterface.Systems.Atmos.GasTank
{
[UsedImplicitly]
public sealed class GasTankBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private GasTankWindow? _window;
public GasTankBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
public void SetOutputPressure(in float value)
{
SendMessage(new GasTankSetPressureMessage
{
Pressure = value
});
}
public void ToggleInternals()
{
SendMessage(new GasTankToggleInternalsMessage());
}
protected override void Open()
{
base.Open();
_window = new GasTankWindow(this, EntMan.GetComponent<MetaDataComponent>(Owner).EntityName);
_window.OnClose += Close;
_window.OpenCentered();
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is GasTankBoundUserInterfaceState cast)
_window?.UpdateState(cast);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_window?.Close();
}
}
}