Move ChatSystem.Emotes to shared (#40866)
* move to shared * entity effect to shared * refactor: whitespaces+xml-doc typo fixups * refactor: a little bit more of xml-doc typos fixups --------- Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
This commit is contained in:
41
Content.Shared/Speech/EntitySystems/EmoteBlockerSystem.cs
Normal file
41
Content.Shared/Speech/EntitySystems/EmoteBlockerSystem.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Speech.Components;
|
||||
|
||||
namespace Content.Shared.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