update files that wanted list added and fix stuff

This commit is contained in:
deltanedas 2025-02-10 00:38:12 +00:00
parent e751098441
commit 5e3b415df7
7 changed files with 140 additions and 19 deletions

View File

@ -907,7 +907,7 @@ public sealed partial class AdminVerbSystem
EnsureComp<BarkAccentComponent>(args.Target); EnsureComp<BarkAccentComponent>(args.Target);
EnsureComp<BleatingAccentComponent>(args.Target); EnsureComp<BleatingAccentComponent>(args.Target);
EnsureComp<FrenchAccentComponent>(args.Target); EnsureComp<FrenchAccentComponent>(args.Target);
EnsureComp<GermanAccentComponent>(args.Target); //EnsureComp<GermanAccentComponent>(args.Target); // DeltaV
EnsureComp<LizardAccentComponent>(args.Target); EnsureComp<LizardAccentComponent>(args.Target);
EnsureComp<MobsterAccentComponent>(args.Target); EnsureComp<MobsterAccentComponent>(args.Target);
EnsureComp<MothAccentComponent>(args.Target); EnsureComp<MothAccentComponent>(args.Target);

View File

@ -76,6 +76,13 @@ public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleS
} }
} }
private void GetOfficer(EntityUid uid, out string officer)
{
var tryGetIdentityShortInfoEvent = new TryGetIdentityShortInfoEvent(null, uid);
RaiseLocalEvent(tryGetIdentityShortInfoEvent);
officer = tryGetIdentityShortInfoEvent.Title ?? Loc.GetString("criminal-records-console-unknown-officer");
}
private void OnChangeStatus(Entity<CriminalRecordsConsoleComponent> ent, ref CriminalRecordChangeStatus msg) private void OnChangeStatus(Entity<CriminalRecordsConsoleComponent> ent, ref CriminalRecordChangeStatus msg)
{ {
// prevent malf client violating wanted/reason nullability // prevent malf client violating wanted/reason nullability
@ -98,17 +105,20 @@ public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleS
return; return;
} }
var oldStatus = record.Status;
var name = _records.RecordName(key.Value);
GetOfficer(mob.Value, out var officer);
// when arresting someone add it to history automatically // when arresting someone add it to history automatically
// fallback exists if the player was not set to wanted beforehand // fallback exists if the player was not set to wanted beforehand
if (msg.Status == SecurityStatus.Detained) if (msg.Status == SecurityStatus.Detained)
{ {
var oldReason = record.Reason ?? Loc.GetString("criminal-records-console-unspecified-reason"); var oldReason = record.Reason ?? Loc.GetString("criminal-records-console-unspecified-reason");
var history = Loc.GetString("criminal-records-console-auto-history", ("reason", oldReason)); var history = Loc.GetString("criminal-records-console-auto-history", ("reason", oldReason));
_criminalRecords.TryAddHistory(key.Value, history); _criminalRecords.TryAddHistory(key.Value, history, officer);
} }
var oldStatus = record.Status;
// will probably never fail given the checks above // will probably never fail given the checks above
name = _records.RecordName(key.Value); name = _records.RecordName(key.Value);
officer = Loc.GetString("criminal-records-console-unknown-officer"); officer = Loc.GetString("criminal-records-console-unknown-officer");
@ -142,10 +152,10 @@ public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleS
(_, SecurityStatus.Paroled) => "paroled", (_, SecurityStatus.Paroled) => "paroled",
// prisoner did their time // prisoner did their time
(_, SecurityStatus.Discharged) => "released", (_, SecurityStatus.Discharged) => "released",
// # DeltaV - person is subpoenaed by Justice Department
(_, SecurityStatus.Subpoenaed) => "subpoenaed",
// going from any other state to wanted, AOS or prisonbreak / lazy secoff never set them to released and they reoffended // going from any other state to wanted, AOS or prisonbreak / lazy secoff never set them to released and they reoffended
(_, SecurityStatus.Wanted) => "wanted", (_, SecurityStatus.Wanted) => "wanted",
// DeltaV - person is subpoenaed by Justice Department
(_, SecurityStatus.Subpoenaed) => "subpoenaed",
// person is no longer sus // person is no longer sus
(SecurityStatus.Suspected, SecurityStatus.None) => "not-suspected", (SecurityStatus.Suspected, SecurityStatus.None) => "not-suspected",
// going from wanted to none, must have been a mistake // going from wanted to none, must have been a mistake
@ -154,7 +164,7 @@ public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleS
(SecurityStatus.Detained, SecurityStatus.None) => "released", (SecurityStatus.Detained, SecurityStatus.None) => "released",
// criminal is no longer on parole // criminal is no longer on parole
(SecurityStatus.Paroled, SecurityStatus.None) => "not-parole", (SecurityStatus.Paroled, SecurityStatus.None) => "not-parole",
// # DeltaV - Person is no longer subpoenaed // DeltaV - Person is no longer subpoenaed
(SecurityStatus.Subpoenaed, SecurityStatus.None) => "not-subpoenaed", (SecurityStatus.Subpoenaed, SecurityStatus.None) => "not-subpoenaed",
// this is impossible // this is impossible
_ => "not-wanted" _ => "not-wanted"
@ -167,14 +177,16 @@ public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleS
private void OnAddHistory(Entity<CriminalRecordsConsoleComponent> ent, ref CriminalRecordAddHistory msg) private void OnAddHistory(Entity<CriminalRecordsConsoleComponent> ent, ref CriminalRecordAddHistory msg)
{ {
if (!CheckSelected(ent, msg.Actor, out _, out var key)) if (!CheckSelected(ent, msg.Actor, out var mob, out var key))
return; return;
var line = msg.Line.Trim(); var line = msg.Line.Trim();
if (line.Length < 1 || line.Length > ent.Comp.MaxStringLength) if (line.Length < 1 || line.Length > ent.Comp.MaxStringLength)
return; return;
if (!_criminalRecords.TryAddHistory(key.Value, line)) GetOfficer(mob.Value, out var officer);
if (!_criminalRecords.TryAddHistory(key.Value, line, officer))
return; return;
// no radio message since its not crucial to officers patrolling // no radio message since its not crucial to officers patrolling

View File

@ -1,10 +1,15 @@
using System.Diagnostics.CodeAnalysis; using System.Linq;
using Content.Server.CartridgeLoader;
using Content.Server.CartridgeLoader.Cartridges;
using Content.Server.StationRecords.Systems; using Content.Server.StationRecords.Systems;
using Content.Shared.CriminalRecords; using Content.Shared.CriminalRecords;
using Content.Shared.CriminalRecords.Systems; using Content.Shared.CriminalRecords.Systems;
using Content.Shared.Security; using Content.Shared.Security;
using Content.Shared.StationRecords; using Content.Shared.StationRecords;
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Server.Station.Systems;
using Content.Shared.CartridgeLoader;
using Content.Shared.CartridgeLoader.Cartridges;
namespace Content.Server.CriminalRecords.Systems; namespace Content.Server.CriminalRecords.Systems;
@ -20,12 +25,19 @@ public sealed class CriminalRecordsSystem : SharedCriminalRecordsSystem
{ {
[Dependency] private readonly GameTicker _ticker = default!; [Dependency] private readonly GameTicker _ticker = default!;
[Dependency] private readonly StationRecordsSystem _records = default!; [Dependency] private readonly StationRecordsSystem _records = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly CartridgeLoaderSystem _cartridge = default!;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<AfterGeneralRecordCreatedEvent>(OnGeneralRecordCreated); SubscribeLocalEvent<AfterGeneralRecordCreatedEvent>(OnGeneralRecordCreated);
/* DeltaV - wanted list replaced by secwatch
SubscribeLocalEvent<WantedListCartridgeComponent, CriminalRecordChangedEvent>(OnRecordChanged);
SubscribeLocalEvent<WantedListCartridgeComponent, CartridgeUiReadyEvent>(OnCartridgeUiReady);
SubscribeLocalEvent<WantedListCartridgeComponent, CriminalHistoryAddedEvent>(OnHistoryAdded);
SubscribeLocalEvent<WantedListCartridgeComponent, CriminalHistoryRemovedEvent>(OnHistoryRemoved); */
} }
private void OnGeneralRecordCreated(AfterGeneralRecordCreatedEvent ev) private void OnGeneralRecordCreated(AfterGeneralRecordCreatedEvent ev)
@ -39,14 +51,14 @@ public sealed class CriminalRecordsSystem : SharedCriminalRecordsSystem
/// Reason should only be passed if status is Wanted, nullability isn't checked. /// Reason should only be passed if status is Wanted, nullability isn't checked.
/// </summary> /// </summary>
/// <returns>True if the status is changed, false if not</returns> /// <returns>True if the status is changed, false if not</returns>
public bool TryChangeStatus(StationRecordKey key, SecurityStatus status, string? reason) public bool TryChangeStatus(StationRecordKey key, SecurityStatus status, string? reason, string? initiatorName = null)
{ {
// don't do anything if its the same status // don't do anything if its the same status
if (!_records.TryGetRecord<CriminalRecord>(key, out var record) if (!_records.TryGetRecord<CriminalRecord>(key, out var record)
|| status == record.Status) || status == record.Status)
return false; return false;
OverwriteStatus(key, record, status, reason); OverwriteStatus(key, record, status, reason, initiatorName);
return true; return true;
} }
@ -54,16 +66,25 @@ public sealed class CriminalRecordsSystem : SharedCriminalRecordsSystem
/// <summary> /// <summary>
/// Sets the status without checking previous status or reason nullability. /// Sets the status without checking previous status or reason nullability.
/// </summary> /// </summary>
public void OverwriteStatus(StationRecordKey key, CriminalRecord record, SecurityStatus status, string? reason) public void OverwriteStatus(StationRecordKey key, CriminalRecord record, SecurityStatus status, string? reason, string? initiatorName = null)
{ {
record.Status = status; record.Status = status;
record.Reason = reason; record.Reason = reason;
record.InitiatorName = initiatorName;
var name = _records.RecordName(key); var name = _records.RecordName(key);
if (name != string.Empty) if (name != string.Empty)
UpdateCriminalIdentity(name, status); UpdateCriminalIdentity(name, status);
_records.Synchronize(key); _records.Synchronize(key);
/* DeltaV - wanted list replaced by secwatch
var args = new CriminalRecordChangedEvent(record);
var query = EntityQueryEnumerator<WantedListCartridgeComponent>();
while (query.MoveNext(out var readerUid, out _))
{
RaiseLocalEvent(readerUid, ref args);
} */
} }
/// <summary> /// <summary>
@ -76,15 +97,24 @@ public sealed class CriminalRecordsSystem : SharedCriminalRecordsSystem
return false; return false;
record.History.Add(entry); record.History.Add(entry);
/* DeltaV - wanted list replaced by secwatch
var args = new CriminalHistoryAddedEvent(entry);
var query = EntityQueryEnumerator<WantedListCartridgeComponent>();
while (query.MoveNext(out var readerUid, out _))
{
RaiseLocalEvent(readerUid, ref args);
} */
return true; return true;
} }
/// <summary> /// <summary>
/// Creates and tries to add a history entry using the current time. /// Creates and tries to add a history entry using the current time.
/// </summary> /// </summary>
public bool TryAddHistory(StationRecordKey key, string line) public bool TryAddHistory(StationRecordKey key, string line, string? initiatorName = null)
{ {
var entry = new CrimeHistory(_ticker.RoundDuration(), line); var entry = new CrimeHistory(_ticker.RoundDuration(), line, initiatorName);
return TryAddHistory(key, entry); return TryAddHistory(key, entry);
} }
@ -100,7 +130,60 @@ public sealed class CriminalRecordsSystem : SharedCriminalRecordsSystem
if (index >= record.History.Count) if (index >= record.History.Count)
return false; return false;
var history = record.History[(int)index];
record.History.RemoveAt((int) index); record.History.RemoveAt((int) index);
/* DeltaV - wanted list replaced by secwatch
var args = new CriminalHistoryRemovedEvent(history);
var query = EntityQueryEnumerator<WantedListCartridgeComponent>();
while (query.MoveNext(out var readerUid, out _))
{
RaiseLocalEvent(readerUid, ref args);
} */
return true; return true;
} }
/* DeltaV - wanted list replaced by secwatch
private void OnRecordChanged(Entity<WantedListCartridgeComponent> ent, ref CriminalRecordChangedEvent args) =>
StateChanged(ent);
private void OnHistoryAdded(Entity<WantedListCartridgeComponent> ent, ref CriminalHistoryAddedEvent args) =>
StateChanged(ent);
private void OnHistoryRemoved(Entity<WantedListCartridgeComponent> ent, ref CriminalHistoryRemovedEvent args) =>
StateChanged(ent);
private void StateChanged(Entity<WantedListCartridgeComponent> ent)
{
if (Comp<CartridgeComponent>(ent).LoaderUid is not { } loaderUid)
return;
UpdateReaderUi(ent, loaderUid);
}
private void OnCartridgeUiReady(Entity<WantedListCartridgeComponent> ent, ref CartridgeUiReadyEvent args)
{
UpdateReaderUi(ent, args.Loader);
}
private void UpdateReaderUi(Entity<WantedListCartridgeComponent> ent, EntityUid loaderUid)
{
if (_station.GetOwningStation(ent) is not { } station)
return;
var records = _records.GetRecordsOfType<CriminalRecord>(station)
.Where(cr => cr.Item2.Status is not SecurityStatus.None || cr.Item2.History.Count > 0)
.Select(cr =>
{
var (i, r) = cr;
var key = new StationRecordKey(i, station);
// Hopefully it will work smoothly.....
_records.TryGetRecord(key, out GeneralStationRecord? generalRecord);
return new WantedRecord(generalRecord!, r.Status, r.Reason, r.InitiatorName, r.History);
});
var state = new WantedListUiState(records.ToList());
_cartridge.UpdateCartridgeUiState(loaderUid, state);
}*/
} }

View File

@ -159,7 +159,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
component.Subverted = true; component.Subverted = true;
// Add the first emag law before the others // Add the first emag law before the others
var name = CompOrNull<EmagSiliconLawComponent>(uid)?.OwnerName ?? Name(args.UserUid); // DeltaV: Reuse emagger name if possible var name = CompOrNull<EmagSiliconLawComponent>(uid)?.OwnerName ?? Name(args.user); // DeltaV: Reuse emagger name if possible
component.Lawset?.Laws.Insert(0, new SiliconLaw component.Lawset?.Laws.Insert(0, new SiliconLaw
{ {
LawString = Loc.GetString("law-emag-custom", ("name", name), ("title", Loc.GetString(component.Lawset.ObeysTo))), // DeltaV: pass name from variable LawString = Loc.GetString("law-emag-custom", ("name", name), ("title", Loc.GetString(component.Lawset.ObeysTo))), // DeltaV: pass name from variable

View File

@ -31,7 +31,7 @@ public sealed partial class BorgSwitchableTypeSystem
if (CompOrNull<EmagSiliconLawComponent>(uid)?.OwnerName != null) if (CompOrNull<EmagSiliconLawComponent>(uid)?.OwnerName != null)
{ {
// raising the event manually to bypass re-emagging checks // raising the event manually to bypass re-emagging checks
var ev = new GotEmaggedEvent(uid); // user wont be used since OwnerName isnt null, safe to pass itself var ev = new GotEmaggedEvent(uid, EmagType.Interaction); // user wont be used since OwnerName isnt null, safe to pass itself
RaiseLocalEvent(uid, ref ev); RaiseLocalEvent(uid, ref ev);
} }

View File

@ -23,6 +23,12 @@ public sealed record CriminalRecord
[DataField] [DataField]
public string? Reason; public string? Reason;
/// <summary>
/// The name of the person who changed the status.
/// </summary>
[DataField]
public string? InitiatorName;
/// <summary> /// <summary>
/// Criminal history of the person. /// Criminal history of the person.
/// This should have charges and time served added after someone is detained. /// This should have charges and time served added after someone is detained.
@ -35,4 +41,4 @@ public sealed record CriminalRecord
/// A line of criminal activity and the time it was added at. /// A line of criminal activity and the time it was added at.
/// </summary> /// </summary>
[Serializable, NetSerializable] [Serializable, NetSerializable]
public record struct CrimeHistory(TimeSpan AddTime, string Crime); public record struct CrimeHistory(TimeSpan AddTime, string Crime, string? InitiatorName);

View File

@ -2,6 +2,8 @@ using Content.Shared.IdentityManagement;
using Content.Shared.IdentityManagement.Components; using Content.Shared.IdentityManagement.Components;
using Content.Shared.Security; using Content.Shared.Security;
using Content.Shared.Security.Components; using Content.Shared.Security.Components;
using Content.Shared.StationRecords;
using Robust.Shared.Serialization;
namespace Content.Shared.CriminalRecords.Systems; namespace Content.Shared.CriminalRecords.Systems;
@ -43,7 +45,6 @@ public abstract class SharedCriminalRecordsSystem : EntitySystem
SecurityStatus.Detained => "SecurityIconIncarcerated", SecurityStatus.Detained => "SecurityIconIncarcerated",
SecurityStatus.Discharged => "SecurityIconDischarged", SecurityStatus.Discharged => "SecurityIconDischarged",
SecurityStatus.Suspected => "SecurityIconSuspected", SecurityStatus.Suspected => "SecurityIconSuspected",
SecurityStatus.Subpoenaed => "SecurityIconSubpoenaed", /// # DeltaV Justice Department Subpoena
_ => record.StatusIcon _ => record.StatusIcon
}; };
@ -51,3 +52,22 @@ public abstract class SharedCriminalRecordsSystem : EntitySystem
Dirty(characterUid, record); 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);