private void SetAnimationInternal(Animation animation, bool loop, QueueEntry entry)
        {
            previous = null;
            if (current != null) {
                if (currentQueueEntry != null) currentQueueEntry.OnEnd(this);
                if (End != null) End(this, EventArgs.Empty);

                if (animation != null) {
                    mixDuration = data.GetMix(current, animation);
                    if (mixDuration > 0) {
                        mixTime = 0;
                        previous = current;
                        previousTime = currentTime;
                        previousLoop = currentLoop;
                    }
                }
            }
            current = animation;
            currentLoop = loop;
            currentTime = 0;
            currentLastTime = 0;
            currentQueueEntry = entry;

            if (currentQueueEntry != null) currentQueueEntry.OnStart(this);
            if (Start != null) Start(this, EventArgs.Empty);
        }
        /** Adds an animation to be played delay seconds after the current or last queued animation.
         * @param delay May be <= 0 to use duration of previous animation minus any mix duration plus the negative delay. */
        public QueueEntry AddAnimation(Animation animation, bool loop, float delay)
        {
            QueueEntry entry = new QueueEntry();
            entry.animation = animation;
            entry.loop = loop;

            if (delay <= 0) {
                Animation previousAnimation = queue.Count == 0 ? current : queue[queue.Count - 1].animation;
                if (previousAnimation != null)
                    delay = previousAnimation.duration - data.GetMix(previousAnimation, animation) + delay;
                else
                    delay = 0;
            }
            entry.delay = delay;

            queue.Add(entry);
            return entry;
        }