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 applying the objective component blacklist to the objective entity.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class ObjectiveBlacklistRequirementSystem : 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<ObjectiveBlacklistRequirementComponent, RequirementCheckEvent>(OnCheck);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnCheck(EntityUid uid, ObjectiveBlacklistRequirementComponent comp, ref RequirementCheckEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Cancelled)
|
|
|
|
|
return;
|
|
|
|
|
|
2024-07-16 02:17:18 -05:00
|
|
|
foreach (var objective in args.Mind.Objectives)
|
2023-09-16 22:25:56 +01:00
|
|
|
{
|
2024-06-03 14:40:03 -07:00
|
|
|
if (_whitelistSystem.IsBlacklistPass(comp.Blacklist, objective))
|
2023-09-16 22:25:56 +01:00
|
|
|
{
|
|
|
|
|
args.Cancelled = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-16 07:18:10 +01:00
|
|
|
}
|
|
|
|
|
}
|