Fix crew monitor for rotated eyes (#11931)

This commit is contained in:
Leon Friedrich
2022-10-16 13:07:42 +13:00
committed by GitHub
parent c44f173f5e
commit 6e6ddc0cb8
5 changed files with 38 additions and 36 deletions

View File

@@ -3,8 +3,6 @@ using Content.Server.DeviceNetwork.Systems;
using Content.Server.Medical.SuitSensors;
using Content.Server.UserInterface;
using Content.Shared.Medical.CrewMonitoring;
using Content.Shared.Movement.Components;
using Robust.Shared.Map;
using Robust.Shared.Timing;
namespace Content.Server.Medical.CrewMonitoring
@@ -12,8 +10,8 @@ namespace Content.Server.Medical.CrewMonitoring
public sealed class CrewMonitoringConsoleSystem : EntitySystem
{
[Dependency] private readonly SuitSensorSystem _sensors = default!;
[Dependency] private readonly SharedTransformSystem _xform = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
private const float UpdateRate = 3f;
private float _updateDif;
@@ -67,20 +65,10 @@ 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 (_mapManager.TryGetGrid(xform.GridUid, out var grid))
worldRot = grid.WorldRotation;
// update all sensors info
var worldPos = _xform.GetWorldPosition(uid);
var allSensors = component.ConnectedSensors.Values.ToList();
var uiState = new CrewMonitoringState(allSensors, worldPos, worldRot, component.Snap, component.Precision);
var uiState = new CrewMonitoringState(allSensors, worldPos, component.Snap, component.Precision);
ui.SetState(uiState);
}