NotJobRequirementSystem.cs 874 B

12345678910111213141516171819202122232425262728293031
  1. using Content.Shared.Objectives.Components;
  2. using Content.Shared.Roles.Jobs;
  3. namespace Content.Server.Objectives.Systems;
  4. /// <summary>
  5. /// Handles checking the job blacklist for this objective.
  6. /// </summary>
  7. public sealed class NotJobRequirementSystem : EntitySystem
  8. {
  9. [Dependency] private readonly SharedJobSystem _jobs = default!;
  10. public override void Initialize()
  11. {
  12. base.Initialize();
  13. SubscribeLocalEvent<NotJobRequirementComponent, RequirementCheckEvent>(OnCheck);
  14. }
  15. private void OnCheck(EntityUid uid, NotJobRequirementComponent comp, ref RequirementCheckEvent args)
  16. {
  17. if (args.Cancelled)
  18. return;
  19. _jobs.MindTryGetJob(args.MindId, out var proto);
  20. // if player has no job then don't care
  21. if (proto is not null && proto.ID == comp.Job)
  22. args.Cancelled = true;
  23. }
  24. }