Files
wwdpublic/Content.Server/DeltaV/Objectives/Systems/NotJobsRequirementSystem.cs
JJ 4996db833f Adds Psionic-related Antag Objectives. (#345)
* Adds Psionic-related Antag Objectives.

Look at them.

* Adds NotJobsRequirement, which should probably replace NotJob
2023-10-28 21:06:51 +02:00

32 lines
919 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 NotJobsRequirementSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<NotJobsRequirementComponent, RequirementCheckEvent>(OnCheck);
}
private void OnCheck(EntityUid uid, NotJobsRequirementComponent 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;
foreach (string forbidJob in comp.Jobs)
if (job.PrototypeId == forbidJob)
args.Cancelled = true;
}
}