criminal records revival (#22510)
This commit is contained in:
38
Content.Shared/CriminalRecords/CriminalRecord.cs
Normal file
38
Content.Shared/CriminalRecords/CriminalRecord.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Content.Shared.Security;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.CriminalRecords;
|
||||
|
||||
/// <summary>
|
||||
/// Criminal record for a crewmember.
|
||||
/// Can be viewed and edited in a criminal records console by security.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable, DataRecord]
|
||||
public sealed record CriminalRecord
|
||||
{
|
||||
/// <summary>
|
||||
/// Status of the person (None, Wanted, Detained).
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public SecurityStatus Status = SecurityStatus.None;
|
||||
|
||||
/// <summary>
|
||||
/// When Status is Wanted, the reason for it.
|
||||
/// Should never be set otherwise.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public string? Reason;
|
||||
|
||||
/// <summary>
|
||||
/// Criminal history of the person.
|
||||
/// This should have charges and time served added after someone is detained.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public List<CrimeHistory> History = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A line of criminal activity and the time it was added at.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public record struct CrimeHistory(TimeSpan AddTime, string Crime);
|
||||
102
Content.Shared/CriminalRecords/CriminalRecordsUi.cs
Normal file
102
Content.Shared/CriminalRecords/CriminalRecordsUi.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using Content.Shared.Security;
|
||||
using Content.Shared.StationRecords;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.CriminalRecords;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum CriminalRecordsConsoleKey : byte
|
||||
{
|
||||
Key
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Criminal records console state. There are a few states:
|
||||
/// - SelectedKey null, Record null, RecordListing null
|
||||
/// - The station record database could not be accessed.
|
||||
/// - SelectedKey null, Record null, RecordListing non-null
|
||||
/// - Records are populated in the database, or at least the station has
|
||||
/// the correct component.
|
||||
/// - SelectedKey non-null, Record null, RecordListing non-null
|
||||
/// - The selected key does not have a record tied to it.
|
||||
/// - SelectedKey non-null, Record non-null, RecordListing non-null
|
||||
/// - The selected key has a record tied to it, and the record has been sent.
|
||||
///
|
||||
/// - there is added new filters and so added new states
|
||||
/// -SelectedKey null, Record null, RecordListing null, filters non-null
|
||||
/// the station may have data, but they all did not pass through the filters
|
||||
///
|
||||
/// Other states are erroneous.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class CriminalRecordsConsoleState : BoundUserInterfaceState
|
||||
{
|
||||
/// <summary>
|
||||
/// Currently selected crewmember record key.
|
||||
/// </summary>
|
||||
public uint? SelectedKey = null;
|
||||
|
||||
public CriminalRecord? CriminalRecord = null;
|
||||
public GeneralStationRecord? StationRecord = null;
|
||||
public readonly Dictionary<uint, string>? RecordListing;
|
||||
public readonly StationRecordsFilter? Filter;
|
||||
|
||||
public CriminalRecordsConsoleState(Dictionary<uint, string>? recordListing, StationRecordsFilter? newFilter)
|
||||
{
|
||||
RecordListing = recordListing;
|
||||
Filter = newFilter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default state for opening the console
|
||||
/// </summary>
|
||||
public CriminalRecordsConsoleState() : this(null, null)
|
||||
{
|
||||
}
|
||||
|
||||
public bool IsEmpty() => SelectedKey == null && StationRecord == null && CriminalRecord == null && RecordListing == null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to change status, respecting the wanted/reason nullability rules in <see cref="CriminalRecord"/>.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class CriminalRecordChangeStatus : BoundUserInterfaceMessage
|
||||
{
|
||||
public readonly SecurityStatus Status;
|
||||
public readonly string? Reason;
|
||||
|
||||
public CriminalRecordChangeStatus(SecurityStatus status, string? reason)
|
||||
{
|
||||
Status = status;
|
||||
Reason = reason;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to add a single line to the record's crime history.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class CriminalRecordAddHistory : BoundUserInterfaceMessage
|
||||
{
|
||||
public readonly string Line;
|
||||
|
||||
public CriminalRecordAddHistory(string line)
|
||||
{
|
||||
Line = line;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to delete a single line from the crime history, by index.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class CriminalRecordDeleteHistory : BoundUserInterfaceMessage
|
||||
{
|
||||
public readonly uint Index;
|
||||
|
||||
public CriminalRecordDeleteHistory(uint index)
|
||||
{
|
||||
Index = index;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user