Make crew monitor update blips at consistent rates (#32555)
This commit is contained in:
@@ -25,6 +25,7 @@ public sealed partial class CrewMonitoringWindow : FancyWindow
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
|
private readonly SharedTransformSystem _transformSystem;
|
||||||
private readonly SpriteSystem _spriteSystem;
|
private readonly SpriteSystem _spriteSystem;
|
||||||
|
|
||||||
private NetEntity? _trackedEntity;
|
private NetEntity? _trackedEntity;
|
||||||
@@ -36,10 +37,10 @@ public sealed partial class CrewMonitoringWindow : FancyWindow
|
|||||||
RobustXamlLoader.Load(this);
|
RobustXamlLoader.Load(this);
|
||||||
IoCManager.InjectDependencies(this);
|
IoCManager.InjectDependencies(this);
|
||||||
|
|
||||||
|
_transformSystem = _entManager.System<SharedTransformSystem>();
|
||||||
_spriteSystem = _entManager.System<SpriteSystem>();
|
_spriteSystem = _entManager.System<SpriteSystem>();
|
||||||
|
|
||||||
NavMap.TrackedEntitySelectedAction += SetTrackedEntityFromNavMap;
|
NavMap.TrackedEntitySelectedAction += SetTrackedEntityFromNavMap;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Set(string stationName, EntityUid? mapUid)
|
public void Set(string stationName, EntityUid? mapUid)
|
||||||
@@ -290,7 +291,7 @@ public sealed partial class CrewMonitoringWindow : FancyWindow
|
|||||||
{
|
{
|
||||||
NavMap.TrackedEntities.TryAdd(sensor.SuitSensorUid,
|
NavMap.TrackedEntities.TryAdd(sensor.SuitSensorUid,
|
||||||
new NavMapBlip
|
new NavMapBlip
|
||||||
(coordinates.Value,
|
(CoordinatesToLocal(coordinates.Value),
|
||||||
_blipTexture,
|
_blipTexture,
|
||||||
(_trackedEntity == null || sensor.SuitSensorUid == _trackedEntity) ? Color.LimeGreen : Color.LimeGreen * Color.DimGray,
|
(_trackedEntity == null || sensor.SuitSensorUid == _trackedEntity) ? Color.LimeGreen : Color.LimeGreen * Color.DimGray,
|
||||||
sensor.SuitSensorUid == _trackedEntity));
|
sensor.SuitSensorUid == _trackedEntity));
|
||||||
@@ -356,7 +357,7 @@ public sealed partial class CrewMonitoringWindow : FancyWindow
|
|||||||
if (NavMap.TrackedEntities.TryGetValue(castSensor.SuitSensorUid, out var data))
|
if (NavMap.TrackedEntities.TryGetValue(castSensor.SuitSensorUid, out var data))
|
||||||
{
|
{
|
||||||
data = new NavMapBlip
|
data = new NavMapBlip
|
||||||
(data.Coordinates,
|
(CoordinatesToLocal(data.Coordinates),
|
||||||
data.Texture,
|
data.Texture,
|
||||||
(currTrackedEntity == null || castSensor.SuitSensorUid == currTrackedEntity) ? Color.LimeGreen : Color.LimeGreen * Color.DimGray,
|
(currTrackedEntity == null || castSensor.SuitSensorUid == currTrackedEntity) ? Color.LimeGreen : Color.LimeGreen * Color.DimGray,
|
||||||
castSensor.SuitSensorUid == currTrackedEntity);
|
castSensor.SuitSensorUid == currTrackedEntity);
|
||||||
@@ -421,6 +422,26 @@ public sealed partial class CrewMonitoringWindow : FancyWindow
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts the input coordinates to an EntityCoordinates which are in
|
||||||
|
/// reference to the grid that the map is displaying. This is a stylistic
|
||||||
|
/// choice; this window deliberately limits the rate that blips update,
|
||||||
|
/// but if the blip is attached to another grid which is moving, that
|
||||||
|
/// blip will move smoothly, unlike the others. By converting the
|
||||||
|
/// coordinates, we are back in control of the blip movement.
|
||||||
|
/// </summary>
|
||||||
|
private EntityCoordinates CoordinatesToLocal(EntityCoordinates refCoords)
|
||||||
|
{
|
||||||
|
if (NavMap.MapUid != null)
|
||||||
|
{
|
||||||
|
return _transformSystem.WithEntityId(refCoords, (EntityUid)NavMap.MapUid);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return refCoords;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ClearOutDatedData()
|
private void ClearOutDatedData()
|
||||||
{
|
{
|
||||||
SensorsTable.RemoveAllChildren();
|
SensorsTable.RemoveAllChildren();
|
||||||
|
|||||||
Reference in New Issue
Block a user