Files
tbd-station-14/Content.Server/Objectives/Systems/ObjectiveBlacklistRequirementSystem.cs
deltanedas 30259e7234 make objective blacklist work (#20256)
Co-authored-by: deltanedas <@deltanedas:kde.org>
2023-09-16 14:25:56 -07:00

33 lines
913 B
C#

using Content.Server.Objectives.Components;
using Content.Shared.Objectives.Components;
namespace Content.Server.Objectives.Systems;
/// <summary>
/// Handles applying the objective component blacklist to the objective entity.
/// </summary>
public sealed class ObjectiveBlacklistRequirementSystem : EntitySystem
{
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.AllObjectives)
{
if (comp.Blacklist.IsValid(objective, EntityManager))
{
args.Cancelled = true;
return;
}
}
}
}