using Content.Shared.IdentityManagement; using Content.Shared.IdentityManagement.Components; using Content.Shared.Security; using Content.Shared.Security.Components; namespace Content.Shared.CriminalRecords.Systems; public abstract class SharedCriminalRecordsConsoleSystem : EntitySystem { /// /// Any entity that has a the name of the record that was just changed as their visible name will get their icon /// updated with the new status, if the record got removed their icon will be removed too. /// public void UpdateCriminalIdentity(string name, SecurityStatus status) { var query = EntityQueryEnumerator(); while (query.MoveNext(out var uid, out var identity)) { if (!Identity.Name(uid, EntityManager).Equals(name)) continue; if (status == SecurityStatus.None) RemComp(uid); else SetCriminalIcon(name, status, uid); } } /// /// Decides the icon that should be displayed on the entity based on the security status /// public void SetCriminalIcon(string name, SecurityStatus status, EntityUid characterUid) { EnsureComp(characterUid, out var record); var previousIcon = record.StatusIcon; record.StatusIcon = status switch { SecurityStatus.Paroled => "SecurityIconParoled", SecurityStatus.Wanted => "SecurityIconWanted", SecurityStatus.Detained => "SecurityIconIncarcerated", SecurityStatus.Discharged => "SecurityIconDischarged", SecurityStatus.Suspected => "SecurityIconSuspected", _ => record.StatusIcon }; if(previousIcon != record.StatusIcon) Dirty(characterUid, record); } }