예제 #1
0
        /************************************************************************************************************************/

        /// <summary>
        /// Stops the animation and makes it inactive immediately so it no longer affects the output.
        /// Sets <see cref="AnimancerNode.Weight"/> = 0, <see cref="IsPlaying"/> = false, <see cref="Time"/> = 0, and
        /// clears the <see cref="Events"/>.
        /// <para></para>
        /// If you only want to freeze the animation in place, you can set <see cref="IsPlaying"/> = false instead. Or
        /// to freeze all animations, you can call <see cref="AnimancerPlayable.PauseGraph"/>.
        /// </summary>
        public override void Stop()
        {
            base.Stop();

            IsPlaying = false;
            Time      = 0;
            EventUpdatable.TryClear(_EventUpdatable);
        }
            /************************************************************************************************************************/

            /// <summary>
            /// If the <see cref="AnimancerEvent.Sequence"/> was acquired from the <see cref="ObjectPool"/>, this
            /// method clears it. Otherwise it simply discards the reference.
            /// </summary>
            public static void TryClear(EventUpdatable events)
            {
                if (events != null && events._Events != null)
                {
                    events._NextEventIndex = RecalculateEventIndex;
                    if (events._GotEventsFromPool)
                    {
                        events._Events.Clear();
                        events._GotEventsFromPool = false;
                    }

                    events._Events = null;
                }
            }
예제 #3
0
        /************************************************************************************************************************/

        /// <summary>Destroys the <see cref="Playable"/>.</summary>
        public virtual void Destroy()
        {
            GC.SuppressFinalize(this);

            if (_Parent != null)
            {
                _Parent.OnRemoveChild(this);
            }

            Index = -1;
            EventUpdatable.TryClear(_EventUpdatable);

            Root.States.Unregister(this);

            // For some reason this is slightly faster than _Playable.Destroy().
            if (_Playable.IsValid())
            {
                Root._Graph.DestroyPlayable(_Playable);
            }
        }
예제 #4
0
        /************************************************************************************************************************/

        /// <summary>
        /// Called by <see cref="AnimancerNode.StartFade"/>. Clears the <see cref="Events"/>.
        /// </summary>
        protected internal override void OnStartFade()
        {
            EventUpdatable.TryClear(_EventUpdatable);
        }
예제 #5
0
        /************************************************************************************************************************/

        /// <summary>
        /// Plays this animation immediately, without any blending.
        /// Sets <see cref="IsPlaying"/> = true, <see cref="AnimancerNode.Weight"/> = 1, and clears the
        /// <see cref="Events"/>.
        /// <para></para>
        /// This method does not change the <see cref="Time"/> so it will continue from its current value.
        /// </summary>
        public void Play()
        {
            IsPlaying = true;
            Weight    = 1;
            EventUpdatable.TryClear(_EventUpdatable);
        }