Add voice locks to various hidden syndicate items (#39310)

This commit is contained in:
beck-thompson
2025-08-10 11:10:13 -07:00
committed by GitHub
parent 80299e863a
commit 80375370f8
36 changed files with 366 additions and 97 deletions

View File

@@ -5,11 +5,13 @@ using Content.Shared.Chat;
using Content.Shared.Clothing;
using Content.Shared.Database;
using Content.Shared.Inventory;
using Content.Shared.Lock;
using Content.Shared.Popups;
using Content.Shared.Preferences;
using Content.Shared.Speech;
using Content.Shared.VoiceMask;
using Robust.Shared.Configuration;
using Robust.Shared.Containers;
using Robust.Shared.Prototypes;
namespace Content.Server.VoiceMask;
@@ -22,6 +24,8 @@ public sealed partial class VoiceMaskSystem : EntitySystem
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly LockSystem _lock = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
// CCVar.
private int _maxNameLength;
@@ -30,6 +34,7 @@ public sealed partial class VoiceMaskSystem : EntitySystem
{
base.Initialize();
SubscribeLocalEvent<VoiceMaskComponent, InventoryRelayedEvent<TransformSpeakerNameEvent>>(OnTransformSpeakerName);
SubscribeLocalEvent<VoiceMaskComponent, LockToggledEvent>(OnLockToggled);
SubscribeLocalEvent<VoiceMaskComponent, VoiceMaskChangeNameMessage>(OnChangeName);
SubscribeLocalEvent<VoiceMaskComponent, VoiceMaskChangeVerbMessage>(OnChangeVerb);
SubscribeLocalEvent<VoiceMaskComponent, ClothingGotEquippedEvent>(OnEquip);
@@ -44,6 +49,14 @@ public sealed partial class VoiceMaskSystem : EntitySystem
args.Args.SpeechVerb = entity.Comp.VoiceMaskSpeechVerb ?? args.Args.SpeechVerb;
}
private void OnLockToggled(Entity<VoiceMaskComponent> ent, ref LockToggledEvent args)
{
if (args.Locked)
_actions.RemoveAction(ent.Comp.ActionEntity);
else if (_container.TryGetContainingContainer(ent.Owner, out var container))
_actions.AddAction(container.Owner, ref ent.Comp.ActionEntity, ent.Comp.Action, ent);
}
#region User inputs from UI
private void OnChangeVerb(Entity<VoiceMaskComponent> entity, ref VoiceMaskChangeVerbMessage msg)
{
@@ -78,6 +91,9 @@ public sealed partial class VoiceMaskSystem : EntitySystem
#region UI
private void OnEquip(EntityUid uid, VoiceMaskComponent component, ClothingGotEquippedEvent args)
{
if (_lock.IsLocked(uid))
return;
_actions.AddAction(args.Wearer, ref component.ActionEntity, component.Action, uid);
}