-
Notifications
You must be signed in to change notification settings - Fork 597
Expand file tree
/
Copy pathPowerMonitoringConsoleBoundUserInterface.cs
More file actions
64 lines (52 loc) · 2.1 KB
/
Copy pathPowerMonitoringConsoleBoundUserInterface.cs
File metadata and controls
64 lines (52 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using Content.Shared.Power;
using Content.Shared.Medical.CrewMonitoring;
using Content.Shared.Silicons.StationAi;
using Robust.Client.UserInterface;
using Robust.Shared.Map;
using Robust.Shared.Player;
namespace Content.Client.Power;
public sealed class PowerMonitoringConsoleBoundUserInterface : BoundUserInterface
{
[Dependency] private ISharedPlayerManager _playerManager = default!; // Starlight: go to clicked position for AI
[ViewVariables]
private PowerMonitoringWindow? _menu;
public PowerMonitoringConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
IoCManager.InjectDependencies(this); // Starlight: go to clicked position for AI
}
protected override void Open()
{
base.Open();
_menu = this.CreateWindow<PowerMonitoringWindow>();
_menu.SetEntity(Owner);
_menu.SendPowerMonitoringConsoleMessageAction += SendPowerMonitoringConsoleMessage;
_menu.MapClicked += SendMapClicked; // Starlight: go to clicked position for AI
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
var castState = (PowerMonitoringConsoleBoundInterfaceState) state;
EntMan.TryGetComponent<TransformComponent>(Owner, out var xform);
_menu?.ShowEntites
(castState.TotalSources,
castState.TotalBatteryUsage,
castState.TotalLoads,
castState.AllEntries,
castState.FocusSources,
castState.FocusLoads,
xform?.Coordinates);
}
public void SendPowerMonitoringConsoleMessage(NetEntity? netEntity, PowerMonitoringConsoleGroup group)
{
SendMessage(new PowerMonitoringConsoleMessage(netEntity, group));
}
#region Starlight
private void SendMapClicked(EntityCoordinates coordinates)
{
var local = _playerManager.LocalEntity;
if (local is null || !EntMan.HasComponent<StationAiHeldComponent>(local.Value))
return;
SendMessage(new CrewMonitoringWarpRequestMessage(EntMan.GetNetCoordinates(coordinates)));
}
#endregion
}