diff --git a/Content.Server/Access/Systems/AgentIDCardSystem.cs b/Content.Server/Access/Systems/AgentIDCardSystem.cs index 4d242e8f81..29657b509a 100644 --- a/Content.Server/Access/Systems/AgentIDCardSystem.cs +++ b/Content.Server/Access/Systems/AgentIDCardSystem.cs @@ -7,6 +7,8 @@ using Content.Shared.Interaction; 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 { @@ -98,6 +100,24 @@ 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()) + { + if(jobPrototype.Icon == jobIcon.ID) + { + job = jobPrototype; + return true; + } + } + + job = null; + return false; } } } diff --git a/Content.Server/Access/Systems/IdCardConsoleSystem.cs b/Content.Server/Access/Systems/IdCardConsoleSystem.cs index b3b2baf28e..791159f972 100644 --- a/Content.Server/Access/Systems/IdCardConsoleSystem.cs +++ b/Content.Server/Access/Systems/IdCardConsoleSystem.cs @@ -131,6 +131,7 @@ public sealed class IdCardConsoleSystem : SharedIdCardConsoleSystem && _prototype.TryIndex(job.Icon, out var jobIcon)) { _idCard.TryChangeJobIcon(targetId, jobIcon, player: player); + _idCard.TryChangeJobDepartment(targetId, job); } if (!newAccessList.TrueForAll(x => component.AccessLevels.Contains(x))) diff --git a/Content.Server/Access/Systems/IdCardSystem.cs b/Content.Server/Access/Systems/IdCardSystem.cs index 1c1e687417..def5e950d2 100644 --- a/Content.Server/Access/Systems/IdCardSystem.cs +++ b/Content.Server/Access/Systems/IdCardSystem.cs @@ -149,6 +149,7 @@ public sealed class IdCardSystem : SharedIdCardSystem if (!Resolve(uid, ref id)) return false; + id.JobDepartments.Clear(); foreach (var department in _prototypeManager.EnumeratePrototypes()) { if (department.Roles.Contains(job.ID))