Make sure explosions reset on round restart (#7801)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Explosion;
|
using Content.Shared.Explosion;
|
||||||
|
using Content.Shared.GameTicking;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
using Robust.Client.ResourceManagement;
|
using Robust.Client.ResourceManagement;
|
||||||
@@ -34,6 +35,7 @@ public sealed class ExplosionOverlaySystem : EntitySystem
|
|||||||
SubscribeNetworkEvent<ExplosionEvent>(OnExplosion);
|
SubscribeNetworkEvent<ExplosionEvent>(OnExplosion);
|
||||||
SubscribeNetworkEvent<ExplosionOverlayUpdateEvent>(HandleExplosionUpdate);
|
SubscribeNetworkEvent<ExplosionOverlayUpdateEvent>(HandleExplosionUpdate);
|
||||||
SubscribeLocalEvent<MapChangedEvent>(OnMapChanged);
|
SubscribeLocalEvent<MapChangedEvent>(OnMapChanged);
|
||||||
|
SubscribeAllEvent<RoundRestartCleanupEvent>(OnReset);
|
||||||
|
|
||||||
_cfg.OnValueChanged(CCVars.ExplosionPersistence, SetExplosionPersistence, true);
|
_cfg.OnValueChanged(CCVars.ExplosionPersistence, SetExplosionPersistence, true);
|
||||||
|
|
||||||
@@ -43,6 +45,21 @@ public sealed class ExplosionOverlaySystem : EntitySystem
|
|||||||
overlayManager.AddOverlay(_overlay);
|
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)
|
private void OnMapChanged(MapChangedEvent ev)
|
||||||
{
|
{
|
||||||
if (ev.Created)
|
if (ev.Created)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using Content.Shared.Camera;
|
|||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using Content.Shared.Explosion;
|
using Content.Shared.Explosion;
|
||||||
|
using Content.Shared.GameTicking;
|
||||||
using Content.Shared.Throwing;
|
using Content.Shared.Throwing;
|
||||||
using Robust.Server.Containers;
|
using Robust.Server.Containers;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
@@ -67,6 +68,8 @@ public sealed partial class ExplosionSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<ExplosionResistanceComponent, GetExplosionResistanceEvent>(OnGetResistance);
|
SubscribeLocalEvent<ExplosionResistanceComponent, GetExplosionResistanceEvent>(OnGetResistance);
|
||||||
SubscribeLocalEvent<TileChangedEvent>(OnTileChanged);
|
SubscribeLocalEvent<TileChangedEvent>(OnTileChanged);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnReset);
|
||||||
|
|
||||||
// Handled by ExplosionSystem.Processing.cs
|
// Handled by ExplosionSystem.Processing.cs
|
||||||
SubscribeLocalEvent<MapChangedEvent>(OnMapChanged);
|
SubscribeLocalEvent<MapChangedEvent>(OnMapChanged);
|
||||||
|
|
||||||
@@ -76,10 +79,18 @@ public sealed partial class ExplosionSystem : EntitySystem
|
|||||||
InitAirtightMap();
|
InitAirtightMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnReset(RoundRestartCleanupEvent ev)
|
||||||
|
{
|
||||||
|
_explosionQueue.Clear();
|
||||||
|
_activeExplosion = null;
|
||||||
|
_nodeGroupSystem.Snoozing = false;
|
||||||
|
}
|
||||||
|
|
||||||
public override void Shutdown()
|
public override void Shutdown()
|
||||||
{
|
{
|
||||||
base.Shutdown();
|
base.Shutdown();
|
||||||
UnsubscribeCvars();
|
UnsubscribeCvars();
|
||||||
|
_nodeGroupSystem.Snoozing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGetResistance(EntityUid uid, ExplosionResistanceComponent component, GetExplosionResistanceEvent args)
|
private void OnGetResistance(EntityUid uid, ExplosionResistanceComponent component, GetExplosionResistanceEvent args)
|
||||||
|
|||||||
Reference in New Issue
Block a user