using Content.Client.Atmos.Overlays; using Content.Shared.Atmos; using Content.Shared.Atmos.EntitySystems; using Content.Shared.GameTicking; using JetBrains.Annotations; using Robust.Client.Graphics; namespace Content.Client.Atmos.EntitySystems { [UsedImplicitly] internal sealed class AtmosDebugOverlaySystem : SharedAtmosDebugOverlaySystem { public readonly Dictionary TileData = new(); // Configuration set by debug commands and used by AtmosDebugOverlay { /// Value source for display public AtmosDebugOverlayMode CfgMode; /// This is subtracted from value (applied before CfgScale) public float CfgBase = 0; /// The value is divided by this (applied after CfgBase) public float CfgScale = Atmospherics.MolesCellStandard * 2; /// Gas ID used by GasMoles mode public int CfgSpecificGas = 0; /// Uses black-to-white interpolation (as opposed to red-green-blue) for colourblind users public bool CfgCBM = false; // } public override void Initialize() { base.Initialize(); SubscribeNetworkEvent(Reset); SubscribeNetworkEvent(HandleAtmosDebugOverlayMessage); SubscribeNetworkEvent(HandleAtmosDebugOverlayDisableMessage); SubscribeLocalEvent(OnGridRemoved); var overlayManager = IoCManager.Resolve(); if(!overlayManager.HasOverlay()) overlayManager.AddOverlay(new AtmosDebugOverlay(this)); } private void OnGridRemoved(GridRemovalEvent ev) { if (TileData.ContainsKey(ev.EntityUid)) { TileData.Remove(ev.EntityUid); } } private void HandleAtmosDebugOverlayMessage(AtmosDebugOverlayMessage message) { TileData[GetEntity(message.GridId)] = message; } private void HandleAtmosDebugOverlayDisableMessage(AtmosDebugOverlayDisableMessage ev) { TileData.Clear(); } public override void Shutdown() { base.Shutdown(); var overlayManager = IoCManager.Resolve(); if (overlayManager.HasOverlay()) overlayManager.RemoveOverlay(); } public void Reset(RoundRestartCleanupEvent ev) { TileData.Clear(); } public bool HasData(EntityUid gridId) { return TileData.ContainsKey(gridId); } } internal enum AtmosDebugOverlayMode : byte { TotalMoles, GasMoles, Temperature } }