Add directional icons to crew monitors (#7404)
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Medical.SuitSensors;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.Medical.CrewMonitoring;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server.Medical.CrewMonitoring
|
||||
@@ -13,6 +13,7 @@ namespace Content.Server.Medical.CrewMonitoring
|
||||
{
|
||||
[Dependency] private readonly SuitSensorSystem _sensors = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
private const float UpdateRate = 3f;
|
||||
private float _updateDif;
|
||||
@@ -66,9 +67,22 @@ namespace Content.Server.Medical.CrewMonitoring
|
||||
if (ui == null)
|
||||
return;
|
||||
|
||||
// For directional arrows, we need to fetch the monitor's transform data
|
||||
var xform = Transform(uid);
|
||||
var (worldPos, worldRot) = xform.GetWorldPositionRotation();
|
||||
|
||||
// In general, the directions displayed depend on either the orientation of the grid, or the orientation of
|
||||
// the monitor. But in the special case where the monitor IS a player (i.e., admin ghost), we base it off
|
||||
// the players eye rotation. We don't know what that is for sure, but we know their last grid angle, which
|
||||
// should work well enough?
|
||||
if (TryComp(uid, out IMoverComponent? mover))
|
||||
worldRot = mover.LastGridAngle;
|
||||
else if (_mapManager.TryGetGrid(xform.GridID, out var grid))
|
||||
worldRot = grid.WorldRotation;
|
||||
|
||||
// update all sensors info
|
||||
var allSensors = component.ConnectedSensors.Values.ToList();
|
||||
var uiState = new CrewMonitoringState(allSensors);
|
||||
var uiState = new CrewMonitoringState(allSensors, worldPos, worldRot, component.Snap, component.Precision);
|
||||
ui.SetState(uiState);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user