Actually make LPO's crew monitor actually show people on the station (#4273)

* Simple fix

* maintainer requested changes
This commit is contained in:
Elperson 2025-08-31 19:31:38 +02:00 committed by GitHub
parent 2966d93c65
commit 24cc28b532
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 9 deletions

View File

@ -26,7 +26,7 @@ public sealed class CrewMonitoringBoundUserInterface : BoundUserInterface
// Begin DeltaV Additions - Find a station's grid instead of the current one for evil monitors
if (EntMan.HasComponent<LongRangeCrewMonitorComponent>(Owner))
{
gridUid = EntMan.System<LongRangeCrewMonitorSystem>().FindStationGridInMap(xform.MapID);
gridUid = EntMan.System<LongRangeCrewMonitorSystem>().FindLargestStationGridInMap(xform.MapID);
gridUid ??= xform.GridUid; // fall back to whatever grid this is on if it failed
}
// End DeltaV Additions

View File

@ -7,19 +7,20 @@ namespace Content.Shared._DV.Medical.CrewMonitoring;
public sealed class LongRangeCrewMonitorSystem : EntitySystem
{
/// <summary>
/// Finds an arbitrary station grid on the same map as the argument.
/// Returns null if no grid was found.
/// Finds the largest (presumably the main station) grid on the same map as the argument.
/// </summary>
public EntityUid? FindStationGridInMap(MapId map)
/// <param name="map"></param>
/// <returns>Returns null if not found</returns>
public EntityUid? FindLargestStationGridInMap(MapId map)
{
// also requiring MapGrid incase StationMember gets used for non-grids in the future
(EntityUid?, int) biggest_grid = (null, 0);
var query = EntityQueryEnumerator<StationMemberComponent, MapGridComponent>();
while (query.MoveNext(out var grid, out _, out _))
while (query.MoveNext(out var grid, out _, out var mapgrid))
{
if (Transform(grid).MapID == map)
return grid;
if (Transform(grid).MapID == map && mapgrid.ChunkCount > biggest_grid.Item2)
biggest_grid = (grid, mapgrid.ChunkCount);
}
return null;
return biggest_grid.Item1;
}
}