Files
tbd-station-14/Content.Server/Chat/AutoEmoteComponent.cs
0x6273 72269c7a77 Add AutoEmote comp/system, updates to zombie code (#13932)
* Add AutoEmote comp/system

* Reduce groan chance so it's the same as before

Old code did 0.2 and then 0.5, now it's just one Prob(0.1)

* Fix typo, curTime var, don't log Resolve

* Maybe fix pausing?

* Fix mistake

* Update NextEmoteTime if an auto emote is removed

* Fix stuff

Get CurTime outside update loop
Use MapInit instead of ComponentInit
Fix a typo in a comment
Debug assert prototype ID in RemoveEmote
Do += PausedTime in OnUnpaused
Add prototype as arg to ResetTimer to avoid an indexing
2023-03-02 11:23:56 -08:00

33 lines
1.4 KiB
C#

namespace Content.Server.Chat;
using Content.Server.Chat.Systems;
using Content.Shared.Chat.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
/// <summary>
/// Causes an entity to automatically emote at a set interval.
/// </summary>
[RegisterComponent, Access(typeof(AutoEmoteSystem))]
public sealed class AutoEmoteComponent : Component
{
/// <summary>
/// A set of emotes that the entity will preform.
/// <see cref="AutoEmotePrototype"/>
/// </summary>
[DataField("emotes", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<AutoEmotePrototype>)), ViewVariables(VVAccess.ReadOnly)]
public HashSet<string> Emotes = new HashSet<string>();
/// <summary>
/// A dictionary storing the time of the next emote attempt for each emote.
/// Uses AutoEmotePrototype IDs as keys.
/// <summary>
[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
public Dictionary<string, TimeSpan> EmoteTimers = new Dictionary<string, TimeSpan>();
/// <summary>
/// Time of the next emote. Redundant, but avoids having to iterate EmoteTimers each update.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
public TimeSpan NextEmoteTime = TimeSpan.MaxValue;
}