Files
crystall-punk-14/Content.Client/Medical/CrewMonitoring/CrewMonitoringBoundUserInterface.cs

47 lines
1.3 KiB
C#
Raw Normal View History

using Content.Shared.Medical.CrewMonitoring;
using Robust.Client.UserInterface;
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;
var 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
}
}
_menu = this.CreateWindow<CrewMonitoringWindow>();
_menu.Set(stationName, gridUid);
2023-12-09 23:38:50 -06:00
}
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;
}
}
}