2023-09-16 07:18:10 +01:00
|
|
|
using Content.Server.Objectives.Components;
|
|
|
|
|
using Content.Shared.Objectives.Components;
|
2024-06-03 14:40:03 -07:00
|
|
|
using Content.Shared.Whitelist;
|
2023-09-16 07:18:10 +01:00
|
|
|
|
|
|
|
|
namespace Content.Server.Objectives.Systems;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Handles role requirement for objectives that require a certain (probably antagonist) role(s).
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class RoleRequirementSystem : EntitySystem
|
|
|
|
|
{
|
2024-06-03 14:40:03 -07:00
|
|
|
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
|
2023-09-16 07:18:10 +01:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<RoleRequirementComponent, RequirementCheckEvent>(OnCheck);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnCheck(EntityUid uid, RoleRequirementComponent comp, ref RequirementCheckEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Cancelled)
|
|
|
|
|
return;
|
|
|
|
|
|
2024-06-03 14:40:03 -07:00
|
|
|
if (_whitelistSystem.IsWhitelistFail(comp.Roles, args.MindId))
|
2023-09-16 07:18:10 +01:00
|
|
|
args.Cancelled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|