EmoteOnDamageComponent.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. namespace Content.Server.Chat;
  2. using Content.Server.Chat.Systems;
  3. using Content.Shared.Chat.Prototypes;
  4. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  5. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
  6. /// <summary>
  7. /// Causes an entity to automatically emote when taking damage.
  8. /// </summary>
  9. [RegisterComponent, Access(typeof(EmoteOnDamageSystem)), AutoGenerateComponentPause]
  10. public sealed partial class EmoteOnDamageComponent : Component
  11. {
  12. /// <summary>
  13. /// Chance of preforming an emote when taking damage and not on cooldown.
  14. /// </summary>
  15. [DataField("emoteChance"), ViewVariables(VVAccess.ReadWrite)]
  16. public float EmoteChance = 0.5f;
  17. /// <summary>
  18. /// A set of emotes that will be randomly picked from.
  19. /// <see cref="EmotePrototype"/>
  20. /// </summary>
  21. [DataField("emotes", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<EmotePrototype>)), ViewVariables(VVAccess.ReadWrite)]
  22. public HashSet<string> Emotes = new();
  23. /// <summary>
  24. /// Also send the emote in chat.
  25. /// <summary>
  26. [DataField("withChat"), ViewVariables(VVAccess.ReadWrite)]
  27. public bool WithChat = false;
  28. /// <summary>
  29. /// Hide the chat message from the chat window, only showing the popup.
  30. /// This does nothing if WithChat is false.
  31. /// <summary>
  32. [DataField("hiddenFromChatWindow")]
  33. public bool HiddenFromChatWindow = false;
  34. /// <summary>
  35. /// The simulation time of the last emote preformed due to taking damage.
  36. /// </summary>
  37. [DataField("lastEmoteTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
  38. [AutoPausedField]
  39. public TimeSpan LastEmoteTime = TimeSpan.Zero;
  40. /// <summary>
  41. /// The cooldown between emotes.
  42. /// </summary>
  43. [DataField("emoteCooldown"), ViewVariables(VVAccess.ReadWrite)]
  44. public TimeSpan EmoteCooldown = TimeSpan.FromSeconds(2);
  45. }