Emote.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Content.Server.Chat.Systems;
  2. using Content.Shared.Chat.Prototypes;
  3. using Content.Shared.EntityEffects;
  4. using JetBrains.Annotations;
  5. using Robust.Shared.Prototypes;
  6. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  7. namespace Content.Server.EntityEffects.Effects;
  8. /// <summary>
  9. /// Tries to force someone to emote (scream, laugh, etc). Still respects whitelists/blacklists and other limits of the specified emote unless forced.
  10. /// </summary>
  11. [UsedImplicitly]
  12. public sealed partial class Emote : EntityEffect
  13. {
  14. [DataField("emote", customTypeSerializer: typeof(PrototypeIdSerializer<EmotePrototype>))]
  15. public string? EmoteId;
  16. [DataField]
  17. public bool ShowInChat;
  18. [DataField]
  19. public bool Force = false;
  20. // JUSTIFICATION: Emoting is flavor, so same reason popup messages are not in here.
  21. protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
  22. => null;
  23. public override void Effect(EntityEffectBaseArgs args)
  24. {
  25. if (EmoteId == null)
  26. return;
  27. var chatSys = args.EntityManager.System<ChatSystem>();
  28. if (ShowInChat)
  29. chatSys.TryEmoteWithChat(args.TargetEntity, EmoteId, ChatTransmitRange.GhostRangeLimit, forceEmote: Force);
  30. else
  31. chatSys.TryEmoteWithoutChat(args.TargetEntity, EmoteId);
  32. }
  33. }