remove mind roles from EntityWhitelist (#36089)
* remove mind roles from EntityWhitelist * remove redundant dependency
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using Content.Server.Objectives.Components;
|
||||
using Content.Shared.Objectives.Components;
|
||||
using Content.Shared.Whitelist;
|
||||
using Content.Shared.Roles;
|
||||
|
||||
namespace Content.Server.Objectives.Systems;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Content.Server.Objectives.Systems;
|
||||
/// </summary>
|
||||
public sealed class RoleRequirementSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
|
||||
[Dependency] private readonly SharedRoleSystem _roles = default!;
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -22,7 +22,19 @@ public sealed class RoleRequirementSystem : EntitySystem
|
||||
if (args.Cancelled)
|
||||
return;
|
||||
|
||||
if (_whitelistSystem.IsWhitelistFail(comp.Roles, args.MindId))
|
||||
args.Cancelled = true;
|
||||
foreach (var role in comp.Roles)
|
||||
{
|
||||
if (!EntityManager.ComponentFactory.TryGetRegistration(role, out var roleReg))
|
||||
{
|
||||
Log.Error($"Role component not found for RoleRequirementComponent: {role}");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_roles.MindHasRole(args.MindId, roleReg.Type, out _))
|
||||
return; // whitelist pass
|
||||
}
|
||||
|
||||
// whitelist fail
|
||||
args.Cancelled = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user