Files
OldThink/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs

78 lines
2.0 KiB
C#
Raw Normal View History

using Content.Client.Shuttles.UI;
using Content.Shared.Shuttles.BUIStates;
using Content.Shared.Shuttles.Events;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
namespace Content.Client.Shuttles.BUI;
[UsedImplicitly]
public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface
{
2023-07-08 09:02:17 -07:00
[ViewVariables]
private ShuttleConsoleWindow? _window;
2023-07-08 09:02:17 -07:00
public ShuttleConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = new ShuttleConsoleWindow();
_window.UndockPressed += OnUndockPressed;
_window.StartAutodockPressed += OnAutodockPressed;
_window.StopAutodockPressed += OnStopAutodockPressed;
2022-07-15 14:11:41 +10:00
_window.DestinationPressed += OnDestinationPressed;
_window.OpenCentered();
_window.OnClose += OnClose;
}
2022-07-15 14:11:41 +10:00
private void OnDestinationPressed(EntityUid obj)
{
2023-05-14 21:37:58 +10:00
SendMessage(new ShuttleConsoleFTLRequestMessage()
2022-07-15 14:11:41 +10:00
{
Destination = obj,
});
}
private void OnClose()
{
Close();
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
_window?.Dispose();
}
}
private void OnStopAutodockPressed(EntityUid obj)
{
2023-07-08 09:02:17 -07:00
SendMessage(new StopAutodockRequestMessage() { DockEntity = obj });
}
private void OnAutodockPressed(EntityUid obj)
{
2023-07-08 09:02:17 -07:00
SendMessage(new AutodockRequestMessage() { DockEntity = obj });
}
private void OnUndockPressed(EntityUid obj)
{
2023-07-08 09:02:17 -07:00
SendMessage(new UndockRequestMessage() { DockEntity = obj });
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is not ShuttleConsoleBoundInterfaceState cState) return;
2022-06-23 14:36:47 +10:00
_window?.SetMatrix(cState.Coordinates, cState.Angle);
_window?.UpdateState(cState);
}
}