Roundstart antag role restrictions revival (#20108)

Co-authored-by: Ray <vigersray@gmail.com>
Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2023-09-20 08:54:53 +01:00
committed by GitHub
parent 35246963c7
commit 4fbebb6917
14 changed files with 229 additions and 150 deletions

View File

@@ -1,8 +1,11 @@
using System.Linq;
using Content.Client.Eui;
using Content.Client.Players.PlayTimeTracking;
using Content.Shared.Eui;
using Content.Shared.Ghost.Roles;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.Utility;
namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
{
@@ -64,14 +67,26 @@ namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles
if (state is not GhostRolesEuiState ghostState) return;
_window.ClearEntries();
var entityManager = IoCManager.Resolve<IEntityManager>();
var sysManager = entityManager.EntitySysManager;
var spriteSystem = sysManager.GetEntitySystem<SpriteSystem>();
var requirementsManager = IoCManager.Resolve<JobRequirementsManager>();
var groupedRoles = ghostState.GhostRoles.GroupBy(
role => (role.Name, role.Description));
role => (role.Name, role.Description, role.Requirements));
foreach (var group in groupedRoles)
{
var name = group.Key.Name;
var description = group.Key.Description;
bool hasAccess = true;
FormattedMessage? reason;
_window.AddEntry(name, description, group);
if (!requirementsManager.CheckRoleTime(group.Key.Requirements, out reason))
{
hasAccess = false;
}
_window.AddEntry(name, description, hasAccess, reason, group, spriteSystem);
}
var closeRulesWindow = ghostState.GhostRoles.All(role => role.Identifier != _windowRulesId);