Fix coords monitor in replays (#29512)

The F3 coords manager is blocked if you're not an admin. This check happened even when playing a replay, where you actually aren't. There's now a check to make sure you are actually server-connected-to-game before running the logic.

Also moved it to a manager because this *shouldn't be a bloody entity system in the first place*.
This commit is contained in:
Pieter-Jan Briers
2024-06-27 16:58:51 +02:00
committed by GitHub
parent 45cc19f315
commit ced15b7934
3 changed files with 24 additions and 6 deletions

View File

@@ -0,0 +1,28 @@
using Content.Client.Administration.Managers;
using Content.Shared.CCVar;
using Robust.Client;
using Robust.Client.UserInterface;
using Robust.Shared.Configuration;
namespace Content.Client.DebugMon;
/// <summary>
/// This handles preventing certain debug monitors from being usable by non-admins.
/// </summary>
internal sealed class DebugMonitorManager
{
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IClientAdminManager _admin = default!;
[Dependency] private readonly IUserInterfaceManager _userInterface = default!;
[Dependency] private readonly IBaseClient _baseClient = default!;
public void FrameUpdate()
{
if (_baseClient.RunLevel == ClientRunLevel.InGame
&& !_admin.IsActive()
&& _cfg.GetCVar(CCVars.DebugCoordinatesAdminOnly))
{
_userInterface.DebugMonitors.SetMonitor(DebugMonitor.Coords, false);
}
}
}