ShuttleConsoleBoundUserInterface.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using Content.Client.Shuttles.UI;
  2. using Content.Shared.Shuttles.BUIStates;
  3. using Content.Shared.Shuttles.Events;
  4. using JetBrains.Annotations;
  5. using Robust.Client.UserInterface;
  6. using Robust.Shared.Map;
  7. namespace Content.Client.Shuttles.BUI;
  8. [UsedImplicitly]
  9. public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface
  10. {
  11. [ViewVariables]
  12. private ShuttleConsoleWindow? _window;
  13. public ShuttleConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
  14. {
  15. }
  16. protected override void Open()
  17. {
  18. base.Open();
  19. _window = this.CreateWindow<ShuttleConsoleWindow>();
  20. _window.RequestFTL += OnFTLRequest;
  21. _window.RequestBeaconFTL += OnFTLBeaconRequest;
  22. _window.DockRequest += OnDockRequest;
  23. _window.UndockRequest += OnUndockRequest;
  24. }
  25. private void OnUndockRequest(NetEntity entity)
  26. {
  27. SendMessage(new UndockRequestMessage()
  28. {
  29. DockEntity = entity,
  30. });
  31. }
  32. private void OnDockRequest(NetEntity entity, NetEntity target)
  33. {
  34. SendMessage(new DockRequestMessage()
  35. {
  36. DockEntity = entity,
  37. TargetDockEntity = target,
  38. });
  39. }
  40. private void OnFTLBeaconRequest(NetEntity ent, Angle angle)
  41. {
  42. SendMessage(new ShuttleConsoleFTLBeaconMessage()
  43. {
  44. Beacon = ent,
  45. Angle = angle,
  46. });
  47. }
  48. private void OnFTLRequest(MapCoordinates obj, Angle angle)
  49. {
  50. SendMessage(new ShuttleConsoleFTLPositionMessage()
  51. {
  52. Coordinates = obj,
  53. Angle = angle,
  54. });
  55. }
  56. protected override void Dispose(bool disposing)
  57. {
  58. base.Dispose(disposing);
  59. if (disposing)
  60. {
  61. _window?.Dispose();
  62. }
  63. }
  64. protected override void UpdateState(BoundUserInterfaceState state)
  65. {
  66. base.UpdateState(state);
  67. if (state is not ShuttleBoundUserInterfaceState cState)
  68. return;
  69. _window?.UpdateState(Owner, cState);
  70. }
  71. }