Fix running showatmos twice not disabling the atmos overlay (#2557)

* Fix running showatmos twice not disabling the atmos overlay

* Remove entity manager dependency
This commit is contained in:
DrSmugleaf
2020-11-18 08:18:04 +01:00
committed by GitHub
parent 0790ad72d2
commit f680f50059
4 changed files with 83 additions and 50 deletions

View File

@@ -1,21 +1,14 @@
#nullable enable
using System;
using System.Collections.Generic;
using Content.Client.Atmos;
using Content.Shared.Atmos;
using Content.Shared.GameObjects.EntitySystems.Atmos;
using Content.Shared.GameTicking;
using JetBrains.Annotations;
using Robust.Client.Graphics;
using Robust.Client.Interfaces.Graphics.Overlays;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.ResourceManagement;
using Robust.Client.Utility;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Utility;
namespace Content.Client.GameObjects.EntitySystems
{
@@ -24,18 +17,17 @@ namespace Content.Client.GameObjects.EntitySystems
{
[Dependency] private readonly IMapManager _mapManager = default!;
private Dictionary<GridId, AtmosDebugOverlayMessage> _tileData =
private readonly Dictionary<GridId, AtmosDebugOverlayMessage> _tileData =
new Dictionary<GridId, AtmosDebugOverlayMessage>();
private AtmosphereSystem _atmosphereSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeNetworkEvent<AtmosDebugOverlayMessage>(HandleAtmosDebugOverlayMessage);
_mapManager.OnGridRemoved += OnGridRemoved;
_atmosphereSystem = Get<AtmosphereSystem>();
SubscribeNetworkEvent<AtmosDebugOverlayMessage>(HandleAtmosDebugOverlayMessage);
SubscribeNetworkEvent<AtmosDebugOverlayDisableMessage>(HandleAtmosDebugOverlayDisableMessage);
_mapManager.OnGridRemoved += OnGridRemoved;
var overlayManager = IoCManager.Resolve<IOverlayManager>();
if(!overlayManager.HasOverlay(nameof(AtmosDebugOverlay)))
@@ -47,6 +39,11 @@ namespace Content.Client.GameObjects.EntitySystems
_tileData[message.GridId] = message;
}
private void HandleAtmosDebugOverlayDisableMessage(AtmosDebugOverlayDisableMessage ev)
{
_tileData.Clear();
}
public override void Shutdown()
{
base.Shutdown();