using System; using System.Collections.Generic; using Robust.Client.Animations; using Robust.Shared.GameObjects; using static Robust.Client.Animations.AnimationPlaybackShared; namespace Robust.Client.GameObjects { /// /// Plays back s on entities. /// public sealed class AnimationPlayerComponent : Component { // TODO: Give this component a friend someday. Way too much content shit to change atm ._. public override string Name => "AnimationPlayer"; public int PlayingAnimationCount => PlayingAnimations.Count; internal readonly Dictionary PlayingAnimations = new(); internal bool HasPlayingAnimation = false; /// /// Start playing an animation. /// /// The animation to play. /// /// The key for this animation play. This key can be used to stop playback short later. /// public void Play(Animation animation, string key) { EntitySystem.Get().AddComponent(this); var playback = new AnimationPlayback(animation); PlayingAnimations.Add(key, playback); } public bool HasRunningAnimation(string key) { return PlayingAnimations.ContainsKey(key); } public void Stop(string key) { PlayingAnimations.Remove(key); } /// /// Temporary method until the event is replaced with eventbus. /// internal void AnimationComplete(string key) { #pragma warning disable 618 AnimationCompleted?.Invoke(key); #pragma warning restore 618 } [Obsolete("Use AnimationCompletedEvent instead")] public event Action? AnimationCompleted; } }