Removes obsolete uses of IMapManager events. (#7036)
This commit is contained in:
@@ -14,7 +14,6 @@ namespace Content.Client.Atmos.EntitySystems
|
||||
[UsedImplicitly]
|
||||
internal sealed class AtmosDebugOverlaySystem : SharedAtmosDebugOverlaySystem
|
||||
{
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
private readonly Dictionary<GridId, AtmosDebugOverlayMessage> _tileData =
|
||||
new();
|
||||
@@ -40,13 +39,21 @@ namespace Content.Client.Atmos.EntitySystems
|
||||
SubscribeNetworkEvent<AtmosDebugOverlayMessage>(HandleAtmosDebugOverlayMessage);
|
||||
SubscribeNetworkEvent<AtmosDebugOverlayDisableMessage>(HandleAtmosDebugOverlayDisableMessage);
|
||||
|
||||
_mapManager.OnGridRemoved += OnGridRemoved;
|
||||
SubscribeLocalEvent<GridRemovalEvent>(OnGridRemoved);
|
||||
|
||||
var overlayManager = IoCManager.Resolve<IOverlayManager>();
|
||||
if(!overlayManager.HasOverlay<AtmosDebugOverlay>())
|
||||
overlayManager.AddOverlay(new AtmosDebugOverlay());
|
||||
}
|
||||
|
||||
private void OnGridRemoved(GridRemovalEvent ev)
|
||||
{
|
||||
if (_tileData.ContainsKey(ev.GridId))
|
||||
{
|
||||
_tileData.Remove(ev.GridId);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleAtmosDebugOverlayMessage(AtmosDebugOverlayMessage message)
|
||||
{
|
||||
_tileData[message.GridId] = message;
|
||||
@@ -60,7 +67,6 @@ namespace Content.Client.Atmos.EntitySystems
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
_mapManager.OnGridRemoved -= OnGridRemoved;
|
||||
var overlayManager = IoCManager.Resolve<IOverlayManager>();
|
||||
if (overlayManager.HasOverlay<AtmosDebugOverlay>())
|
||||
overlayManager.RemoveOverlay<AtmosDebugOverlay>();
|
||||
@@ -71,14 +77,6 @@ namespace Content.Client.Atmos.EntitySystems
|
||||
_tileData.Clear();
|
||||
}
|
||||
|
||||
private void OnGridRemoved(MapId mapId, GridId gridId)
|
||||
{
|
||||
if (_tileData.ContainsKey(gridId))
|
||||
{
|
||||
_tileData.Remove(gridId);
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasData(GridId gridId)
|
||||
{
|
||||
return _tileData.ContainsKey(gridId);
|
||||
@@ -93,7 +91,7 @@ namespace Content.Client.Atmos.EntitySystems
|
||||
if (relative.X < 0 || relative.Y < 0 || relative.X >= LocalViewRange || relative.Y >= LocalViewRange)
|
||||
return null;
|
||||
|
||||
return srcMsg.OverlayData[relative.X + (relative.Y * LocalViewRange)];
|
||||
return srcMsg.OverlayData[relative.X + relative.Y * LocalViewRange];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user