GasTankBoundUserInterface.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using Content.Shared.Atmos.Components;
  2. using JetBrains.Annotations;
  3. using Robust.Client.GameObjects;
  4. using Robust.Client.UserInterface;
  5. namespace Content.Client.UserInterface.Systems.Atmos.GasTank
  6. {
  7. [UsedImplicitly]
  8. public sealed class GasTankBoundUserInterface : BoundUserInterface
  9. {
  10. [ViewVariables]
  11. private GasTankWindow? _window;
  12. public GasTankBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
  13. {
  14. }
  15. public void SetOutputPressure(float value)
  16. {
  17. SendMessage(new GasTankSetPressureMessage
  18. {
  19. Pressure = value
  20. });
  21. }
  22. public void ToggleInternals()
  23. {
  24. SendMessage(new GasTankToggleInternalsMessage());
  25. }
  26. protected override void Open()
  27. {
  28. base.Open();
  29. _window = this.CreateWindow<GasTankWindow>();
  30. _window.SetTitle(EntMan.GetComponent<MetaDataComponent>(Owner).EntityName);
  31. _window.OnOutputPressure += SetOutputPressure;
  32. _window.OnToggleInternals += ToggleInternals;
  33. }
  34. protected override void UpdateState(BoundUserInterfaceState state)
  35. {
  36. base.UpdateState(state);
  37. if (state is GasTankBoundUserInterfaceState cast)
  38. _window?.UpdateState(cast);
  39. }
  40. protected override void Dispose(bool disposing)
  41. {
  42. base.Dispose(disposing);
  43. _window?.Close();
  44. }
  45. }
  46. }