Beispiel #1
0
            /// <summary>
            /// Calls <see cref="Destroy(AnimationClip)"/> on all states gathered by
            /// <see cref="IAnimationClipCollection.GatherAnimationClips"/>.
            /// </summary>
            public void DestroyAll(IAnimationClipCollection source)
            {
                if (source == null)
                {
                    return;
                }

                var clips = ObjectPool.AcquireSet <AnimationClip>();

                foreach (var clip in clips)
                {
                    Destroy(clip);
                }
                ObjectPool.Release(clips);
            }
Beispiel #2
0
            /************************************************************************************************************************/

            /// <summary>
            /// Calls <see cref="Destroy(AnimationClip)"/> on all states gathered by
            /// <see cref="IAnimationClipSource.GetAnimationClips"/>.
            /// </summary>
            public void DestroyAll(IAnimationClipSource source)
            {
                if (source == null)
                {
                    return;
                }

                var clips = ObjectPool.AcquireList <AnimationClip>();

                for (int i = 0; i < clips.Count; i++)
                {
                    Destroy(clips[i]);
                }
                ObjectPool.Release(clips);
            }
            /************************************************************************************************************************/

            /// <summary>
            /// Returns this <see cref="EventRunner"/> to the <see cref="ObjectPool"/>.
            /// </summary>
            private void Release()
            {
                if (_State == null)
                {
                    return;
                }

                _State.Root.CancelUpdate(this);

                Events = null;
                _State._EventRunner = null;
                _State = null;

                ObjectPool.Release(this);
            }
Beispiel #4
0
        /************************************************************************************************************************/

        /// <summary>
        /// Checks if any <see cref="AnimationClip"/> in the `source` has an animation event with the specified
        /// `functionName`.
        /// </summary>
        public static bool HasEvent(IAnimationClipCollection source, string functionName)
        {
            var clips = ObjectPool.AcquireSet <AnimationClip>();

            source.GatherAnimationClips(clips);

            foreach (var clip in clips)
            {
                if (HasEvent(clip, functionName))
                {
                    ObjectPool.Release(clips);
                    return(true);
                }
            }

            ObjectPool.Release(clips);
            return(false);
        }
            /************************************************************************************************************************/

            /// <summary>
            /// Returns this <see cref="EventUpdatable"/> to the <see cref="ObjectPool"/>.
            /// </summary>
            private void Release()
            {
                if (_State == null)
                {
                    return;
                }

                _State.Root.CancelUpdate(this);

                if (_GotEventsFromPool)
                {
                    _Events.Clear();
                    ObjectPool.Release(_Events);
                    _GotEventsFromPool = false;
                }

                _Events = null;
                _State._EventUpdatable = null;
                _State          = null;
                _NextEventIndex = RecalculateEventIndex;

                ObjectPool.Release(this);
            }
Beispiel #6
0
 /// <summary>
 /// Calls <see cref="ObjectPool{T}.Release"/> to clear the `list` and mark it as a spare
 /// so it can be later returned by <see cref="AcquireList"/>.
 /// </summary>
 public static void Release <T>(List <T> list)
 {
     list.Clear();
     ObjectPool <List <T> > .Release(list);
 }
Beispiel #7
0
        /************************************************************************************************************************/

        /// <summary>
        /// Calls <see cref="ObjectPool{T}.Release"/> to add the `item` to the list of spares so it can be reused.
        /// </summary>
        public static void Release <T>(T item)
            where T : class, new()
        => ObjectPool <T> .Release(item);
Beispiel #8
0
 /// <summary>
 /// Sets <see cref="StringBuilder.Length"/> = 0 and <see cref="ObjectPool{T}.Release"/> to mark it as a spare
 /// so it can be later returned by <see cref="AcquireStringBuilder"/>.
 /// </summary>
 public static void Release(StringBuilder builder)
 {
     builder.Length = 0;
     ObjectPool <StringBuilder> .Release(builder);
 }
Beispiel #9
0
 /// <summary>
 /// Calls <see cref="ObjectPool{T}.Release"/> to clear the `set` and mark it as a spare
 /// so it can be later returned by <see cref="AcquireSet"/>.
 /// </summary>
 public static void Release <T>(HashSet <T> set)
 {
     set.Clear();
     ObjectPool <HashSet <T> > .Release(set);
 }
Beispiel #10
0
        /************************************************************************************************************************/

        private void Release()
        {
            _Callback = null;
            _Node     = null;
            ObjectPool.Release(this);
        }
Beispiel #11
0
            /************************************************************************************************************************/

            protected override void Release() => ObjectPool <Curve> .Release(this);
Beispiel #12
0
            /************************************************************************************************************************/

            protected override void Release() => ObjectPool <Delegate> .Release(this);
Beispiel #13
0
        /// <summary>Adds the `item` to the list of spares so it can be reused and sets it to <c>null</c>.</summary>
        public static void Release <T>(ref T item) where T : class, new()
        {
            ObjectPool <T> .Release(item);

            item = null;
        }