Stop AtmosphereSystem from logging errors if an atmosphere gets deleted. (#22761)

Stop AtmosphereSystem from logging errors if a atmosphere gets deleted.
This commit is contained in:
Leon Friedrich
2023-12-19 19:57:29 -05:00
committed by GitHub
parent edceb55119
commit b1e12d03f1

View File

@@ -14,6 +14,7 @@ public sealed partial class AtmosphereSystem
private void InitializeGridAtmosphere()
{
SubscribeLocalEvent<GridAtmosphereComponent, ComponentInit>(OnGridAtmosphereInit);
SubscribeLocalEvent<GridAtmosphereComponent, ComponentRemove>(OnAtmosphereRemove);
SubscribeLocalEvent<GridAtmosphereComponent, GridSplitEvent>(OnGridSplit);
#region Atmos API Subscriptions
@@ -42,6 +43,19 @@ public sealed partial class AtmosphereSystem
#endregion
}
private void OnAtmosphereRemove(EntityUid uid, GridAtmosphereComponent component, ComponentRemove args)
{
for (var i = 0; i < _currentRunAtmosphere.Count; i++)
{
if (_currentRunAtmosphere[i].Owner != uid)
continue;
_currentRunAtmosphere.RemoveAt(i);
if (_currentRunAtmosphereIndex >= i)
_currentRunAtmosphereIndex--;
}
}
private void OnGridAtmosphereInit(EntityUid uid, GridAtmosphereComponent gridAtmosphere, ComponentInit args)
{
base.Initialize();