Пример #1
0
        // Token: 0x0600015C RID: 348 RVA: 0x00007778 File Offset: 0x00005978
        internal static bool DoGoto(Tween t, float toPosition, int toCompletedLoops, UpdateMode updateMode)
        {
            if (!t.startupDone && !t.Startup())
            {
                return(true);
            }
            if (!t.playedOnce && updateMode == UpdateMode.Update)
            {
                t.playedOnce = true;
                if (t.onStart != null)
                {
                    Tween.OnTweenCallback(t.onStart);
                    if (!t.active)
                    {
                        return(true);
                    }
                }
                if (t.onPlay != null)
                {
                    Tween.OnTweenCallback(t.onPlay);
                    if (!t.active)
                    {
                        return(true);
                    }
                }
            }
            float prevPosition = t.position;
            int   num          = t.completedLoops;

            t.completedLoops = toCompletedLoops;
            bool flag  = t.position <= 0f && num <= 0;
            bool flag2 = t.isComplete;

            if (t.loops != -1)
            {
                t.isComplete = (t.completedLoops == t.loops);
            }
            int num2 = 0;

            if (updateMode == UpdateMode.Update)
            {
                if (t.isBackwards)
                {
                    num2 = ((t.completedLoops < num) ? (num - t.completedLoops) : ((toPosition <= 0f && !flag) ? 1 : 0));
                    if (flag2)
                    {
                        num2--;
                    }
                }
                else
                {
                    num2 = ((t.completedLoops > num) ? (t.completedLoops - num) : 0);
                }
            }
            else if (t.tweenType == TweenType.Sequence)
            {
                num2 = num - toCompletedLoops;
                if (num2 < 0)
                {
                    num2 = -num2;
                }
            }
            t.position = toPosition;
            if (t.position > t.duration)
            {
                t.position = t.duration;
            }
            else if (t.position <= 0f)
            {
                if (t.completedLoops > 0 || t.isComplete)
                {
                    t.position = t.duration;
                }
                else
                {
                    t.position = 0f;
                }
            }
            bool flag3 = t.isPlaying;

            if (t.isPlaying)
            {
                if (!t.isBackwards)
                {
                    t.isPlaying = !t.isComplete;
                }
                else
                {
                    t.isPlaying = (t.completedLoops != 0 || t.position > 0f);
                }
            }
            bool         useInversePosition = t.loopType == LoopType.Yoyo && ((t.position < t.duration) ? (t.completedLoops % 2 != 0) : (t.completedLoops % 2 == 0));
            UpdateNotice updateNotice       = (!flag && ((t.loopType == LoopType.Restart && t.completedLoops != num) || (t.position <= 0f && t.completedLoops <= 0))) ? UpdateNotice.RewindStep : UpdateNotice.None;

            if (t.ApplyTween(prevPosition, num, num2, useInversePosition, updateMode, updateNotice))
            {
                return(true);
            }
            if (t.onUpdate != null && updateMode != UpdateMode.IgnoreOnUpdate)
            {
                Tween.OnTweenCallback(t.onUpdate);
            }
            if (t.position <= 0f && t.completedLoops <= 0 && !flag && t.onRewind != null)
            {
                Tween.OnTweenCallback(t.onRewind);
            }
            if (num2 > 0 && updateMode == UpdateMode.Update && t.onStepComplete != null)
            {
                for (int i = 0; i < num2; i++)
                {
                    Tween.OnTweenCallback(t.onStepComplete);
                }
            }
            if (t.isComplete && !flag2 && t.onComplete != null)
            {
                Tween.OnTweenCallback(t.onComplete);
            }
            if (!t.isPlaying && flag3 && (!t.isComplete || !t.autoKill) && t.onPause != null)
            {
                Tween.OnTweenCallback(t.onPause);
            }
            return(t.autoKill && t.isComplete);
        }
Пример #2
0
        // Instead of advancing the tween from the previous position each time,
        // uses the given position to calculate running time since startup, and places the tween there like a Goto.
        // Executes regardless of whether the tween is playing.
        // Returns TRUE if the tween needs to be killed
        internal static bool DoGoto(Tween t, float toPosition, int toCompletedLoops, UpdateMode updateMode)
        {
            // Startup
            if (!t.startupDone)
            {
                if (!t.Startup())
                {
                    return(true);
                }
            }
            // OnStart and first OnPlay callbacks
            if (!t.playedOnce && updateMode == UpdateMode.Update)
            {
                t.playedOnce = true;
                if (t.onStart != null)
                {
                    OnTweenCallback(t.onStart);
                    if (!t.active)
                    {
                        return(true);           // Tween might have been killed by onStart callback
                    }
                }
                if (t.onPlay != null)
                {
                    OnTweenCallback(t.onPlay);
                    if (!t.active)
                    {
                        return(true);           // Tween might have been killed by onPlay callback
                    }
                }
            }

            float prevPosition       = t.position;
            int   prevCompletedLoops = t.completedLoops;

            t.completedLoops = toCompletedLoops;
            bool wasRewinded = t.position <= 0 && prevCompletedLoops <= 0;
            bool wasComplete = t.isComplete;

            // Determine if it will be complete after update
            if (t.loops != -1)
            {
                t.isComplete = t.completedLoops == t.loops;
            }
            // Calculate newCompletedSteps (always useful with Sequences)
            int newCompletedSteps = 0;

            if (updateMode == UpdateMode.Update)
            {
                if (t.isBackwards)
                {
                    newCompletedSteps = t.completedLoops < prevCompletedLoops ? prevCompletedLoops - t.completedLoops : (toPosition <= 0 && !wasRewinded ? 1 : 0);
                    if (wasComplete)
                    {
                        newCompletedSteps--;
                    }
                }
                else
                {
                    newCompletedSteps = t.completedLoops > prevCompletedLoops ? t.completedLoops - prevCompletedLoops : 0;
                }
            }
            else if (t.tweenType == TweenType.Sequence)
            {
                newCompletedSteps = prevCompletedLoops - toCompletedLoops;
                if (newCompletedSteps < 0)
                {
                    newCompletedSteps = -newCompletedSteps;
                }
            }

            // Set position (makes position 0 equal to position "end" when looping)
            t.position = toPosition;
            if (t.position > t.duration)
            {
                t.position = t.duration;
            }
            else if (t.position <= 0)
            {
                if (t.completedLoops > 0 || t.isComplete)
                {
                    t.position = t.duration;
                }
                else
                {
                    t.position = 0;
                }
            }
            // Set playing state after update
            bool wasPlaying = t.isPlaying;

            if (t.isPlaying)
            {
                if (!t.isBackwards)
                {
                    t.isPlaying = !t.isComplete;                 // Reached the end
                }
                else
                {
                    t.isPlaying = !(t.completedLoops == 0 && t.position <= 0);  // Rewinded
                }
            }

            // updatePosition is different in case of Yoyo loop under certain circumstances
            bool useInversePosition = t.loopType == LoopType.Yoyo &&
                                      (t.position < t.duration ? t.completedLoops % 2 != 0 : t.completedLoops % 2 == 0);

            // Get values from plugin and set them
            bool isRewindStep = !wasRewinded && (
                t.loopType == LoopType.Restart && t.completedLoops != prevCompletedLoops && (t.loops == -1 || t.completedLoops < t.loops) ||
                t.position <= 0 && t.completedLoops <= 0
                );
            UpdateNotice updateNotice = isRewindStep ? UpdateNotice.RewindStep : UpdateNotice.None;

            if (t.ApplyTween(prevPosition, prevCompletedLoops, newCompletedSteps, useInversePosition, updateMode, updateNotice))
            {
                return(true);
            }

            // Additional callbacks
            if (t.onUpdate != null && updateMode != UpdateMode.IgnoreOnUpdate)
            {
                OnTweenCallback(t.onUpdate);
            }
            if (t.position <= 0 && t.completedLoops <= 0 && !wasRewinded && t.onRewind != null)
            {
                OnTweenCallback(t.onRewind);
            }
            if (newCompletedSteps > 0 && updateMode == UpdateMode.Update && t.onStepComplete != null)
            {
                for (int i = 0; i < newCompletedSteps; ++i)
                {
                    OnTweenCallback(t.onStepComplete);
                }
            }
            if (t.isComplete && !wasComplete && updateMode != UpdateMode.IgnoreOnComplete && t.onComplete != null)
            {
                OnTweenCallback(t.onComplete);
            }
            if (!t.isPlaying && wasPlaying && (!t.isComplete || !t.autoKill) && t.onPause != null)
            {
                OnTweenCallback(t.onPause);
            }

            // Return
            return(t.autoKill && t.isComplete);
        }
Пример #3
0
        internal static bool DoGoto(Tween t, float toPosition, int toCompletedLoops, UpdateMode updateMode)
        {
            if (!t.startupDone && !t.Startup())
            {
                return(true);
            }
            if (!t.playedOnce && (updateMode == UpdateMode.Update))
            {
                t.playedOnce = true;
                if (t.onStart != null)
                {
                    OnTweenCallback(t.onStart);
                    if (!t.active)
                    {
                        return(true);
                    }
                }
                if (t.onPlay != null)
                {
                    OnTweenCallback(t.onPlay);
                    if (!t.active)
                    {
                        return(true);
                    }
                }
            }
            float position       = t.position;
            int   completedLoops = t.completedLoops;

            t.completedLoops = toCompletedLoops;
            bool flag       = (t.position <= 0f) && (completedLoops <= 0);
            bool isComplete = t.isComplete;

            if (t.loops != -1)
            {
                t.isComplete = t.completedLoops == t.loops;
            }
            int newCompletedSteps = 0;

            if (updateMode == UpdateMode.Update)
            {
                if (t.isBackwards)
                {
                    newCompletedSteps = (t.completedLoops < completedLoops) ? (completedLoops - t.completedLoops) : (((toPosition <= 0f) && !flag) ? 1 : 0);
                    if (isComplete)
                    {
                        newCompletedSteps--;
                    }
                }
                else
                {
                    newCompletedSteps = (t.completedLoops > completedLoops) ? (t.completedLoops - completedLoops) : 0;
                }
            }
            else if (t.tweenType == TweenType.Sequence)
            {
                newCompletedSteps = completedLoops - toCompletedLoops;
                if (newCompletedSteps < 0)
                {
                    newCompletedSteps = -newCompletedSteps;
                }
            }
            t.position = toPosition;
            if (t.position > t.duration)
            {
                t.position = t.duration;
            }
            else if (t.position <= 0f)
            {
                if ((t.completedLoops > 0) || t.isComplete)
                {
                    t.position = t.duration;
                }
                else
                {
                    t.position = 0f;
                }
            }
            bool isPlaying = t.isPlaying;

            if (t.isPlaying)
            {
                if (!t.isBackwards)
                {
                    t.isPlaying = !t.isComplete;
                }
                else
                {
                    t.isPlaying = (t.completedLoops != 0) || (t.position > 0f);
                }
            }
            bool         useInversePosition = (t.loopType == LoopType.Yoyo) && ((t.position < t.duration) ? ((t.completedLoops % 2) > 0) : ((t.completedLoops % 2) == 0));
            UpdateNotice updateNotice       = (!flag && (((t.loopType == LoopType.Restart) && (t.completedLoops != completedLoops)) || ((t.position <= 0f) && (t.completedLoops <= 0)))) ? UpdateNotice.RewindStep : UpdateNotice.None;

            if (t.ApplyTween(position, completedLoops, newCompletedSteps, useInversePosition, updateMode, updateNotice))
            {
                return(true);
            }
            if ((t.onUpdate != null) && (updateMode != UpdateMode.IgnoreOnUpdate))
            {
                OnTweenCallback(t.onUpdate);
            }
            if (((t.position <= 0f) && (t.completedLoops <= 0)) && (!flag && (t.onRewind != null)))
            {
                OnTweenCallback(t.onRewind);
            }
            if (((newCompletedSteps > 0) && (updateMode == UpdateMode.Update)) && (t.onStepComplete != null))
            {
                for (int i = 0; i < newCompletedSteps; i++)
                {
                    OnTweenCallback(t.onStepComplete);
                }
            }
            if ((t.isComplete && !isComplete) && (t.onComplete != null))
            {
                OnTweenCallback(t.onComplete);
            }
            if (((!t.isPlaying & isPlaying) && (!t.isComplete || !t.autoKill)) && (t.onPause != null))
            {
                OnTweenCallback(t.onPause);
            }
            return(t.autoKill && t.isComplete);
        }