Files
tbd-station-14/Content.Client/Medical/CrewMonitoring/CrewMonitoringBoundUserInterface.cs
2023-12-10 16:38:50 +11:00

57 lines
1.4 KiB
C#

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