6
StarHorizon_Public/Content.Client/_NF/Players/PlayTimeTracking/JobRequirementsManager.GhostRoles.cs
2026-01-24 12:49:55 +03:00

37 lines
1.1 KiB
C#

using System.Diagnostics.CodeAnalysis;
using Content.Shared.CCVar;
using Content.Shared.Ghost.Roles;
using Content.Shared.Players.PlayTimeTracking;
using Content.Shared.Preferences;
using Robust.Shared.Utility;
namespace Content.Client.Players.PlayTimeTracking;
public sealed partial class JobRequirementsManager : ISharedPlaytimeManager
{
public bool IsAllowed(GhostRolePrototype ghostRole, [NotNullWhen(false)] out FormattedMessage? reason)
{
reason = null;
if (ghostRole.Whitelisted && !CheckWhitelist(ghostRole, out reason))
return false;
return true;
}
public bool CheckWhitelist(GhostRolePrototype ghostRole, [NotNullWhen(false)] out FormattedMessage? reason)
{
reason = default;
if (!_cfg.GetCVar(CCVars.GameRoleWhitelist))
return true;
if (ghostRole.Whitelisted && !_jobWhitelists.Contains(ghostRole.ID) && !_whitelisted)
{
reason = FormattedMessage.FromUnformatted(Loc.GetString("role-not-whitelisted"));
return false;
}
return true;
}
}