Files
OldThink/Content.Server/_White/Animations/EmoteAnimationSystem.cs
2024-01-29 01:02:37 +07:00

36 lines
1.2 KiB
C#

using Content.Server.Chat.Systems;
using Content.Shared.Chat.Prototypes;
using Content.Shared._White.Animations;
using Robust.Shared.GameStates;
using static Content.Shared._White.Animations.EmoteAnimationComponent;
namespace Content.Server._White.Animations;
public sealed class EmoteAnimationSystem : EntitySystem
{
public override void Initialize()
{
SubscribeLocalEvent<EmoteAnimationComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<EmoteAnimationComponent, EmoteEvent>(OnEmote);
}
private void OnGetState(EntityUid uid, EmoteAnimationComponent component, ref ComponentGetState args)
{
args.State = new EmoteAnimationComponentState(component.AnimationId);
}
private void OnEmote(EntityUid uid, EmoteAnimationComponent component, ref EmoteEvent args)
{
if (args.Handled || !args.Emote.Category.HasFlag(EmoteCategory.Hands))
return;
PlayEmoteAnimation(uid, component, args.Emote.ID);
}
public void PlayEmoteAnimation(EntityUid uid, EmoteAnimationComponent component, string emoteId)
{
component.AnimationId = emoteId;
Dirty(component);
}
}