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

86 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.Shared.Map;
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.OpenCentered();
_window.OnClose += Close;
_window.RequestFTL += OnFTLRequest;
_window.RequestBeaconFTL += OnFTLBeaconRequest;
_window.DockRequest += OnDockRequest;
_window.UndockRequest += OnUndockRequest;
}
private void OnUndockRequest(NetEntity entity)
2022-07-15 14:11:41 +10:00
{
SendMessage(new UndockRequestMessage()
2022-07-15 14:11:41 +10:00
{
DockEntity = entity,
2022-07-15 14:11:41 +10:00
});
}
private void OnDockRequest(NetEntity entity, NetEntity target)
{
SendMessage(new DockRequestMessage()
{
DockEntity = entity,
TargetDockEntity = target,
});
}
private void OnFTLBeaconRequest(NetEntity ent, Angle angle)
{
SendMessage(new ShuttleConsoleFTLBeaconMessage()
{
Beacon = ent,
Angle = angle,
});
}
private void OnFTLRequest(MapCoordinates obj, Angle angle)
{
SendMessage(new ShuttleConsoleFTLPositionMessage()
{
Coordinates = obj,
Angle = angle,
});
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
_window?.Dispose();
}
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is not ShuttleBoundUserInterfaceState cState)
return;
2022-06-23 14:36:47 +10:00
_window?.UpdateState(Owner, cState);
}
}