Criminal record hud icons (#25192)
* Security hud shows icon based on criminal record status * Criminal status now linked to name instead of identity * parole loc * Test fix * review changes * Check station records instead of storing names on criminal record consoles. * cleanup * more cleanup * review changes * change outdated comments * rename * review changes * remove event subscription * replaced event with trycomp * default value
This commit is contained in:
@@ -1,8 +1,52 @@
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.IdentityManagement.Components;
|
||||
using Content.Shared.Security;
|
||||
using Content.Shared.Security.Components;
|
||||
|
||||
namespace Content.Shared.CriminalRecords.Systems;
|
||||
|
||||
/// <summary>
|
||||
/// Nothing is predicted just exists for access.
|
||||
/// </summary>
|
||||
public abstract class SharedCriminalRecordsConsoleSystem : EntitySystem
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public void UpdateCriminalIdentity(string name, SecurityStatus status)
|
||||
{
|
||||
var query = EntityQueryEnumerator<IdentityComponent>();
|
||||
|
||||
while (query.MoveNext(out var uid, out var identity))
|
||||
{
|
||||
if (!Identity.Name(uid, EntityManager).Equals(name))
|
||||
continue;
|
||||
|
||||
if (status == SecurityStatus.None)
|
||||
RemComp<CriminalRecordComponent>(uid);
|
||||
else
|
||||
SetCriminalIcon(name, status, uid);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decides the icon that should be displayed on the entity based on the security status
|
||||
/// </summary>
|
||||
public void SetCriminalIcon(string name, SecurityStatus status, EntityUid characterUid)
|
||||
{
|
||||
EnsureComp<CriminalRecordComponent>(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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user