Files
tbd-station-14/Content.Shared/CriminalRecords/Systems/SharedCriminalRecordsSystem.cs
Эдуард 1468cbdb8a Wanted list cartridge (#31223)
* WantedListCartridge has been added

* WantedListCartridge user interface works

* WantedListCartridge is added as standard in some PDAs

* The CriminalRecordsSystem can now also take into account who created the record

* Added offense history table

* Fix of missing loaderUid for a cartridge without installing the program

* Added personalized information about the target

* The crime history has been finalized

* Added StatusList

* The officer's name has been added to the automatic history

* WantedListCartridge has been added to the HOS locker

* WantedListCartridge has been removed from brigmedic's preset programs

* The StealConditionSystem now takes into account whether a cartridge is inserted or installed

* Added target to thief on WantedListCartridge

* Merge fix

* Removing copypaste

* Fix merge 2

* The sprite of WantedListCartridge has been changed

* Update pda.yml

* Fix scrollbar in the history table

* Upstream localization fix

* `StatusList` has been replaced by `ListContainer` with `TextureRect`

* Margin fix
2024-09-19 12:22:02 +02:00

74 lines
2.6 KiB
C#

using Content.Shared.IdentityManagement;
using Content.Shared.IdentityManagement.Components;
using Content.Shared.Security;
using Content.Shared.Security.Components;
using Content.Shared.StationRecords;
using Robust.Shared.Serialization;
namespace Content.Shared.CriminalRecords.Systems;
public abstract class SharedCriminalRecordsSystem : 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);
}
}
[Serializable, NetSerializable]
public struct WantedRecord(GeneralStationRecord targetInfo, SecurityStatus status, string? reason, string? initiator, List<CrimeHistory> history)
{
public GeneralStationRecord TargetInfo = targetInfo;
public SecurityStatus Status = status;
public string? Reason = reason;
public string? Initiator = initiator;
public List<CrimeHistory> History = history;
};
[ByRefEvent]
public record struct CriminalRecordChangedEvent(CriminalRecord Record);
[ByRefEvent]
public record struct CriminalHistoryAddedEvent(CrimeHistory History);
[ByRefEvent]
public record struct CriminalHistoryRemovedEvent(CrimeHistory History);