criminal records revival (#22510)

This commit is contained in:
deltanedas
2024-02-04 23:29:35 +00:00
committed by GitHub
parent c856dd7506
commit 683591ab04
34 changed files with 1564 additions and 339 deletions

View File

@@ -34,7 +34,7 @@ public sealed partial class AccessReaderComponent : Component
public List<HashSet<string>> AccessLists = new();
/// <summary>
/// A list of <see cref="StationRecordKey"/>s that grant access. Only a single matching key is required tp gaim
/// A list of <see cref="StationRecordKey"/>s that grant access. Only a single matching key is required to gain
/// access.
/// </summary>
[DataField]

View 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);

View 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;
}
}

View File

@@ -0,0 +1,15 @@
namespace Content.Shared.Security;
/// <summary>
/// Status used in Criminal Records.
///
/// None - the default value
/// Wanted - the person is being wanted by security
/// Detained - the person is detained by security
/// </summary>
public enum SecurityStatus : byte
{
None,
Wanted,
Detained
}

View File

@@ -30,14 +30,16 @@ public enum GeneralStationRecordConsoleKey : byte
public sealed class GeneralStationRecordConsoleState : BoundUserInterfaceState
{
/// <summary>
/// Current selected key.
/// Current selected key.
/// Station is always the station that owns the console.
/// </summary>
public (NetEntity, uint)? SelectedKey { get; }
public GeneralStationRecord? Record { get; }
public Dictionary<(NetEntity, uint), string>? RecordListing { get; }
public GeneralStationRecordsFilter? Filter { get; }
public GeneralStationRecordConsoleState((NetEntity, uint)? key, GeneralStationRecord? record,
Dictionary<(NetEntity, uint), string>? recordListing, GeneralStationRecordsFilter? newFilter)
public readonly uint? SelectedKey;
public readonly GeneralStationRecord? Record;
public readonly Dictionary<uint, string>? RecordListing;
public readonly StationRecordsFilter? Filter;
public GeneralStationRecordConsoleState(uint? key, GeneralStationRecord? record,
Dictionary<uint, string>? recordListing, StationRecordsFilter? newFilter)
{
SelectedKey = key;
Record = record;
@@ -45,16 +47,24 @@ public sealed class GeneralStationRecordConsoleState : BoundUserInterfaceState
Filter = newFilter;
}
public GeneralStationRecordConsoleState() : this(null, null, null, null)
{
}
public bool IsEmpty() => SelectedKey == null
&& Record == null && RecordListing == null;
}
/// <summary>
/// Select a specific crewmember's record, or deselect.
/// Used by any kind of records console including general and criminal.
/// </summary>
[Serializable, NetSerializable]
public sealed class SelectGeneralStationRecord : BoundUserInterfaceMessage
public sealed class SelectStationRecord : BoundUserInterfaceMessage
{
public (NetEntity, uint)? SelectedKey { get; }
public readonly uint? SelectedKey;
public SelectGeneralStationRecord((NetEntity, uint)? selectedKey)
public SelectStationRecord(uint? selectedKey)
{
SelectedKey = selectedKey;
}

View File

@@ -7,46 +7,46 @@ namespace Content.Shared.StationRecords;
/// General station record. Indicates the crewmember's name and job.
/// </summary>
[Serializable, NetSerializable]
public sealed class GeneralStationRecord
public sealed record GeneralStationRecord
{
/// <summary>
/// Name tied to this station record.
/// </summary>
[ViewVariables]
[DataField]
public string Name = string.Empty;
/// <summary>
/// Age of the person that this station record represents.
/// </summary>
[ViewVariables]
[DataField]
public int Age;
/// <summary>
/// Job title tied to this station record.
/// </summary>
[ViewVariables]
[DataField]
public string JobTitle = string.Empty;
/// <summary>
/// Job icon tied to this station record.
/// </summary>
[ViewVariables]
[DataField]
public string JobIcon = string.Empty;
[ViewVariables]
[DataField]
public string JobPrototype = string.Empty;
/// <summary>
/// Species tied to this station record.
/// </summary>
[ViewVariables]
[DataField]
public string Species = string.Empty;
/// <summary>
/// Gender identity tied to this station record.
/// </summary>
/// <remarks>Sex should be placed in a medical record, not a general record.</remarks>
[ViewVariables]
[DataField]
public Gender Gender = Gender.Epicene;
/// <summary>
@@ -54,18 +54,18 @@ public sealed class GeneralStationRecord
/// This is taken from the 'weight' of a job prototype,
/// usually.
/// </summary>
[ViewVariables]
[DataField]
public int DisplayPriority;
/// <summary>
/// Fingerprint of the person.
/// </summary>
[ViewVariables]
[DataField]
public string? Fingerprint;
/// <summary>
/// DNA of the person.
/// </summary>
[ViewVariables]
[DataField]
public string? DNA;
}

View File

@@ -1,38 +0,0 @@
using Robust.Shared.Serialization;
namespace Content.Shared.StationRecords;
[Serializable, NetSerializable]
public sealed class GeneralStationRecordsFilter
{
public GeneralStationRecordFilterType Type { get; set; }
= GeneralStationRecordFilterType.Name;
public string Value { get; set; } = "";
public GeneralStationRecordsFilter(GeneralStationRecordFilterType filterType, string newValue = "")
{
Type = filterType;
Value = newValue;
}
}
[Serializable, NetSerializable]
public sealed class GeneralStationRecordsFilterMsg : BoundUserInterfaceMessage
{
public string Value { get; }
public GeneralStationRecordFilterType Type { get; }
public GeneralStationRecordsFilterMsg(GeneralStationRecordFilterType filterType,
string filterValue)
{
Type = filterType;
Value = filterValue;
}
}
[Serializable, NetSerializable]
public enum GeneralStationRecordFilterType : byte
{
Name,
Prints,
DNA,
}

View File

@@ -1,10 +1,14 @@
namespace Content.Shared.StationRecords;
// Station record keys. These should be stored somewhere,
// preferably within an ID card.
/// <summary>
/// Station record keys. These should be stored somewhere,
/// preferably within an ID card.
/// This refers to both the id and station. This is suitable for an access reader field etc,
/// but when you already know the station just store the id itself.
/// </summary>
public readonly struct StationRecordKey : IEquatable<StationRecordKey>
{
[DataField("id")]
[DataField]
public readonly uint Id;
[DataField("station")]

View File

@@ -0,0 +1,44 @@
using Robust.Shared.Serialization;
namespace Content.Shared.StationRecords;
[Serializable, NetSerializable]
public sealed class StationRecordsFilter
{
public StationRecordFilterType Type = StationRecordFilterType.Name;
public string Value = "";
public StationRecordsFilter(StationRecordFilterType filterType, string newValue = "")
{
Type = filterType;
Value = newValue;
}
}
/// <summary>
/// Message for updating the filter on any kind of records console.
/// </summary>
[Serializable, NetSerializable]
public sealed class SetStationRecordFilter : BoundUserInterfaceMessage
{
public readonly string Value;
public readonly StationRecordFilterType Type;
public SetStationRecordFilter(StationRecordFilterType filterType,
string filterValue)
{
Type = filterType;
Value = filterValue;
}
}
/// <summary>
/// Different strings that results can be filtered by.
/// </summary>
[Serializable, NetSerializable]
public enum StationRecordFilterType : byte
{
Name,
Prints,
DNA,
}