Add job whitelist system (#28085)

* Add job whitelist system

* Address reviews

* Fix name

* Apply suggestions from code review

Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>

* cancinium

---------

Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
This commit is contained in:
DrSmugleaf
2024-06-01 05:08:31 -07:00
committed by GitHub
parent e3a66136bf
commit 19be94c9ea
35 changed files with 4666 additions and 47 deletions

View File

@@ -2,6 +2,7 @@ using System.Linq;
using Content.Server.Administration.Managers;
using Content.Server.Players.PlayTimeTracking;
using Content.Server.Station.Components;
using Content.Server.Station.Events;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Robust.Shared.Network;
@@ -342,8 +343,9 @@ public sealed partial class StationJobsSystem
foreach (var (player, profile) in profiles)
{
var roleBans = _banManager.GetJobBans(player);
var profileJobs = profile.JobPriorities.Keys.ToList();
_playTime.RemoveDisallowedJobs(player, ref profileJobs);
var profileJobs = profile.JobPriorities.Keys.Select(k => new ProtoId<JobPrototype>(k)).ToList();
var ev = new StationJobsGetCandidatesEvent(player, profileJobs);
RaiseLocalEvent(ref ev);
List<string>? availableJobs = null;
@@ -354,7 +356,7 @@ public sealed partial class StationJobsSystem
if (!(priority == selectedPriority || selectedPriority is null))
continue;
if (!_prototypeManager.TryIndex(jobId, out JobPrototype? job))
if (!_prototypeManager.TryIndex(jobId, out var job))
continue;
if (weight is not null && job.Weight != weight.Value)