Files
tbd-station-14/Content.Server/Emoting/Systems/BodyEmotesSystem.cs
slarticodefast ee9d1032bb 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>
2025-10-13 18:06:01 +00:00

46 lines
1.3 KiB
C#

using Content.Server.Chat.Systems;
using Content.Server.Emoting.Components;
using Content.Shared.Chat;
using Content.Shared.Chat.Prototypes;
using Content.Shared.Hands.Components;
using Robust.Shared.Prototypes;
namespace Content.Server.Emoting.Systems;
public sealed class BodyEmotesSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly ChatSystem _chat = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<BodyEmotesComponent, EmoteEvent>(OnEmote);
}
private void OnEmote(EntityUid uid, BodyEmotesComponent component, ref EmoteEvent args)
{
if (args.Handled)
return;
var cat = args.Emote.Category;
if (cat.HasFlag(EmoteCategory.Hands))
{
args.Handled = TryEmoteHands(uid, args.Emote, component);
}
}
private bool TryEmoteHands(EntityUid uid, EmotePrototype emote, BodyEmotesComponent component)
{
// check that user actually has hands to do emote sound
if (!TryComp(uid, out HandsComponent? hands) || hands.Count <= 0)
return false;
if (!_proto.Resolve(component.SoundsId, out var sounds))
return false;
return _chat.TryPlayEmoteSound(uid, sounds, emote);
}
}