CatStation/Content.Server/Emoting/Systems/BodyEmotesSystem.cs
Whatstone f42f8df6d1
Cleanup: ProtoMan Part 2 - remove Client and Server EntitySystem IPrototypeManager instances (#44416)
* Remove all IPrototypeManager instances

* Remove redundant IComponentFactory instances too

* Found some stragglers

* DestructibleSystem.PrototypeManager: no dependency

* not based
2026-06-29 21:33:56 +00:00

44 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 partial class BodyEmotesSystem : EntitySystem
{
[Dependency] private 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 (!ProtoMan.Resolve(component.SoundsId, out var sounds))
return false;
return _chat.TryPlayEmoteSound(uid, sounds, emote);
}
}