AutoEmoteComponent.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132
  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.Prototype.Set;
  5. /// <summary>
  6. /// Causes an entity to automatically emote at a set interval.
  7. /// </summary>
  8. [RegisterComponent, Access(typeof(AutoEmoteSystem))]
  9. public sealed partial class AutoEmoteComponent : Component
  10. {
  11. /// <summary>
  12. /// A set of emotes that the entity will preform.
  13. /// <see cref="AutoEmotePrototype"/>
  14. /// </summary>
  15. [DataField("emotes", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<AutoEmotePrototype>)), ViewVariables(VVAccess.ReadOnly)]
  16. public HashSet<string> Emotes = new HashSet<string>();
  17. /// <summary>
  18. /// A dictionary storing the time of the next emote attempt for each emote.
  19. /// Uses AutoEmotePrototype IDs as keys.
  20. /// <summary>
  21. [ViewVariables(VVAccess.ReadOnly)] //TODO: make this a datafield and (de)serialize values as time offsets when https://github.com/space-wizards/RobustToolbox/issues/3768 is fixed
  22. public Dictionary<string, TimeSpan> EmoteTimers = new Dictionary<string, TimeSpan>();
  23. /// <summary>
  24. /// Time of the next emote. Redundant, but avoids having to iterate EmoteTimers each update.
  25. /// </summary>
  26. [ViewVariables(VVAccess.ReadOnly)]
  27. public TimeSpan NextEmoteTime = TimeSpan.MaxValue;
  28. }