Fix crew manifest department bugs (#24975)

This commit is contained in:
themias
2024-02-10 04:17:25 -05:00
committed by GitHub
parent 21e2289d2b
commit 543cd6a236
3 changed files with 22 additions and 0 deletions

View File

@@ -7,6 +7,8 @@ using Content.Shared.Interaction;
using Content.Shared.StatusIcon; using Content.Shared.StatusIcon;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Content.Shared.Roles;
using System.Diagnostics.CodeAnalysis;
namespace Content.Server.Access.Systems namespace Content.Server.Access.Systems
{ {
@@ -98,6 +100,24 @@ namespace Content.Server.Access.Systems
} }
_cardSystem.TryChangeJobIcon(uid, jobIcon, idCard); _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;
} }
} }
} }

View File

@@ -131,6 +131,7 @@ public sealed class IdCardConsoleSystem : SharedIdCardConsoleSystem
&& _prototype.TryIndex<StatusIconPrototype>(job.Icon, out var jobIcon)) && _prototype.TryIndex<StatusIconPrototype>(job.Icon, out var jobIcon))
{ {
_idCard.TryChangeJobIcon(targetId, jobIcon, player: player); _idCard.TryChangeJobIcon(targetId, jobIcon, player: player);
_idCard.TryChangeJobDepartment(targetId, job);
} }
if (!newAccessList.TrueForAll(x => component.AccessLevels.Contains(x))) if (!newAccessList.TrueForAll(x => component.AccessLevels.Contains(x)))

View File

@@ -149,6 +149,7 @@ public sealed class IdCardSystem : SharedIdCardSystem
if (!Resolve(uid, ref id)) if (!Resolve(uid, ref id))
return false; return false;
id.JobDepartments.Clear();
foreach (var department in _prototypeManager.EnumeratePrototypes<DepartmentPrototype>()) foreach (var department in _prototypeManager.EnumeratePrototypes<DepartmentPrototype>())
{ {
if (department.Roles.Contains(job.ID)) if (department.Roles.Contains(job.ID))