Files
tbd-station-14/Content.Server/Objectives/Systems/NotJobRequirementSystem.cs
Super dd61991b1c Add multi-job exclusion support to objectives, and add more appropriate job restrictions to certain thief objectives. (#40065)
* multi exclusion!

* quick correction

* migrate all job: fields to jobs fields to avoid test fails. breaking change!!!
2025-10-31 09:26:25 +00:00

32 lines
882 B
C#

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
{
[Dependency] private readonly SharedJobSystem _jobs = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<NotJobRequirementComponent, RequirementCheckEvent>(OnCheck);
}
private void OnCheck(EntityUid uid, NotJobRequirementComponent comp, ref RequirementCheckEvent args)
{
if (args.Cancelled)
return;
_jobs.MindTryGetJob(args.MindId, out var proto);
// if player has no job then don't care
if (proto is not null && comp.Jobs.Contains(proto.ID))
args.Cancelled = true;
}
}