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 <beck314159@hotmail.com>
This commit is contained in:
Leah
2026-02-13 22:42:16 +01:00
committed by GitHub
parent e16ae0e76c
commit 0e86bd45bd
6 changed files with 34 additions and 5 deletions

View File

@@ -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<AgentIDCardComponent, AgentIDCardJobChangedMessage>(OnJobChanged);
SubscribeLocalEvent<AgentIDCardComponent, AgentIDCardJobIconChangedMessage>(OnJobIconChanged);
SubscribeLocalEvent<AgentIDCardComponent, InventoryRelayedEvent<ChameleonControllerOutfitSelectedEvent>>(OnChameleonControllerOutfitChangedItem);
SubscribeLocalEvent<AgentIDCardComponent, InventoryRelayedEvent<VoiceMaskNameUpdatedEvent>>(OnVoiceMaskNameChanged);
}
private void OnChameleonControllerOutfitChangedItem(Entity<AgentIDCardComponent> ent, ref InventoryRelayedEvent<ChameleonControllerOutfitSelectedEvent> args)
@@ -80,6 +83,17 @@ namespace Content.Server.Access.Systems
_chameleon.SetSelectedPrototype(ent, comp.IdCard);
}
private void OnVoiceMaskNameChanged(Entity<AgentIDCardComponent> ent, ref InventoryRelayedEvent<VoiceMaskNameUpdatedEvent> args)
{
if (!TryComp<IdCardComponent>(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) ||

View File

@@ -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<StationRenamedEvent>(OnStationRenamed);
SubscribeLocalEvent<EntityRenamedEvent>(OnEntityRenamed, after: new[] { typeof(IdCardSystem) });
SubscribeLocalEvent<AlertLevelChangedEvent>(OnAlertLevelChanged);
SubscribeLocalEvent<PdaComponent, InventoryRelayedEvent<ChameleonControllerOutfitSelectedEvent>>(ChameleonControllerOutfitItemSelected);
SubscribeLocalEvent<PdaComponent, InventoryRelayedEvent<ChameleonControllerOutfitSelectedEvent>>(OnRelayedEventToIdCard);
SubscribeLocalEvent<PdaComponent, InventoryRelayedEvent<VoiceMaskNameUpdatedEvent>>(OnRelayedEventToIdCard);
}
private void ChameleonControllerOutfitItemSelected(Entity<PdaComponent> ent, ref InventoryRelayedEvent<ChameleonControllerOutfitSelectedEvent> args)
private void OnRelayedEventToIdCard<T>(Entity<PdaComponent> ent, ref InventoryRelayedEvent<T> args)
{
// Relay it to your ID so it can update as well.
if (ent.Comp.ContainedId != null)

View File

@@ -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<InventoryComponent, IsEquippingTargetAttemptEvent>(RelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, IsUnequippingTargetAttemptEvent>(RelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, ChameleonControllerOutfitSelectedEvent>(RelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, VoiceMaskNameUpdatedEvent>(RelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, BeforeEmoteEvent>(RelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, StoodEvent>(RelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, DownedEvent>(RelayInventoryEvent);

View File

@@ -1,7 +1,7 @@
using Content.Shared.Speech;
using Robust.Shared.Prototypes;
namespace Content.Server.VoiceMask;
namespace Content.Shared.VoiceMask;
/// <summary>
/// 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
/// </summary>
[DataField]
public bool AccentHide = true;
/// <summary>
/// If user's equipped agent id name is getting changed.
/// </summary>
[DataField]
public bool ChangeIDName = false;
}

View File

@@ -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
/// <summary>
/// Raised on an entity when their voice masks name is updated
/// </summary>
/// <param name="VoiceMaskUid">Uid of the voice mask</param>
/// <param name="VoiceMask">VoiceMask component</param>
/// <param name="OldName">The old name</param>
/// <param name="NewName">The new name</param>
[ByRefEvent]
public readonly record struct VoiceMaskNameUpdatedEvent(EntityUid VoiceMaskUid, string? OldName, string NewName);
public readonly record struct VoiceMaskNameUpdatedEvent(Entity<VoiceMaskComponent> VoiceMask, string? OldName, string NewName) : IInventoryRelayEvent
{
SlotFlags IInventoryRelayEvent.TargetSlots => SlotFlags.WITHOUT_POCKET;
}

View File

@@ -250,6 +250,7 @@
implantAction: ActionChangeVoiceMaskImplant
- type: VoiceMask
overrideIdentity: true
changeIDName: true
- type: UserInterface
interfaces:
enum.VoiceMaskUIKey.Key: