Component for clothes to suppress emotes and scream action in general, and the muzzle to suppress vocal emotes in particular (#32588)
* Component for clothes to suppress scream noise GaggedComponent + AddGaggedClothingComponent and relevant systems to make them work. Currently only stifles the scream _action_, not all emotes because if a mime can silently emote, so can gagged you! * fix comments * swap to inventory relay and make it more general such that specific emotes or emotes of a given category can be blocked * power gloves shouldn't block snapping * easy fixes * blockable emote event * pr comments, switch to using emote event mostly * pr comments add beforeEmoteEvent add emote blocker name to popup maybe some other stuff, I forget * get rid of emoteevent's source because I don't need it anymore * smol clean * formatting, style, and one minor thing where having a muzzle in your pocket would gag you
This commit is contained in:
41
Content.Server/Speech/EntitySystems/EmoteBlockerSystem.cs
Normal file
41
Content.Server/Speech/EntitySystems/EmoteBlockerSystem.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Emoting;
|
||||
using Content.Shared.Inventory;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems;
|
||||
|
||||
public sealed class EmoteBlockerSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<EmoteBlockerComponent, BeforeEmoteEvent>(OnEmoteEvent);
|
||||
SubscribeLocalEvent<EmoteBlockerComponent, InventoryRelayedEvent<BeforeEmoteEvent>>(OnRelayedEmoteEvent);
|
||||
}
|
||||
|
||||
private static void OnRelayedEmoteEvent(Entity<EmoteBlockerComponent> entity, ref InventoryRelayedEvent<BeforeEmoteEvent> args)
|
||||
{
|
||||
OnEmoteEvent(entity, ref args.Args);
|
||||
}
|
||||
|
||||
private static void OnEmoteEvent(Entity<EmoteBlockerComponent> entity, ref BeforeEmoteEvent args)
|
||||
{
|
||||
if (entity.Comp.BlocksEmotes.Contains(args.Emote))
|
||||
{
|
||||
args.Cancel();
|
||||
args.Blocker = entity;
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var blockedCat in entity.Comp.BlocksCategories)
|
||||
{
|
||||
if (blockedCat == args.Emote.Category)
|
||||
{
|
||||
args.Cancel();
|
||||
args.Blocker = entity;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user