Muzzles reduce emote sound (#34444)

* Muzzles reduce emote sound

* update based on review comments

* review comments
This commit is contained in:
themias
2025-06-05 19:45:55 -04:00
committed by GitHub
parent 7943dad603
commit eb85a8a1b0
4 changed files with 34 additions and 9 deletions

View File

@@ -1,9 +1,13 @@
using Content.Server.Chat.Systems;
using Content.Server.Speech.Components;
using Content.Shared.Chat.Prototypes;
using Content.Shared.Speech.Components;
namespace Content.Server.Speech.EntitySystems;
public sealed class MumbleAccentSystem : EntitySystem
{
[Dependency] private readonly ChatSystem _chat = default!;
[Dependency] private readonly ReplacementAccentSystem _replacement = default!;
public override void Initialize()
@@ -11,6 +15,19 @@ public sealed class MumbleAccentSystem : EntitySystem
base.Initialize();
SubscribeLocalEvent<MumbleAccentComponent, AccentGetEvent>(OnAccentGet);
SubscribeLocalEvent<MumbleAccentComponent, EmoteEvent>(OnEmote, before: [typeof(VocalSystem)]);
}
private void OnEmote(Entity<MumbleAccentComponent> ent, ref EmoteEvent args)
{
if (args.Handled || !args.Emote.Category.HasFlag(EmoteCategory.Vocal))
return;
if (TryComp<VocalComponent>(ent.Owner, out var vocalComp))
{
// play a muffled version of the vocal emote
args.Handled = _chat.TryPlayEmoteSound(ent.Owner, vocalComp.EmoteSounds, args.Emote, ent.Comp.EmoteAudioParams);
}
}
public string Accentuate(string message, MumbleAccentComponent component)
@@ -18,8 +35,8 @@ public sealed class MumbleAccentSystem : EntitySystem
return _replacement.ApplyReplacements(message, "mumble");
}
private void OnAccentGet(EntityUid uid, MumbleAccentComponent component, AccentGetEvent args)
private void OnAccentGet(Entity<MumbleAccentComponent> ent, ref AccentGetEvent args)
{
args.Message = Accentuate(args.Message, component);
args.Message = Accentuate(args.Message, ent.Comp);
}
}