Crew monitor revisit (#22240)
This commit is contained in:
@@ -1,53 +1,56 @@
|
||||
using Content.Shared.Medical.CrewMonitoring;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client.Medical.CrewMonitoring
|
||||
namespace Content.Client.Medical.CrewMonitoring;
|
||||
|
||||
public sealed class CrewMonitoringBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
public sealed class CrewMonitoringBoundUserInterface : BoundUserInterface
|
||||
[ViewVariables]
|
||||
private CrewMonitoringWindow? _menu;
|
||||
|
||||
public CrewMonitoringBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
||||
{
|
||||
[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;
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
EntityUid? gridUid = null;
|
||||
|
||||
if (EntMan.TryGetComponent<TransformComponent>(Owner, out var xform))
|
||||
if (EntMan.TryGetComponent<MetaDataComponent>(gridUid, out var metaData))
|
||||
{
|
||||
gridUid = xform.GridUid;
|
||||
}
|
||||
|
||||
_menu = new CrewMonitoringWindow(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, xform?.Coordinates, st.Snap, st.Precision);
|
||||
break;
|
||||
stationName = metaData.EntityName;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (!disposing)
|
||||
return;
|
||||
_menu = new CrewMonitoringWindow(stationName, gridUid);
|
||||
|
||||
_menu?.Dispose();
|
||||
_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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user