Add directional icons to crew monitors (#7404)
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Medical.SuitSensor;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Medical.CrewMonitoring
|
||||
{
|
||||
@@ -18,7 +14,20 @@ namespace Content.Server.Medical.CrewMonitoring
|
||||
/// <summary>
|
||||
/// After what time sensor consider to be lost.
|
||||
/// </summary>
|
||||
[DataField("sensorTimeout")]
|
||||
[DataField("sensorTimeout"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public float SensorTimeout = 10f;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the direction arrows in the monitor UI should snap the nearest diagonal or cardinal direction, or whether they should point exactly towards the target.
|
||||
/// </summary>
|
||||
[DataField("snap"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool Snap = true;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum distance before the monitor direction indicator stops pointing towards the target and instead
|
||||
/// shows an icon indicating that the target is "here". Does not affect the displayed coordinates.
|
||||
/// </summary>
|
||||
[DataField("precision"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public float Precision = 10f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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