mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-23 08:37:48 +03:00
# Description Cherry-picks https://github.com/DeltaV-Station/Delta-v/pull/1237 All credit goes to the original author, deltanedas Adds a PDA app that lets seccies know who's wanted and who's about to be thrown out of an airlock without relying on the sechud and people having their IDs on them. # Media  (see the original PR for a better preview) # Changelog 🆑 deltanedas - add: Security can find the new SecWatch™ app in their PDAs to see current suspects and wanted criminals. Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: Azzy <azzydev@icloud.com>
74 lines
2.6 KiB
C#
74 lines
2.6 KiB
C#
using Content.Server.Station.Systems;
|
|
using Content.Server.StationRecords;
|
|
using Content.Server.StationRecords.Systems;
|
|
using Content.Shared.CartridgeLoader;
|
|
using Content.Shared.CartridgeLoader.Cartridges;
|
|
using Content.Shared.CriminalRecords;
|
|
using Content.Shared.StationRecords;
|
|
|
|
namespace Content.Server.CartridgeLoader.Cartridges;
|
|
|
|
public sealed class SecWatchCartridgeSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly CartridgeLoaderSystem _cartridgeLoader = default!;
|
|
[Dependency] private readonly StationRecordsSystem _records = default!;
|
|
[Dependency] private readonly StationSystem _station = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<RecordModifiedEvent>(OnRecordModified);
|
|
|
|
SubscribeLocalEvent<SecWatchCartridgeComponent, CartridgeUiReadyEvent>(OnUiReady);
|
|
}
|
|
|
|
private void OnRecordModified(RecordModifiedEvent args)
|
|
{
|
|
// when a record is modified update the ui of every loaded cartridge tuned to the same station
|
|
var query = EntityQueryEnumerator<SecWatchCartridgeComponent, CartridgeComponent>();
|
|
while (query.MoveNext(out var uid, out var comp, out var cartridge))
|
|
{
|
|
if (cartridge.LoaderUid is not {} loader || comp.Station != args.Station)
|
|
continue;
|
|
|
|
UpdateUI((uid, comp), loader);
|
|
}
|
|
}
|
|
|
|
private void OnUiReady(Entity<SecWatchCartridgeComponent> ent, ref CartridgeUiReadyEvent args)
|
|
{
|
|
UpdateUI(ent, args.Loader);
|
|
}
|
|
|
|
private void UpdateUI(Entity<SecWatchCartridgeComponent> ent, EntityUid loader)
|
|
{
|
|
// if the loader is on a grid, update the station
|
|
// if it is off grid use the cached station
|
|
if (_station.GetOwningStation(loader) is {} station)
|
|
ent.Comp.Station = station;
|
|
|
|
if (!TryComp<StationRecordsComponent>(ent.Comp.Station, out var records))
|
|
return;
|
|
|
|
station = ent.Comp.Station.Value;
|
|
|
|
var entries = new List<SecWatchEntry>();
|
|
foreach (var (id, criminal) in _records.GetRecordsOfType<CriminalRecord>(station, records))
|
|
{
|
|
if (!ent.Comp.Statuses.Contains(criminal.Status))
|
|
continue;
|
|
|
|
var key = new StationRecordKey(id, station);
|
|
if (!_records.TryGetRecord<GeneralStationRecord>(key, out var general, records))
|
|
continue;
|
|
|
|
var status = criminal.Status;
|
|
entries.Add(new SecWatchEntry(general.Name, general.JobTitle, criminal.Status, criminal.Reason));
|
|
}
|
|
|
|
var state = new SecWatchUiState(entries);
|
|
_cartridgeLoader.UpdateCartridgeUiState(loader, state);
|
|
}
|
|
}
|