1
0

EmotesMenuSystem.cs 860 B

123456789101112131415161718192021222324252627282930
  1. using Content.Server.Chat.Systems;
  2. using Content.Shared.Chat;
  3. using Robust.Shared.Prototypes;
  4. namespace Content.Server.Speech;
  5. public sealed partial class EmotesMenuSystem : EntitySystem
  6. {
  7. [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
  8. [Dependency] private readonly ChatSystem _chat = default!;
  9. public override void Initialize()
  10. {
  11. base.Initialize();
  12. SubscribeAllEvent<PlayEmoteMessage>(OnPlayEmote);
  13. }
  14. private void OnPlayEmote(PlayEmoteMessage msg, EntitySessionEventArgs args)
  15. {
  16. var player = args.SenderSession.AttachedEntity;
  17. if (!player.HasValue)
  18. return;
  19. if (!_prototypeManager.TryIndex(msg.ProtoId, out var proto) || proto.ChatTriggers.Count == 0)
  20. return;
  21. _chat.TryEmoteWithChat(player.Value, msg.ProtoId);
  22. }
  23. }