Files
tbd-station-14/Content.Server/Objectives/Systems/NotJobRequirementSystem.cs
deltanedas f7711edbe3 Objectives ecs rework (#19967)
Co-authored-by: deltanedas <@deltanedas:kde.org>
2023-09-16 16:18:10 +10:00

32 lines
860 B
C#

using Content.Server.Objectives.Components;
using Content.Shared.Objectives.Components;
using Content.Shared.Roles.Jobs;
namespace Content.Server.Objectives.Systems;
/// <summary>
/// Handles checking the job blacklist for this objective.
/// </summary>
public sealed class NotJobRequirementSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<NotJobRequirementComponent, RequirementCheckEvent>(OnCheck);
}
private void OnCheck(EntityUid uid, NotJobRequirementComponent comp, ref RequirementCheckEvent args)
{
if (args.Cancelled)
return;
// if player has no job then don't care
if (!TryComp<JobComponent>(args.MindId, out var job))
return;
if (job.PrototypeId == comp.Job)
args.Cancelled = true;
}
}