From 1e6981b97721940cf9e0dca19fc499c58127e6ed Mon Sep 17 00:00:00 2001 From: MiraHell <42539014+MiraHell@users.noreply.github.com> Date: Thu, 6 Jun 2024 20:22:59 +0300 Subject: [PATCH 1/2] off system --- .../Overlays/ShowCriminalRecordIconsSystem.cs | 62 ++----------------- .../Machines/Computers/computers.yml | 54 +++++----------- Resources/Prototypes/Guidebook/security.yml | 2 +- 3 files changed, 21 insertions(+), 97 deletions(-) diff --git a/Content.Client/Overlays/ShowCriminalRecordIconsSystem.cs b/Content.Client/Overlays/ShowCriminalRecordIconsSystem.cs index 3d27ee096caa..c353b1727295 100644 --- a/Content.Client/Overlays/ShowCriminalRecordIconsSystem.cs +++ b/Content.Client/Overlays/ShowCriminalRecordIconsSystem.cs @@ -1,10 +1,5 @@ -using Content.Shared.Access.Components; -using Content.Shared.Access.Systems; -using Content.Shared.IdentityManagement.Components; using Content.Shared.Overlays; -using Content.Shared.PDA; using Content.Shared.Security.Components; -using Content.Shared.SS220.CriminalRecords; using Content.Shared.StatusIcon; using Content.Shared.StatusIcon.Components; using Robust.Shared.Prototypes; @@ -14,67 +9,20 @@ namespace Content.Client.Overlays; public sealed class ShowCriminalRecordIconsSystem : EquipmentHudSystem { [Dependency] private readonly IPrototypeManager _prototype = default!; - [Dependency] private readonly AccessReaderSystem _accessReader = default!; - [Dependency] private readonly IPrototypeManager _prototypeMan = default!; public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnGetStatusIconsEvent); // 220 secincons fix + SubscribeLocalEvent(OnGetStatusIconsEvent); } - private void OnGetStatusIconsEvent(EntityUid uid, IdentityComponent _, ref GetStatusIconsEvent ev) // 220 secincons fix + private void OnGetStatusIconsEvent(EntityUid uid, CriminalRecordComponent component, ref GetStatusIconsEvent ev) { - if (!IsActive || ev.InContainer) + if (!IsActive) return; - //SS220 Criminal-Records begin - - // WizDen code, no longer needed - // if (_prototype.TryIndex(component.StatusIcon.Id, out var iconPrototype)) - // ev.StatusIcons.Add(iconPrototype); - - string? securityRecordType = null; - if (_accessReader.FindAccessItemsInventory(uid, out var items)) - { - foreach (var item in items) - { - // ID Card - if (TryComp(item, out IdCardComponent? id)) - { - securityRecordType = id.CurrentSecurityRecord?.RecordType; //SS220 Criminal-Records - break; - } - - // PDA - if (TryComp(item, out PdaComponent? pda) - && pda.ContainedId != null - && TryComp(pda.ContainedId, out id)) - { - securityRecordType = id.CurrentSecurityRecord?.RecordType; //SS220 Criminal-Records - break; - } - } - } - - if (securityRecordType != null) - { - if (_prototypeMan.TryIndex(securityRecordType, out var criminalStatus)) - { - if (criminalStatus.StatusIcon.HasValue) - { - if (_prototypeMan.TryIndex(criminalStatus.StatusIcon, out var secIcon)) - ev.StatusIcons.Add(secIcon); - else - Log.Error($"Invalid security status icon prototype: {secIcon}"); - } - } - else - { - Log.Error($"Invalid security status prototype: {criminalStatus}"); - } - } - //SS220 Criminal-Records end + if (_prototype.TryIndex(component.StatusIcon, out var iconPrototype)) + ev.StatusIcons.Add(iconPrototype); } } diff --git a/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml b/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml index ba42cf1d8579..14c68b202798 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml @@ -303,13 +303,13 @@ name: criminal records computer description: This can be used to check criminal records. Only security can modify them. components: - # - type: CriminalRecordsConsole #SS220 Criminal-Records (remove comp) - # - type: UserInterface - # interfaces: - # enum.CriminalRecordsConsoleKey.Key: - # type: CriminalRecordsConsoleBoundUserInterface - # - type: ActivatableUI - # key: enum.CriminalRecordsConsoleKey.Key + - type: CriminalRecordsConsole + - type: UserInterface + interfaces: + enum.CriminalRecordsConsoleKey.Key: + type: CriminalRecordsConsoleBoundUserInterface + - type: ActivatableUI + key: enum.CriminalRecordsConsoleKey.Key - type: Sprite layers: - map: ["computerLayerBody"] @@ -324,27 +324,13 @@ radius: 1.5 energy: 1.6 color: "#1f8c28" - #SS220 Criminal-Records begin + - type: Computer + board: CriminalRecordsComputerCircuitboard - type: AccessReader - access: [ [ "Brig" ] ] #So IAA can have access too - - type: CriminalRecordsConsole220 - - type: UserInterface - interfaces: - enum.CriminalRecordsUiKey.Key: - type: CriminalRecordsBoundUserInterface - - type: ActivatableUI - key: enum.CriminalRecordsUiKey.Key + access: [["Security"]] - type: GuideHelp guides: - - Forensics - #SS220 Criminal-Records end - - type: Computer - board: CriminalRecordsComputerCircuitboard - # - type: AccessReader - # access: [["Security"]] - # - type: GuideHelp - # guides: - # - CriminalRecords + - CriminalRecords - type: entity parent: BaseComputer @@ -352,23 +338,13 @@ name: station records computer description: This can be used to check station records. components: - #SS220 Criminal-Records begin - # - type: GeneralStationRecordConsole - - type: CriminalRecordsConsole220 - isSecurity: false + - type: GeneralStationRecordConsole - type: UserInterface interfaces: - enum.CriminalRecordsUiKey.Key: - type: CriminalRecordsBoundUserInterface + enum.GeneralStationRecordConsoleKey.Key: + type: GeneralStationRecordConsoleBoundUserInterface - type: ActivatableUI - key: enum.CriminalRecordsUiKey.Key - # - type: UserInterface - # interfaces: - # enum.GeneralStationRecordConsoleKey.Key: - # type: GeneralStationRecordConsoleBoundUserInterface - # - type: ActivatableUI - # key: enum.GeneralStationRecordConsoleKey.Key - #SS220 Criminal-Records end + key: enum.GeneralStationRecordConsoleKey.Key - type: PointLight radius: 1.5 energy: 1.6 diff --git a/Resources/Prototypes/Guidebook/security.yml b/Resources/Prototypes/Guidebook/security.yml index 8a4f8e796a55..f5e347082836 100644 --- a/Resources/Prototypes/Guidebook/security.yml +++ b/Resources/Prototypes/Guidebook/security.yml @@ -5,7 +5,7 @@ children: - Forensics - Defusal - # - CriminalRecords SS220 Criminal-Records - remove official guidebook + - CriminalRecords - type: guideEntry id: Forensics From 53d3097349edcf55ae67de91eeee8013dd8bb6ac Mon Sep 17 00:00:00 2001 From: MiraHell <42539014+MiraHell@users.noreply.github.com> Date: Sat, 8 Jun 2024 01:29:40 +0300 Subject: [PATCH 2/2] reason examine --- .../Overlays/ShowCriminalRecordIconsSystem.cs | 11 ++ .../Systems/CriminalRecordsConsoleSystem.cs | 1 + .../Systems/CriminalRecordsSystem.cs | 3 +- .../CriminalRecords/CriminalRecordSystem.cs | 132 +++++++++--------- .../Systems/SharedCriminalRecordsSystem.cs | 17 ++- .../Components/CriminalRecordComponent.cs | 5 + 6 files changed, 101 insertions(+), 68 deletions(-) diff --git a/Content.Client/Overlays/ShowCriminalRecordIconsSystem.cs b/Content.Client/Overlays/ShowCriminalRecordIconsSystem.cs index c353b1727295..9ba8281ba22b 100644 --- a/Content.Client/Overlays/ShowCriminalRecordIconsSystem.cs +++ b/Content.Client/Overlays/ShowCriminalRecordIconsSystem.cs @@ -3,6 +3,7 @@ using Content.Shared.StatusIcon; using Content.Shared.StatusIcon.Components; using Robust.Shared.Prototypes; +using Content.Shared.Examine; namespace Content.Client.Overlays; @@ -15,6 +16,7 @@ public override void Initialize() base.Initialize(); SubscribeLocalEvent(OnGetStatusIconsEvent); + SubscribeLocalEvent(OnStatusExamine); } private void OnGetStatusIconsEvent(EntityUid uid, CriminalRecordComponent component, ref GetStatusIconsEvent ev) @@ -25,4 +27,13 @@ private void OnGetStatusIconsEvent(EntityUid uid, CriminalRecordComponent compon if (_prototype.TryIndex(component.StatusIcon, out var iconPrototype)) ev.StatusIcons.Add(iconPrototype); } + // Start 220 CriminalRecords + private void OnStatusExamine(Entity ent, ref ExaminedEvent args) + { + if (!IsActive) + return; + + args.PushMarkup($"[color=#FF0000][bold]Причина: {ent.Comp.Reason}[/bold][/color]"); + } + // End 220 CriminalRecords } diff --git a/Content.Server/CriminalRecords/Systems/CriminalRecordsConsoleSystem.cs b/Content.Server/CriminalRecords/Systems/CriminalRecordsConsoleSystem.cs index bbd402b9fad1..d31719961305 100644 --- a/Content.Server/CriminalRecords/Systems/CriminalRecordsConsoleSystem.cs +++ b/Content.Server/CriminalRecords/Systems/CriminalRecordsConsoleSystem.cs @@ -251,6 +251,7 @@ public void CheckNewIdentity(EntityUid uid) if (record.Status != SecurityStatus.None) { _criminalRecords.SetCriminalIcon(name, record.Status, uid); + _criminalRecords.SetCriminalReason(name, record.Reason, uid); // 220 CriminalRecords return; } } diff --git a/Content.Server/CriminalRecords/Systems/CriminalRecordsSystem.cs b/Content.Server/CriminalRecords/Systems/CriminalRecordsSystem.cs index a65fb0be9e1a..6e6e2cc029a2 100644 --- a/Content.Server/CriminalRecords/Systems/CriminalRecordsSystem.cs +++ b/Content.Server/CriminalRecords/Systems/CriminalRecordsSystem.cs @@ -61,7 +61,8 @@ public void OverwriteStatus(StationRecordKey key, CriminalRecord record, Securit var name = _records.RecordName(key); if (name != string.Empty) - UpdateCriminalIdentity(name, status); + // UpdateCriminalIdentity(name, status); + UpdateCriminalIdentity(name, status, reason); // 220 CriminalRecords _records.Synchronize(key); } diff --git a/Content.Server/SS220/CriminalRecords/CriminalRecordSystem.cs b/Content.Server/SS220/CriminalRecords/CriminalRecordSystem.cs index 9db0876f54fc..246819b638a9 100644 --- a/Content.Server/SS220/CriminalRecords/CriminalRecordSystem.cs +++ b/Content.Server/SS220/CriminalRecords/CriminalRecordSystem.cs @@ -33,77 +33,77 @@ public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnStatusExamine); + // SubscribeLocalEvent(OnStatusExamine); } // TheArturZh 25.09.2023 22:15 // TODO: bad code. make it use InventoryRelayedEvent. Create separate components for examining and for examined subscription. // no pohuy prosto zaebalsya( - private void OnStatusExamine(EntityUid uid, StatusIconComponent comp, ExaminedEvent args) - { - var scannerOn = false; - if (_inventory.TryGetSlotEntity(args.Examiner, "eyes", out var ent)) - { - if (HasComp(ent)) - { - scannerOn = true; - } - } - - if (!scannerOn) - return; - - CriminalRecord? record = null; - - if (_accessReader.FindAccessItemsInventory(uid, out var items)) - { - foreach (var item in items) - { - // ID Card - if (TryComp(item, out IdCardComponent? id)) - { - if (id.CurrentSecurityRecord != null) - { - record = id.CurrentSecurityRecord; - break; - } - } - - // PDA - if (TryComp(item, out PdaComponent? pda) - && pda.ContainedId != null - && TryComp(pda.ContainedId, out id)) - { - if (id.CurrentSecurityRecord != null) - { - record = id.CurrentSecurityRecord; - break; - } - } - } - } - - //SS220 Criminal-Records begin - if (record != null) - { - var msg = new FormattedMessage(); - - if (record.RecordType == null) - { - msg.AddMarkup("[bold]Без статуса: [/bold]"); - } - else - { - if (_prototype.TryIndex(record.RecordType, out var statusType)) - { - msg.AddMarkup($"[color={statusType.Color.ToHex()}][bold]{statusType.Name}:[/bold][/color] "); - } - } - - msg.AddText(record.Message); - args.PushMessage(msg); - } - } + // private void OnStatusExamine(EntityUid uid, StatusIconComponent comp, ExaminedEvent args) + // { + // var scannerOn = false; + // if (_inventory.TryGetSlotEntity(args.Examiner, "eyes", out var ent)) + // { + // if (HasComp(ent)) + // { + // scannerOn = true; + // } + // } + + // if (!scannerOn) + // return; + + // CriminalRecord? record = null; + + // if (_accessReader.FindAccessItemsInventory(uid, out var items)) + // { + // foreach (var item in items) + // { + // // ID Card + // if (TryComp(item, out IdCardComponent? id)) + // { + // if (id.CurrentSecurityRecord != null) + // { + // record = id.CurrentSecurityRecord; + // break; + // } + // } + + // // PDA + // if (TryComp(item, out PdaComponent? pda) + // && pda.ContainedId != null + // && TryComp(pda.ContainedId, out id)) + // { + // if (id.CurrentSecurityRecord != null) + // { + // record = id.CurrentSecurityRecord; + // break; + // } + // } + // } + // } + + // //SS220 Criminal-Records begin + // if (record != null) + // { + // var msg = new FormattedMessage(); + + // if (record.RecordType == null) + // { + // msg.AddMarkup("[bold]Без статуса: [/bold]"); + // } + // else + // { + // if (_prototype.TryIndex(record.RecordType, out var statusType)) + // { + // msg.AddMarkup($"[color={statusType.Color.ToHex()}][bold]{statusType.Name}:[/bold][/color] "); + // } + // } + + // msg.AddText(record.Message); + // args.PushMessage(msg); + // } + // } public CriminalRecordCatalog EnsureRecordCatalog(GeneralStationRecord record) { diff --git a/Content.Shared/CriminalRecords/Systems/SharedCriminalRecordsSystem.cs b/Content.Shared/CriminalRecords/Systems/SharedCriminalRecordsSystem.cs index 96b33ab91bd3..f924dda1d283 100644 --- a/Content.Shared/CriminalRecords/Systems/SharedCriminalRecordsSystem.cs +++ b/Content.Shared/CriminalRecords/Systems/SharedCriminalRecordsSystem.cs @@ -11,7 +11,8 @@ public abstract class SharedCriminalRecordsSystem : EntitySystem /// Any entity that has a the name of the record that was just changed as their visible name will get their icon /// updated with the new status, if the record got removed their icon will be removed too. /// - public void UpdateCriminalIdentity(string name, SecurityStatus status) + // public void UpdateCriminalIdentity(string name, SecurityStatus status) + public void UpdateCriminalIdentity(string name, SecurityStatus status, string? reason) // 220 CriminalRecords { var query = EntityQueryEnumerator(); @@ -23,7 +24,12 @@ public void UpdateCriminalIdentity(string name, SecurityStatus status) if (status == SecurityStatus.None) RemComp(uid); else + // Start 220 CriminalRecords + { SetCriminalIcon(name, status, uid); + SetCriminalReason(name, reason, uid); + } + // End 220 CriminalRecords } } @@ -49,4 +55,13 @@ public void SetCriminalIcon(string name, SecurityStatus status, EntityUid charac if (previousIcon != record.StatusIcon) Dirty(characterUid, record); } + + public void SetCriminalReason(string name, string? reason, EntityUid characterUid) + { + if (TryComp(characterUid, out var record)) + { + if (reason != null) + record.Reason = reason; + } + } } diff --git a/Content.Shared/Security/Components/CriminalRecordComponent.cs b/Content.Shared/Security/Components/CriminalRecordComponent.cs index 25fab3f1350f..167d206c41c0 100644 --- a/Content.Shared/Security/Components/CriminalRecordComponent.cs +++ b/Content.Shared/Security/Components/CriminalRecordComponent.cs @@ -1,6 +1,7 @@ using Content.Shared.StatusIcon; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; +using Content.Shared.CriminalRecords; namespace Content.Shared.Security.Components; @@ -12,4 +13,8 @@ public sealed partial class CriminalRecordComponent : Component /// [DataField, AutoNetworkedField] public ProtoId StatusIcon = "SecurityIconWanted"; + // 220 Criminal Records + [DataField, AutoNetworkedField] + public string Reason = "Не указана"; + // 220 Criminal Records }