Make sure explosions reset on round restart (#7801)

This commit is contained in:
Leon Friedrich
2022-04-27 02:37:31 +12:00
committed by GitHub
parent f1385b1352
commit d3a20c8a23
2 changed files with 28 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
using Content.Shared.CCVar;
using Content.Shared.Explosion;
using Content.Shared.GameTicking;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
@@ -34,6 +35,7 @@ public sealed class ExplosionOverlaySystem : EntitySystem
SubscribeNetworkEvent<ExplosionEvent>(OnExplosion);
SubscribeNetworkEvent<ExplosionOverlayUpdateEvent>(HandleExplosionUpdate);
SubscribeLocalEvent<MapChangedEvent>(OnMapChanged);
SubscribeAllEvent<RoundRestartCleanupEvent>(OnReset);
_cfg.OnValueChanged(CCVars.ExplosionPersistence, SetExplosionPersistence, true);
@@ -43,6 +45,21 @@ public sealed class ExplosionOverlaySystem : EntitySystem
overlayManager.AddOverlay(_overlay);
}
private void OnReset(RoundRestartCleanupEvent ev)
{
// Not sure if round restart cleans up client-side entities, but better safe than sorry.
foreach (var exp in _overlay.CompletedExplosions)
{
QueueDel(exp.LightEntity);
}
if (_overlay.ActiveExplosion != null)
QueueDel(_overlay.ActiveExplosion.LightEntity);
_overlay.CompletedExplosions.Clear();
_overlay.ActiveExplosion = null;
_overlay.Index = 0;
}
private void OnMapChanged(MapChangedEvent ev)
{
if (ev.Created)