Files
tbd-station-14/Content.Server/Objectives/Systems/ObjectiveBlacklistRequirementSystem.cs
Cojoke 927cf7799f Remove uses of AllObjectives (#30077)
Remove the uses of AllObjectives
2024-07-16 10:17:18 +03:00

36 lines
1.0 KiB
C#

using Content.Server.Objectives.Components;
using Content.Shared.Objectives.Components;
using Content.Shared.Whitelist;
namespace Content.Server.Objectives.Systems;
/// <summary>
/// Handles applying the objective component blacklist to the objective entity.
/// </summary>
public sealed class ObjectiveBlacklistRequirementSystem : EntitySystem
{
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ObjectiveBlacklistRequirementComponent, RequirementCheckEvent>(OnCheck);
}
private void OnCheck(EntityUid uid, ObjectiveBlacklistRequirementComponent comp, ref RequirementCheckEvent args)
{
if (args.Cancelled)
return;
foreach (var objective in args.Mind.Objectives)
{
if (_whitelistSystem.IsBlacklistPass(comp.Blacklist, objective))
{
args.Cancelled = true;
return;
}
}
}
}