Optimize & clean up RadiationSystem (#34459)

* Optimize & clean up RadiationSystem

* comments

* Update Content.Server/Radiation/Systems/RadiationSystem.GridCast.cs

Co-authored-by: Thomas <87614336+Aeshus@users.noreply.github.com>

---------

Co-authored-by: Thomas <87614336+Aeshus@users.noreply.github.com>
This commit is contained in:
Leon Friedrich
2025-01-18 12:07:20 +11:00
committed by GitHub
parent efd5d644e8
commit 9d4e60068b
7 changed files with 189 additions and 127 deletions

View File

@@ -5,6 +5,7 @@ using Content.Shared.Administration;
using Content.Shared.Radiation.Events;
using Content.Shared.Radiation.Systems;
using Robust.Shared.Console;
using Robust.Shared.Debugging;
using Robust.Shared.Enums;
using Robust.Shared.Map.Components;
using Robust.Shared.Player;
@@ -42,12 +43,12 @@ public partial class RadiationSystem
/// </summary>
private void UpdateDebugOverlay(EntityEventArgs ev)
{
var sessions = _debugSessions.ToArray();
foreach (var session in sessions)
foreach (var session in _debugSessions)
{
if (session.Status != SessionStatus.InGame)
_debugSessions.Remove(session);
RaiseNetworkEvent(ev, session.Channel);
else
RaiseNetworkEvent(ev, session);
}
}
@@ -70,13 +71,16 @@ public partial class RadiationSystem
UpdateDebugOverlay(ev);
}
private void UpdateGridcastDebugOverlay(double elapsedTime, int totalSources,
int totalReceivers, List<RadiationRay> rays)
private void UpdateGridcastDebugOverlay(
double elapsedTime,
int totalSources,
int totalReceivers,
List<DebugRadiationRay>? rays)
{
if (_debugSessions.Count == 0)
return;
var ev = new OnRadiationOverlayUpdateEvent(elapsedTime, totalSources, totalReceivers, rays);
var ev = new OnRadiationOverlayUpdateEvent(elapsedTime, totalSources, totalReceivers, rays ?? new());
UpdateDebugOverlay(ev);
}
}