Files
OldThink/Content.Client/Medical/CrewMonitoring/CrewMonitoringBoundUserInterface.cs

57 lines
1.4 KiB
C#
Raw Normal View History

using Content.Shared.Medical.CrewMonitoring;
2023-12-09 23:38:50 -06:00
namespace Content.Client.Medical.CrewMonitoring;
public sealed class CrewMonitoringBoundUserInterface : BoundUserInterface
{
2023-12-09 23:38:50 -06:00
[ViewVariables]
private CrewMonitoringWindow? _menu;
public CrewMonitoringBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
2023-12-09 23:38:50 -06:00
}
2023-12-09 23:38:50 -06:00
protected override void Open()
{
EntityUid? gridUid = null;
string stationName = string.Empty;
2023-12-09 23:38:50 -06:00
if (EntMan.TryGetComponent<TransformComponent>(Owner, out var xform))
{
2023-12-09 23:38:50 -06:00
gridUid = xform.GridUid;
2023-04-13 16:21:24 +10:00
2023-12-09 23:38:50 -06:00
if (EntMan.TryGetComponent<MetaDataComponent>(gridUid, out var metaData))
2023-04-13 16:21:24 +10:00
{
2023-12-09 23:38:50 -06:00
stationName = metaData.EntityName;
2023-04-13 16:21:24 +10:00
}
}
2023-12-09 23:38:50 -06:00
_menu = new CrewMonitoringWindow(stationName, gridUid);
2023-12-09 23:38:50 -06:00
_menu.OpenCentered();
_menu.OnClose += Close;
}
2023-04-13 16:21:24 +10:00
2023-12-09 23:38:50 -06:00
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
2023-12-09 23:38:50 -06:00
switch (state)
{
2023-12-09 23:38:50 -06:00
case CrewMonitoringState st:
EntMan.TryGetComponent<TransformComponent>(Owner, out var xform);
_menu?.ShowSensors(st.Sensors, Owner, xform?.Coordinates);
break;
}
}
2023-12-09 23:38:50 -06:00
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;
_menu?.Dispose();
}
}