- add: Criminal records hud icons (#32)
This commit is contained in:
@@ -34,8 +34,8 @@ public sealed class CriminalRecordsConsoleBoundUserInterface : BoundUserInterfac
|
||||
SendMessage(new SetStationRecordFilter(type, filterValue));
|
||||
_window.OnStatusSelected += status =>
|
||||
SendMessage(new CriminalRecordChangeStatus(status, null));
|
||||
_window.OnDialogConfirmed += (_, reason) =>
|
||||
SendMessage(new CriminalRecordChangeStatus(SecurityStatus.Wanted, reason));
|
||||
_window.OnDialogConfirmed += (status, reason) => // WD EDIT
|
||||
SendMessage(new CriminalRecordChangeStatus(status, reason)); // WD EDIT
|
||||
_window.OnHistoryUpdated += UpdateHistory;
|
||||
_window.OnHistoryClosed += () => _historyWindow?.Close();
|
||||
_window.OnClose += Close;
|
||||
|
||||
@@ -217,16 +217,16 @@ public sealed partial class CriminalRecordsConsoleWindow : FancyWindow
|
||||
|
||||
private void SetStatus(SecurityStatus status)
|
||||
{
|
||||
if (status == SecurityStatus.Wanted)
|
||||
if (status is SecurityStatus.Wanted or SecurityStatus.Suspected) // WD EDIT
|
||||
{
|
||||
GetWantedReason();
|
||||
GetWantedReason(status); // WD EDIT
|
||||
return;
|
||||
}
|
||||
|
||||
OnStatusSelected?.Invoke(status);
|
||||
}
|
||||
|
||||
private void GetWantedReason()
|
||||
private void GetWantedReason(SecurityStatus status = SecurityStatus.Wanted) // WD EDIT
|
||||
{
|
||||
if (_reasonDialog != null)
|
||||
{
|
||||
@@ -235,7 +235,7 @@ public sealed partial class CriminalRecordsConsoleWindow : FancyWindow
|
||||
}
|
||||
|
||||
var field = "reason";
|
||||
var title = Loc.GetString("criminal-records-status-wanted");
|
||||
var title = Loc.GetString($"criminal-records-status-{status.ToString().ToLower()}"); // WD EDIT
|
||||
var placeholders = _proto.Index<DatasetPrototype>(ReasonPlaceholders);
|
||||
var placeholder = Loc.GetString("criminal-records-console-reason-placeholder", ("placeholder", _random.Pick(placeholders.Values))); // just funny it doesn't actually get used
|
||||
var prompt = Loc.GetString("criminal-records-console-reason");
|
||||
@@ -250,7 +250,7 @@ public sealed partial class CriminalRecordsConsoleWindow : FancyWindow
|
||||
if (reason.Length < 1 || reason.Length > 256)
|
||||
return;
|
||||
|
||||
OnDialogConfirmed?.Invoke(SecurityStatus.Wanted, reason);
|
||||
OnDialogConfirmed?.Invoke(status, reason); // WD EDIT
|
||||
};
|
||||
|
||||
_reasonDialog.OnClose += () => { _reasonDialog = null; };
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
using System.Linq;
|
||||
using Content.Shared._Miracle.Components;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.IdentityManagement.Components;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Mindshield.Components;
|
||||
using Content.Shared.Overlays;
|
||||
using Content.Shared.PDA;
|
||||
using Content.Shared.Security;
|
||||
using Content.Shared.StatusIcon;
|
||||
using Content.Shared.StatusIcon.Components;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -13,12 +18,11 @@ public sealed class ShowSecurityIconsSystem : EquipmentHudSystem<ShowSecurityIco
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeMan = default!;
|
||||
[Dependency] private readonly AccessReaderSystem _accessReader = default!;
|
||||
/*/ WD EDIT START
|
||||
// WD EDIT START
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
||||
[Dependency] private readonly ShowCrimeRecordsSystem _parentSystem = default!;
|
||||
[Dependency] private readonly SharedIdCardSystem _idCard = default!;
|
||||
// WD EDIT END
|
||||
*/
|
||||
|
||||
[ValidatePrototypeId<StatusIconPrototype>]
|
||||
private const string JobIconForNoId = "JobIconNoId";
|
||||
@@ -80,84 +84,65 @@ public sealed class ShowSecurityIconsSystem : EquipmentHudSystem<ShowSecurityIco
|
||||
result.Add(icon);
|
||||
}
|
||||
|
||||
/*/ WD EDIT START
|
||||
if (!GetRecord(uid, out var type))
|
||||
return result;
|
||||
|
||||
var protoId = type switch
|
||||
// WD EDIT START
|
||||
string? protoId;
|
||||
switch (GetRecord(uid))
|
||||
{
|
||||
EnumCriminalRecordType.Discharged => "CriminalRecordIconDischarged",
|
||||
EnumCriminalRecordType.Incarcerated => "CriminalRecordIconIncarcerated",
|
||||
EnumCriminalRecordType.Parolled => "CriminalRecordIconParolled",
|
||||
EnumCriminalRecordType.Suspected => "CriminalRecordIconSuspected",
|
||||
EnumCriminalRecordType.Wanted => "CriminalRecordIconWanted",
|
||||
_ => "CriminalRecordIconReleased"
|
||||
};
|
||||
case SecurityStatus.Detained:
|
||||
protoId = "CriminalRecordIconIncarcerated";
|
||||
break;
|
||||
case SecurityStatus.Released:
|
||||
protoId = "CriminalRecordIconReleased";
|
||||
break;
|
||||
case SecurityStatus.Suspected:
|
||||
protoId = "CriminalRecordIconSuspected";
|
||||
break;
|
||||
case SecurityStatus.Wanted:
|
||||
protoId = "CriminalRecordIconWanted";
|
||||
break;
|
||||
case SecurityStatus.None:
|
||||
default:
|
||||
return result;
|
||||
}
|
||||
|
||||
if (_prototypeMan.TryIndex<StatusIconPrototype>(protoId, out var recordIcon))
|
||||
result.Add(recordIcon);
|
||||
// WD EDIT END
|
||||
*/
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*/ WD EDIT START
|
||||
private bool GetRecord(EntityUid uid, out EnumCriminalRecordType type)
|
||||
// WD EDIT START
|
||||
private SecurityStatus GetRecord(EntityUid uid)
|
||||
{
|
||||
if (!_entManager.TryGetComponent(uid, out MetaDataComponent? meta))
|
||||
return SecurityStatus.None;
|
||||
|
||||
var name = meta.EntityName;
|
||||
|
||||
var ev = new SeeIdentityAttemptEvent();
|
||||
RaiseLocalEvent(uid, ev);
|
||||
|
||||
if (ev.Cancelled)
|
||||
{
|
||||
type = EnumCriminalRecordType.Released;
|
||||
return false;
|
||||
if (_inventorySystem.TryGetSlotEntity(uid, "id", out var idUid) &&
|
||||
_idCard.TryGetIdCard(idUid.Value, out var idCard))
|
||||
name = idCard.Comp.FullName;
|
||||
else
|
||||
return SecurityStatus.None;
|
||||
}
|
||||
|
||||
var serverList = _entManager.EntityQuery<CriminalRecordsServerComponent>();
|
||||
foreach (var server in serverList)
|
||||
if (name == null)
|
||||
return SecurityStatus.None;
|
||||
|
||||
var query = EntityQuery<CriminalStatusDataComponent>();
|
||||
foreach (var data in query)
|
||||
{
|
||||
// if all good - check avaible records
|
||||
foreach (var (key, info) in server.Cache)
|
||||
{
|
||||
// Check id
|
||||
if (_inventorySystem.TryGetSlotEntity(uid, "id", out var idUid))
|
||||
{
|
||||
// PDA
|
||||
if (_entManager.TryGetComponent(idUid, out PdaComponent? pda) &&
|
||||
_entManager.TryGetComponent(pda.ContainedId, out IdCardComponent? idCard))
|
||||
{
|
||||
if (idCard.FullName == info.StationRecord.Name &&
|
||||
idCard.JobTitle == info.StationRecord.JobTitle)
|
||||
{
|
||||
type = info.CriminalType;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// ID Card
|
||||
if (_entManager.TryGetComponent(idUid, out IdCardComponent? id))
|
||||
{
|
||||
idCard = id;
|
||||
if (idCard.FullName == info.StationRecord.Name &&
|
||||
idCard.JobTitle == info.StationRecord.JobTitle)
|
||||
{
|
||||
type = info.CriminalType;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check DNA (Dirty Nanotrasen tehnology lol)
|
||||
// And yeah, he can't check - is pulled mask or not
|
||||
// it's only Content.Server logic, idk hot it impl to Content.Client
|
||||
if (_parentSystem.CanIdentityName(uid) != meta.EntityName)
|
||||
continue;
|
||||
if (meta.EntityName != info.StationRecord.Name)
|
||||
continue;
|
||||
type = info.CriminalType;
|
||||
return true;
|
||||
}
|
||||
if (data.Statuses.TryGetValue(name, out var status))
|
||||
return status;
|
||||
}
|
||||
|
||||
type = EnumCriminalRecordType.Released;
|
||||
return false;
|
||||
return SecurityStatus.None;
|
||||
}
|
||||
// WD EDIT END
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ using Content.Shared.StationRecords;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Player;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Shared._Miracle.Components;
|
||||
|
||||
namespace Content.Server.CriminalRecords.Systems;
|
||||
|
||||
@@ -67,7 +68,7 @@ public sealed class CriminalRecordsConsoleSystem : EntitySystem
|
||||
private void OnChangeStatus(Entity<CriminalRecordsConsoleComponent> ent, ref CriminalRecordChangeStatus msg)
|
||||
{
|
||||
// prevent malf client violating wanted/reason nullability
|
||||
if ((msg.Status == SecurityStatus.Wanted) != (msg.Reason != null))
|
||||
if ((msg.Status is SecurityStatus.Wanted or SecurityStatus.Suspected) != (msg.Reason != null)) // WD EDIT
|
||||
return;
|
||||
|
||||
if (!CheckSelected(ent, msg.Session, out var mob, out var key))
|
||||
@@ -121,11 +122,31 @@ public sealed class CriminalRecordsConsoleSystem : EntitySystem
|
||||
(_, SecurityStatus.None) => "not-wanted",
|
||||
// going from none or detained, AOS or prisonbreak / lazy secoff never set them to released and they reoffended
|
||||
(_, SecurityStatus.Wanted) => "wanted",
|
||||
// WD EDIT START
|
||||
(_, SecurityStatus.Released) => "released",
|
||||
(_, SecurityStatus.Suspected) => "suspected",
|
||||
// WD EDIT END
|
||||
// this is impossible
|
||||
_ => "not-wanted"
|
||||
};
|
||||
_radio.SendRadioMessage(ent, Loc.GetString($"criminal-records-console-{statusString}", args), ent.Comp.SecurityChannel, ent);
|
||||
|
||||
// WD EDIT START
|
||||
if (_stationRecords.TryGetRecord<GeneralStationRecord>(key.Value, out var rec))
|
||||
{
|
||||
var query = EntityQueryEnumerator<CriminalStatusDataComponent>();
|
||||
if (!query.MoveNext(out var entity, out var criminalData))
|
||||
{
|
||||
entity = Spawn(null, Transform(ent).Coordinates);
|
||||
criminalData = EnsureComp<CriminalStatusDataComponent>(entity);
|
||||
}
|
||||
criminalData.Statuses[rec.Name] = msg.Status;
|
||||
criminalData.Statuses[rec.ClownName] = msg.Status;
|
||||
criminalData.Statuses[rec.MimeName] = msg.Status;
|
||||
Dirty(entity, criminalData);
|
||||
}
|
||||
// WD EDIT END
|
||||
|
||||
UpdateUserInterface(ent);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
public enum SecurityStatus : byte
|
||||
{
|
||||
None,
|
||||
Released, // WD EDIT
|
||||
Suspected, // WD EDIT
|
||||
Wanted,
|
||||
Detained
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
using Content.Shared.Security;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared._Miracle.Components;
|
||||
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
public sealed partial class CriminalStatusDataComponent : Component
|
||||
{
|
||||
[AutoNetworkedField, ViewVariables]
|
||||
public Dictionary<string, SecurityStatus> Statuses = new();
|
||||
}
|
||||
@@ -11,6 +11,9 @@ criminal-records-status-none = None
|
||||
criminal-records-status-wanted = Wanted
|
||||
criminal-records-status-detained = Detained
|
||||
|
||||
criminal-records-status-suspected = Suspected
|
||||
criminal-records-status-released = Released
|
||||
|
||||
criminal-records-console-wanted-reason = [color=gray]Wanted Reason[/color]
|
||||
criminal-records-console-reason = Reason
|
||||
criminal-records-console-reason-placeholder = For example: {$placeholder}
|
||||
@@ -32,6 +35,8 @@ criminal-records-console-detained = {$name} has been detained by {$officer}.
|
||||
criminal-records-console-released = {$name} has been released by {$officer}.
|
||||
criminal-records-console-not-wanted = {$name} is no longer wanted.
|
||||
|
||||
criminal-records-console-suspected = {$name} is suspected by {$officer} for: {$reason}.
|
||||
|
||||
## Filters
|
||||
|
||||
criminal-records-filter-placeholder = Input text and press "Enter"
|
||||
|
||||
Reference in New Issue
Block a user