From: eoineoineoin Date: Mon, 27 Jan 2025 17:37:35 +0000 (+0000) Subject: Make crew monitor update blips at consistent rates (#32555) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=b1f83fb70733893c4acca9583ce9b19d27416eac;p=space-station-14.git Make crew monitor update blips at consistent rates (#32555) --- diff --git a/Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs b/Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs index 179a2c25c0..ac23e8216b 100644 --- a/Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs +++ b/Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs @@ -25,6 +25,7 @@ public sealed partial class CrewMonitoringWindow : FancyWindow { [Dependency] private readonly IEntityManager _entManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + private readonly SharedTransformSystem _transformSystem; private readonly SpriteSystem _spriteSystem; private NetEntity? _trackedEntity; @@ -36,10 +37,10 @@ public sealed partial class CrewMonitoringWindow : FancyWindow RobustXamlLoader.Load(this); IoCManager.InjectDependencies(this); + _transformSystem = _entManager.System(); _spriteSystem = _entManager.System(); NavMap.TrackedEntitySelectedAction += SetTrackedEntityFromNavMap; - } public void Set(string stationName, EntityUid? mapUid) @@ -290,7 +291,7 @@ public sealed partial class CrewMonitoringWindow : FancyWindow { NavMap.TrackedEntities.TryAdd(sensor.SuitSensorUid, new NavMapBlip - (coordinates.Value, + (CoordinatesToLocal(coordinates.Value), _blipTexture, (_trackedEntity == null || sensor.SuitSensorUid == _trackedEntity) ? Color.LimeGreen : Color.LimeGreen * Color.DimGray, sensor.SuitSensorUid == _trackedEntity)); @@ -356,7 +357,7 @@ public sealed partial class CrewMonitoringWindow : FancyWindow if (NavMap.TrackedEntities.TryGetValue(castSensor.SuitSensorUid, out var data)) { data = new NavMapBlip - (data.Coordinates, + (CoordinatesToLocal(data.Coordinates), data.Texture, (currTrackedEntity == null || castSensor.SuitSensorUid == currTrackedEntity) ? Color.LimeGreen : Color.LimeGreen * Color.DimGray, castSensor.SuitSensorUid == currTrackedEntity); @@ -421,6 +422,26 @@ public sealed partial class CrewMonitoringWindow : FancyWindow return false; } + /// + /// 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. + /// + private EntityCoordinates CoordinatesToLocal(EntityCoordinates refCoords) + { + if (NavMap.MapUid != null) + { + return _transformSystem.WithEntityId(refCoords, (EntityUid)NavMap.MapUid); + } + else + { + return refCoords; + } + } + private void ClearOutDatedData() { SensorsTable.RemoveAllChildren();