mirror of
https://github.com/corvax-team/ss14-wl.git
synced 2026-06-09 10:06:46 +02:00
877070139f
* Fix AtmosDebugOverlay being always active * review
102 lines
3.0 KiB
C#
102 lines
3.0 KiB
C#
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
|
|
{
|
|
[Dependency] private readonly IOverlayManager _overlayManager = default!;
|
|
|
|
public readonly Dictionary<EntityUid, AtmosDebugOverlayMessage> TileData = [];
|
|
|
|
// Configuration set by debug commands and used by AtmosDebugOverlay {
|
|
/// <summary>Value source for display</summary>
|
|
public AtmosDebugOverlayMode CfgMode;
|
|
/// <summary>This is subtracted from value (applied before CfgScale)</summary>
|
|
public float CfgBase = 0;
|
|
/// <summary>The value is divided by this (applied after CfgBase)</summary>
|
|
public float CfgScale = Atmospherics.MolesCellStandard * 2;
|
|
/// <summary>Gas ID used by GasMoles mode</summary>
|
|
public int CfgSpecificGas = 0;
|
|
/// <summary>Uses black-to-white interpolation (as opposed to red-green-blue) for colourblind users</summary>
|
|
public bool CfgCBM = false;
|
|
// }
|
|
|
|
private AtmosDebugOverlay? _overlay;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeNetworkEvent<RoundRestartCleanupEvent>(Reset);
|
|
SubscribeNetworkEvent<AtmosDebugOverlayMessage>(HandleAtmosDebugOverlayMessage);
|
|
SubscribeNetworkEvent<AtmosDebugOverlayDisableMessage>(HandleAtmosDebugOverlayDisableMessage);
|
|
|
|
SubscribeLocalEvent<GridRemovalEvent>(OnGridRemoved);
|
|
}
|
|
|
|
private void OnGridRemoved(GridRemovalEvent ev)
|
|
{
|
|
if (TileData.ContainsKey(ev.EntityUid))
|
|
{
|
|
TileData.Remove(ev.EntityUid);
|
|
}
|
|
}
|
|
|
|
private void HandleAtmosDebugOverlayMessage(AtmosDebugOverlayMessage message)
|
|
{
|
|
TileData[GetEntity(message.GridId)] = message;
|
|
|
|
if (_overlay is not null)
|
|
return;
|
|
|
|
_overlay = new AtmosDebugOverlay(this);
|
|
_overlayManager.AddOverlay(_overlay);
|
|
}
|
|
|
|
private void HandleAtmosDebugOverlayDisableMessage(AtmosDebugOverlayDisableMessage ev)
|
|
{
|
|
TileData.Clear();
|
|
RemoveOverlay();
|
|
}
|
|
|
|
public override void Shutdown()
|
|
{
|
|
base.Shutdown();
|
|
|
|
RemoveOverlay();
|
|
}
|
|
|
|
public void Reset(RoundRestartCleanupEvent ev)
|
|
{
|
|
TileData.Clear();
|
|
}
|
|
|
|
public bool HasData(EntityUid gridId)
|
|
{
|
|
return TileData.ContainsKey(gridId);
|
|
}
|
|
|
|
private void RemoveOverlay()
|
|
{
|
|
if (_overlay is null)
|
|
return;
|
|
|
|
_overlayManager.RemoveOverlay(_overlay);
|
|
_overlay = null;
|
|
}
|
|
}
|
|
|
|
internal enum AtmosDebugOverlayMode : byte
|
|
{
|
|
TotalMoles,
|
|
GasMoles,
|
|
Temperature
|
|
}
|
|
}
|