using Content.Shared.StatusIcon;
using Robust.Server.GameObjects;
using Robust.Shared.Prototypes;
+using Content.Shared.Roles;
+using System.Diagnostics.CodeAnalysis;
namespace Content.Server.Access.Systems
{
}
_cardSystem.TryChangeJobIcon(uid, jobIcon, idCard);
+
+ if (TryFindJobProtoFromIcon(jobIcon, out var job))
+ _cardSystem.TryChangeJobDepartment(uid, job, idCard);
+ }
+
+ private bool TryFindJobProtoFromIcon(StatusIconPrototype jobIcon, [NotNullWhen(true)] out JobPrototype? job)
+ {
+ foreach (var jobPrototype in _prototypeManager.EnumeratePrototypes<JobPrototype>())
+ {
+ if(jobPrototype.Icon == jobIcon.ID)
+ {
+ job = jobPrototype;
+ return true;
+ }
+ }
+
+ job = null;
+ return false;
}
}
}
&& _prototype.TryIndex<StatusIconPrototype>(job.Icon, out var jobIcon))
{
_idCard.TryChangeJobIcon(targetId, jobIcon, player: player);
+ _idCard.TryChangeJobDepartment(targetId, job);
}
if (!newAccessList.TrueForAll(x => component.AccessLevels.Contains(x)))
if (!Resolve(uid, ref id))
return false;
+ id.JobDepartments.Clear();
foreach (var department in _prototypeManager.EnumeratePrototypes<DepartmentPrototype>())
{
if (department.Roles.Contains(job.ID))