From 0e86bd45bd422e910b0ed134488ba0fa85782418 Mon Sep 17 00:00:00 2001 From: Leah Date: Fri, 13 Feb 2026 22:42:16 +0100 Subject: [PATCH] Identity Mask now updates equipped Agent ID name (#42772) * add identity mask updating agent id functionality * fix indentation * add check for voice mask item * use ChangeIDName field instead * Minor cleanup * remove trycomp --------- Co-authored-by: beck-thompson --- Content.Server/Access/Systems/AgentIDCardSystem.cs | 14 ++++++++++++++ Content.Server/PDA/PdaSystem.cs | 6 ++++-- Content.Shared/Inventory/InventorySystem.Relay.cs | 2 ++ .../VoiceMask/VoiceMaskComponent.cs | 8 +++++++- Content.Shared/VoiceMask/VoiceMaskSetNameEvent.cs | 8 ++++++-- .../Entities/Objects/Misc/subdermal_implants.yml | 1 + 6 files changed, 34 insertions(+), 5 deletions(-) rename {Content.Server => Content.Shared}/VoiceMask/VoiceMaskComponent.cs (90%) diff --git a/Content.Server/Access/Systems/AgentIDCardSystem.cs b/Content.Server/Access/Systems/AgentIDCardSystem.cs index 1eb050dd2ae..0586c33adae 100644 --- a/Content.Server/Access/Systems/AgentIDCardSystem.cs +++ b/Content.Server/Access/Systems/AgentIDCardSystem.cs @@ -11,10 +11,12 @@ using Content.Shared.Roles; using System.Diagnostics.CodeAnalysis; using Content.Server.Clothing.Systems; using Content.Server.Implants; +using Content.Server.VoiceMask; using Content.Shared.Implants; using Content.Shared.Inventory; using Content.Shared.Lock; using Content.Shared.PDA; +using Content.Shared.VoiceMask; namespace Content.Server.Access.Systems { @@ -39,6 +41,7 @@ namespace Content.Server.Access.Systems SubscribeLocalEvent(OnJobChanged); SubscribeLocalEvent(OnJobIconChanged); SubscribeLocalEvent>(OnChameleonControllerOutfitChangedItem); + SubscribeLocalEvent>(OnVoiceMaskNameChanged); } private void OnChameleonControllerOutfitChangedItem(Entity ent, ref InventoryRelayedEvent args) @@ -80,6 +83,17 @@ namespace Content.Server.Access.Systems _chameleon.SetSelectedPrototype(ent, comp.IdCard); } + private void OnVoiceMaskNameChanged(Entity ent, ref InventoryRelayedEvent args) + { + if (!TryComp(ent, out var idCard)) + return; + + if (!args.Args.VoiceMask.Comp.ChangeIDName) + return; + + _cardSystem.TryChangeFullName(ent, args.Args.NewName, idCard); + } + private void OnAfterInteract(EntityUid uid, AgentIDCardComponent component, AfterInteractEvent args) { if (args.Target == null || !args.CanReach || _lock.IsLocked(uid) || diff --git a/Content.Server/PDA/PdaSystem.cs b/Content.Server/PDA/PdaSystem.cs index 282290e4694..9122c969645 100644 --- a/Content.Server/PDA/PdaSystem.cs +++ b/Content.Server/PDA/PdaSystem.cs @@ -17,6 +17,7 @@ using Content.Shared.Light; using Content.Shared.Light.EntitySystems; using Content.Shared.PDA; using Content.Shared.PDA.Ringer; +using Content.Shared.VoiceMask; using Robust.Server.Containers; using Robust.Server.GameObjects; using Robust.Shared.Containers; @@ -58,10 +59,11 @@ namespace Content.Server.PDA SubscribeLocalEvent(OnStationRenamed); SubscribeLocalEvent(OnEntityRenamed, after: new[] { typeof(IdCardSystem) }); SubscribeLocalEvent(OnAlertLevelChanged); - SubscribeLocalEvent>(ChameleonControllerOutfitItemSelected); + SubscribeLocalEvent>(OnRelayedEventToIdCard); + SubscribeLocalEvent>(OnRelayedEventToIdCard); } - private void ChameleonControllerOutfitItemSelected(Entity ent, ref InventoryRelayedEvent args) + private void OnRelayedEventToIdCard(Entity ent, ref InventoryRelayedEvent args) { // Relay it to your ID so it can update as well. if (ent.Comp.ContainedId != null) diff --git a/Content.Shared/Inventory/InventorySystem.Relay.cs b/Content.Shared/Inventory/InventorySystem.Relay.cs index ce8a6b1f508..8101c19eab5 100644 --- a/Content.Shared/Inventory/InventorySystem.Relay.cs +++ b/Content.Shared/Inventory/InventorySystem.Relay.cs @@ -27,6 +27,7 @@ using Content.Shared.Standing; using Content.Shared.Strip.Components; using Content.Shared.Temperature; using Content.Shared.Verbs; +using Content.Shared.VoiceMask; using Content.Shared.Weapons.Ranged.Events; using Content.Shared.Wieldable; using Content.Shared.Zombies; @@ -57,6 +58,7 @@ public partial class InventorySystem SubscribeLocalEvent(RelayInventoryEvent); SubscribeLocalEvent(RelayInventoryEvent); SubscribeLocalEvent(RelayInventoryEvent); + SubscribeLocalEvent(RelayInventoryEvent); SubscribeLocalEvent(RelayInventoryEvent); SubscribeLocalEvent(RelayInventoryEvent); SubscribeLocalEvent(RelayInventoryEvent); diff --git a/Content.Server/VoiceMask/VoiceMaskComponent.cs b/Content.Shared/VoiceMask/VoiceMaskComponent.cs similarity index 90% rename from Content.Server/VoiceMask/VoiceMaskComponent.cs rename to Content.Shared/VoiceMask/VoiceMaskComponent.cs index 042b78a8591..b53a6150947 100644 --- a/Content.Server/VoiceMask/VoiceMaskComponent.cs +++ b/Content.Shared/VoiceMask/VoiceMaskComponent.cs @@ -1,7 +1,7 @@ using Content.Shared.Speech; using Robust.Shared.Prototypes; -namespace Content.Server.VoiceMask; +namespace Content.Shared.VoiceMask; /// /// This component is for voice mask items! Adding this component to clothing will give the the voice mask UI @@ -55,5 +55,11 @@ public sealed partial class VoiceMaskComponent : Component /// [DataField] public bool AccentHide = true; + + /// + /// If user's equipped agent id name is getting changed. + /// + [DataField] + public bool ChangeIDName = false; } diff --git a/Content.Shared/VoiceMask/VoiceMaskSetNameEvent.cs b/Content.Shared/VoiceMask/VoiceMaskSetNameEvent.cs index caeb8429318..3d03a429d7b 100644 --- a/Content.Shared/VoiceMask/VoiceMaskSetNameEvent.cs +++ b/Content.Shared/VoiceMask/VoiceMaskSetNameEvent.cs @@ -1,4 +1,5 @@ using Content.Shared.Actions; +using Content.Shared.Inventory; namespace Content.Shared.VoiceMask; @@ -9,8 +10,11 @@ public sealed partial class VoiceMaskSetNameEvent : InstantActionEvent /// /// Raised on an entity when their voice masks name is updated /// -/// Uid of the voice mask +/// VoiceMask component /// The old name /// The new name [ByRefEvent] -public readonly record struct VoiceMaskNameUpdatedEvent(EntityUid VoiceMaskUid, string? OldName, string NewName); +public readonly record struct VoiceMaskNameUpdatedEvent(Entity VoiceMask, string? OldName, string NewName) : IInventoryRelayEvent +{ + SlotFlags IInventoryRelayEvent.TargetSlots => SlotFlags.WITHOUT_POCKET; +} diff --git a/Resources/Prototypes/Entities/Objects/Misc/subdermal_implants.yml b/Resources/Prototypes/Entities/Objects/Misc/subdermal_implants.yml index 98c1857b76b..8e29fdd88f8 100644 --- a/Resources/Prototypes/Entities/Objects/Misc/subdermal_implants.yml +++ b/Resources/Prototypes/Entities/Objects/Misc/subdermal_implants.yml @@ -250,6 +250,7 @@ implantAction: ActionChangeVoiceMaskImplant - type: VoiceMask overrideIdentity: true + changeIDName: true - type: UserInterface interfaces: enum.VoiceMaskUIKey.Key: