mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
35 lines
1 KiB
C#
35 lines
1 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 partial class ObjectiveBlacklistRequirementSystem : EntitySystem
|
|
{
|
|
[Dependency] private 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.IsWhitelistPass(comp.Blacklist, objective))
|
|
{
|
|
args.Cancelled = true;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|