using Content.Shared.Access.Components; using Content.Shared.Access.Systems; using Content.Shared.Overlays; using Content.Shared.PDA; using Content.Shared.StatusIcon; using Content.Shared.StatusIcon.Components; using Robust.Shared.Prototypes; namespace Content.Client.Overlays; public sealed class ShowSecurityIconsSystem : EquipmentHudSystem { [Dependency] private readonly IPrototypeManager _prototypeMan = default!; [Dependency] private readonly AccessReaderSystem _accessReader = default!; [ValidatePrototypeId] private const string JobIconForNoId = "JobIconNoId"; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnGetStatusIconsEvent); } private void OnGetStatusIconsEvent(EntityUid uid, StatusIconComponent _, ref GetStatusIconsEvent @event) { if (!IsActive || @event.InContainer) { return; } var healthIcons = DecideSecurityIcon(uid); @event.StatusIcons.AddRange(healthIcons); } private IReadOnlyList DecideSecurityIcon(EntityUid uid) { var result = new List(); var jobIconToGet = JobIconForNoId; if (_accessReader.FindAccessItemsInventory(uid, out var items)) { foreach (var item in items) { // ID Card if (TryComp(item, out IdCardComponent? id)) { jobIconToGet = id.JobIcon; break; } // PDA if (TryComp(item, out PdaComponent? pda) && pda.ContainedId != null && TryComp(pda.ContainedId, out id)) { jobIconToGet = id.JobIcon; break; } } } if (_prototypeMan.TryIndex(jobIconToGet, out var jobIcon)) result.Add(jobIcon); else Log.Error($"Invalid job icon prototype: {jobIcon}"); // Add arrest icons here, WYCI. return result; } }