Files
crystall-punk-14/Content.Client/UserInterface/Systems/Atmos/GasTank/GasTankBoundUserInterface.cs

56 lines
1.5 KiB
C#
Raw Permalink Normal View History

2022-03-17 10:30:40 +13:00
using Content.Shared.Atmos.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
2022-09-11 20:42:12 -07:00
namespace Content.Client.UserInterface.Systems.Atmos.GasTank
{
[UsedImplicitly]
2023-07-08 09:02:17 -07:00
public sealed class GasTankBoundUserInterface : BoundUserInterface
{
2023-07-08 09:02:17 -07:00
[ViewVariables]
private GasTankWindow? _window;
public GasTankBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
public void SetOutputPressure(float value)
{
2023-07-08 09:02:17 -07:00
SendMessage(new GasTankSetPressureMessage
{
Pressure = value
});
}
public void ToggleInternals()
{
SendMessage(new GasTankToggleInternalsMessage());
}
protected override void Open()
{
base.Open();
_window = this.CreateWindow<GasTankWindow>();
_window.SetTitle(EntMan.GetComponent<MetaDataComponent>(Owner).EntityName);
_window.OnOutputPressure += SetOutputPressure;
_window.OnToggleInternals += ToggleInternals;
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
2022-03-17 10:30:40 +13:00
if (state is GasTankBoundUserInterfaceState cast)
_window?.UpdateState(cast);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_window?.Close();
}
}
}