// Commented this out because it interferes with Unity 2019.3 "no domain reload" experimental playmode
        // (now I clear DOTween completely when the DOTween component is destroyed which allows this to be commented out)
//        void OnApplicationQuit()
//        {
//            DOTween.isQuitting = true;
//        }

        #endregion

        #region Editor



        #endregion

        #region Public Methods

        /// <summary>
        /// Directly sets the current max capacity of Tweeners and Sequences
        /// (meaning how many Tweeners and Sequences can be running at the same time),
        /// so that DOTween doesn't need to automatically increase them in case the max is reached
        /// (which might lead to hiccups when that happens).
        /// Sequences capacity must be less or equal to Tweeners capacity
        /// (if you pass a low Tweener capacity it will be automatically increased to match the Sequence's).
        /// Beware: use this method only when there are no tweens running.
        /// </summary>
        /// <param name="tweenersCapacity">Max Tweeners capacity.
        /// Default: 200</param>
        /// <param name="sequencesCapacity">Max Sequences capacity.
        /// Default: 50</param>
        public IDOTweenInit SetCapacity(int tweenersCapacity, int sequencesCapacity)
        {
            TweenManager.SetCapacities(tweenersCapacity, sequencesCapacity);
            return(this);
        }
Beispiel #2
0
        public static void Update(UpdateType updateType, float deltaTime, float independentTime)
        {
            if (TweenManager._requiresActiveReorganization)
            {
                TweenManager.ReorganizeActiveTweens();
            }
            TweenManager.isUpdateLoop = true;
            bool flag = false;
            int  num  = TweenManager._maxActiveLookupId + 1;

            for (int i = 0; i < num; i++)
            {
                Tween tween = TweenManager._activeTweens[i];
                if (tween != null && tween.updateType == updateType)
                {
                    if (!tween.active)
                    {
                        flag = true;
                        TweenManager.MarkForKilling(tween);
                    }
                    else if (tween.isPlaying)
                    {
                        tween.creationLocked = true;
                        float num2 = (tween.isIndependentUpdate ? independentTime : deltaTime) * tween.timeScale;
                        if (!tween.delayComplete)
                        {
                            num2 = tween.UpdateDelay(tween.elapsedDelay + num2);
                            if (num2 <= -1f)
                            {
                                flag = true;
                                TweenManager.MarkForKilling(tween);
                                goto IL_1CB;
                            }
                            if (num2 <= 0f)
                            {
                                goto IL_1CB;
                            }
                        }
                        if (!tween.startupDone && !tween.Startup())
                        {
                            flag = true;
                            TweenManager.MarkForKilling(tween);
                        }
                        else
                        {
                            float num3  = tween.position;
                            bool  flag2 = num3 >= tween.duration;
                            int   num4  = tween.completedLoops;
                            if (tween.duration <= 0f)
                            {
                                num3 = 0f;
                                num4 = ((tween.loops == -1) ? (tween.completedLoops + 1) : tween.loops);
                            }
                            else
                            {
                                if (tween.isBackwards)
                                {
                                    num3 -= num2;
                                    while (num3 < 0f)
                                    {
                                        if (num4 <= 0)
                                        {
                                            break;
                                        }
                                        num3 += tween.duration;
                                        num4--;
                                    }
                                }
                                else
                                {
                                    num3 += num2;
                                    while (num3 >= tween.duration && (tween.loops == -1 || num4 < tween.loops))
                                    {
                                        num3 -= tween.duration;
                                        num4++;
                                    }
                                }
                                if (flag2)
                                {
                                    num4--;
                                }
                                if (tween.loops != -1 && num4 >= tween.loops)
                                {
                                    num3 = tween.duration;
                                }
                            }
                            bool flag3 = Tween.DoGoto(tween, num3, num4, UpdateMode.Update);
                            if (flag3)
                            {
                                flag = true;
                                TweenManager.MarkForKilling(tween);
                            }
                        }
                    }
                }
                IL_1CB :;
            }
            if (flag)
            {
                TweenManager.DespawnTweens(TweenManager._KillList, false);
                int num5 = TweenManager._KillList.Count - 1;
                for (int j = num5; j > -1; j--)
                {
                    TweenManager.RemoveActiveTween(TweenManager._KillList[j]);
                }
                TweenManager._KillList.Clear();
            }
            TweenManager.isUpdateLoop = false;
        }
Beispiel #3
0
        public static int FilteredOperation(OperationType operationType, FilterType filterType, object id, bool optionalBool, float optionalFloat, object optionalObj = null)
        {
            int  num  = 0;
            bool flag = false;

            for (int i = TweenManager._maxActiveLookupId; i > -1; i--)
            {
                Tween tween = TweenManager._activeTweens[i];
                if (tween != null && tween.active)
                {
                    bool flag2 = false;
                    switch (filterType)
                    {
                    case FilterType.All:
                        flag2 = true;
                        break;

                    case FilterType.TargetOrId:
                        flag2 = (id.Equals(tween.id) || id.Equals(tween.target));
                        break;

                    case FilterType.TargetAndId:
                        flag2 = (id.Equals(tween.id) && optionalObj != null && optionalObj.Equals(tween.target));
                        break;
                    }
                    if (flag2)
                    {
                        switch (operationType)
                        {
                        case OperationType.Complete:
                        {
                            bool autoKill = tween.autoKill;
                            if (TweenManager.Complete(tween, false))
                            {
                                num += ((!optionalBool) ? 1 : (autoKill ? 1 : 0));
                                if (autoKill)
                                {
                                    if (TweenManager.isUpdateLoop)
                                    {
                                        tween.active = false;
                                    }
                                    else
                                    {
                                        flag = true;
                                        TweenManager._KillList.Add(tween);
                                    }
                                }
                            }
                            break;
                        }

                        case OperationType.Despawn:
                            num++;
                            if (TweenManager.isUpdateLoop)
                            {
                                tween.active = false;
                            }
                            else
                            {
                                TweenManager.Despawn(tween, false);
                                flag = true;
                                TweenManager._KillList.Add(tween);
                            }
                            break;

                        case OperationType.Flip:
                            if (TweenManager.Flip(tween))
                            {
                                num++;
                            }
                            break;

                        case OperationType.Goto:
                            TweenManager.Goto(tween, optionalFloat, optionalBool, UpdateMode.Goto);
                            num++;
                            break;

                        case OperationType.Pause:
                            if (TweenManager.Pause(tween))
                            {
                                num++;
                            }
                            break;

                        case OperationType.Play:
                            if (TweenManager.Play(tween))
                            {
                                num++;
                            }
                            break;

                        case OperationType.PlayForward:
                            if (TweenManager.PlayForward(tween))
                            {
                                num++;
                            }
                            break;

                        case OperationType.PlayBackwards:
                            if (TweenManager.PlayBackwards(tween))
                            {
                                num++;
                            }
                            break;

                        case OperationType.Rewind:
                            if (TweenManager.Rewind(tween, optionalBool))
                            {
                                num++;
                            }
                            break;

                        case OperationType.SmoothRewind:
                            if (TweenManager.SmoothRewind(tween))
                            {
                                num++;
                            }
                            break;

                        case OperationType.Restart:
                            if (TweenManager.Restart(tween, optionalBool))
                            {
                                num++;
                            }
                            break;

                        case OperationType.TogglePause:
                            if (TweenManager.TogglePause(tween))
                            {
                                num++;
                            }
                            break;

                        case OperationType.IsTweening:
                            if (!tween.isComplete || !tween.autoKill)
                            {
                                num++;
                            }
                            break;
                        }
                    }
                }
            }
            if (flag)
            {
                int num2 = TweenManager._KillList.Count - 1;
                for (int j = num2; j > -1; j--)
                {
                    TweenManager.RemoveActiveTween(TweenManager._KillList[j]);
                }
                TweenManager._KillList.Clear();
            }
            return(num);
        }
Beispiel #4
0
        public static void Despawn(Tween t, bool modifyActiveLists = true)
        {
            if (t.onKill != null)
            {
                Tween.OnTweenCallback(t.onKill);
            }
            if (modifyActiveLists)
            {
                TweenManager.RemoveActiveTween(t);
            }
            if (t.isRecyclable)
            {
                switch (t.tweenType)
                {
                case TweenType.Tweener:
                    if (TweenManager._maxPooledTweenerId == -1)
                    {
                        TweenManager._maxPooledTweenerId = TweenManager.maxTweeners - 1;
                        TweenManager._minPooledTweenerId = TweenManager.maxTweeners - 1;
                    }
                    if (TweenManager._maxPooledTweenerId < TweenManager.maxTweeners - 1)
                    {
                        TweenManager._pooledTweeners[TweenManager._maxPooledTweenerId + 1] = t;
                        TweenManager._maxPooledTweenerId++;
                        if (TweenManager._minPooledTweenerId > TweenManager._maxPooledTweenerId)
                        {
                            TweenManager._minPooledTweenerId = TweenManager._maxPooledTweenerId;
                        }
                    }
                    else
                    {
                        int i = TweenManager._maxPooledTweenerId;
                        while (i > -1)
                        {
                            if (TweenManager._pooledTweeners[i] == null)
                            {
                                TweenManager._pooledTweeners[i] = t;
                                if (i < TweenManager._minPooledTweenerId)
                                {
                                    TweenManager._minPooledTweenerId = i;
                                }
                                if (TweenManager._maxPooledTweenerId < TweenManager._minPooledTweenerId)
                                {
                                    TweenManager._maxPooledTweenerId = TweenManager._minPooledTweenerId;
                                    break;
                                }
                                break;
                            }
                            else
                            {
                                i--;
                            }
                        }
                    }
                    TweenManager.totPooledTweeners++;
                    break;

                case TweenType.Sequence:
                {
                    TweenManager._PooledSequences.Push(t);
                    TweenManager.totPooledSequences++;
                    Sequence sequence = (Sequence)t;
                    int      count    = sequence.sequencedTweens.Count;
                    for (int j = 0; j < count; j++)
                    {
                        TweenManager.Despawn(sequence.sequencedTweens[j], false);
                    }
                    break;
                }
                }
            }
            else
            {
                switch (t.tweenType)
                {
                case TweenType.Tweener:
                    TweenManager.totTweeners--;
                    break;

                case TweenType.Sequence:
                {
                    TweenManager.totSequences--;
                    Sequence sequence2 = (Sequence)t;
                    int      count2    = sequence2.sequencedTweens.Count;
                    for (int k = 0; k < count2; k++)
                    {
                        TweenManager.Despawn(sequence2.sequencedTweens[k], false);
                    }
                    break;
                }
                }
            }
            t.active = false;
            t.Reset();
        }
Beispiel #5
0
 public static void ResetCapacities()
 {
     TweenManager.SetCapacities(200, 50);
 }
Beispiel #6
0
 public static void AddActiveTweenToSequence(Tween t)
 {
     TweenManager.RemoveActiveTween(t);
 }
Beispiel #7
0
 // Token: 0x0600026C RID: 620 RVA: 0x0000DB99 File Offset: 0x0000BD99
 internal static void ResetCapacities()
 {
     TweenManager.SetCapacities(200, 50);
 }
Beispiel #8
0
 // Token: 0x06000269 RID: 617 RVA: 0x0000D8D4 File Offset: 0x0000BAD4
 internal static void Despawn(Tween t, bool modifyActiveLists = true)
 {
     if (t.onKill != null)
     {
         Tween.OnTweenCallback(t.onKill);
     }
     if (modifyActiveLists)
     {
         TweenManager.RemoveActiveTween(t);
     }
     if (t.isRecyclable)
     {
         TweenType tweenType = t.tweenType;
         if (tweenType != TweenType.Tweener)
         {
             if (tweenType == TweenType.Sequence)
             {
                 TweenManager._PooledSequences.Push(t);
                 TweenManager.totPooledSequences++;
                 Sequence sequence = (Sequence)t;
                 int      count    = sequence.sequencedTweens.Count;
                 for (int i = 0; i < count; i++)
                 {
                     TweenManager.Despawn(sequence.sequencedTweens[i], false);
                 }
             }
         }
         else
         {
             if (TweenManager._maxPooledTweenerId == -1)
             {
                 TweenManager._maxPooledTweenerId = TweenManager.maxTweeners - 1;
                 TweenManager._minPooledTweenerId = TweenManager.maxTweeners - 1;
             }
             if (TweenManager._maxPooledTweenerId < TweenManager.maxTweeners - 1)
             {
                 TweenManager._pooledTweeners[TweenManager._maxPooledTweenerId + 1] = t;
                 TweenManager._maxPooledTweenerId++;
                 if (TweenManager._minPooledTweenerId > TweenManager._maxPooledTweenerId)
                 {
                     TweenManager._minPooledTweenerId = TweenManager._maxPooledTweenerId;
                 }
             }
             else
             {
                 int j = TweenManager._maxPooledTweenerId;
                 while (j > -1)
                 {
                     if (TweenManager._pooledTweeners[j] == null)
                     {
                         TweenManager._pooledTweeners[j] = t;
                         if (j < TweenManager._minPooledTweenerId)
                         {
                             TweenManager._minPooledTweenerId = j;
                         }
                         if (TweenManager._maxPooledTweenerId < TweenManager._minPooledTweenerId)
                         {
                             TweenManager._maxPooledTweenerId = TweenManager._minPooledTweenerId;
                             break;
                         }
                         break;
                     }
                     else
                     {
                         j--;
                     }
                 }
             }
             TweenManager.totPooledTweeners++;
         }
     }
     else
     {
         TweenType tweenType = t.tweenType;
         if (tweenType != TweenType.Tweener)
         {
             if (tweenType == TweenType.Sequence)
             {
                 TweenManager.totSequences--;
                 Sequence sequence2 = (Sequence)t;
                 int      count2    = sequence2.sequencedTweens.Count;
                 for (int k = 0; k < count2; k++)
                 {
                     TweenManager.Despawn(sequence2.sequencedTweens[k], false);
                 }
             }
         }
         else
         {
             TweenManager.totTweeners--;
         }
     }
     t.active = false;
     t.Reset();
 }
Beispiel #9
0
        internal static int FilteredOperation(OperationType operationType, FilterType filterType, object id, bool optionalBool, float optionalFloat, object optionalObj = null, object[] optionalArray = null)
        {
            int  num  = 0;
            bool flag = false;
            int  num2 = (optionalArray != null) ? optionalArray.Length : 0;

            for (int num3 = TweenManager._maxActiveLookupId; num3 > -1; num3--)
            {
                Tween tween = TweenManager._activeTweens[num3];
                if (tween != null && tween.active)
                {
                    bool flag2 = false;
                    switch (filterType)
                    {
                    case FilterType.All:
                        flag2 = true;
                        break;

                    case FilterType.TargetOrId:
                        flag2 = (id.Equals(tween.id) || id.Equals(tween.target));
                        break;

                    case FilterType.TargetAndId:
                        flag2 = (id.Equals(tween.id) && optionalObj != null && optionalObj.Equals(tween.target));
                        break;

                    case FilterType.AllExceptTargetsOrIds:
                    {
                        flag2 = true;
                        int num4 = 0;
                        while (num4 < num2)
                        {
                            object obj = optionalArray[num4];
                            if (!obj.Equals(tween.id) && !obj.Equals(tween.target))
                            {
                                num4++;
                                continue;
                            }
                            flag2 = false;
                            break;
                        }
                        break;
                    }
                    }
                    if (flag2)
                    {
                        switch (operationType)
                        {
                        case OperationType.Despawn:
                            num++;
                            if (TweenManager.isUpdateLoop)
                            {
                                tween.active = false;
                            }
                            else
                            {
                                TweenManager.Despawn(tween, false);
                                flag = true;
                                TweenManager._KillList.Add(tween);
                            }
                            break;

                        case OperationType.Complete:
                        {
                            bool autoKill = tween.autoKill;
                            if (TweenManager.Complete(tween, false, (UpdateMode)((!(optionalFloat > 0f)) ? 1 : 0)))
                            {
                                num += ((!optionalBool) ? 1 : (autoKill ? 1 : 0));
                                if (autoKill)
                                {
                                    if (TweenManager.isUpdateLoop)
                                    {
                                        tween.active = false;
                                    }
                                    else
                                    {
                                        flag = true;
                                        TweenManager._KillList.Add(tween);
                                    }
                                }
                            }
                            break;
                        }

                        case OperationType.Flip:
                            if (TweenManager.Flip(tween))
                            {
                                num++;
                            }
                            break;

                        case OperationType.Goto:
                            TweenManager.Goto(tween, optionalFloat, optionalBool, UpdateMode.Goto);
                            num++;
                            break;

                        case OperationType.Pause:
                            if (TweenManager.Pause(tween))
                            {
                                num++;
                            }
                            break;

                        case OperationType.Play:
                            if (TweenManager.Play(tween))
                            {
                                num++;
                            }
                            break;

                        case OperationType.PlayBackwards:
                            if (TweenManager.PlayBackwards(tween))
                            {
                                num++;
                            }
                            break;

                        case OperationType.PlayForward:
                            if (TweenManager.PlayForward(tween))
                            {
                                num++;
                            }
                            break;

                        case OperationType.Restart:
                            if (TweenManager.Restart(tween, optionalBool))
                            {
                                num++;
                            }
                            break;

                        case OperationType.Rewind:
                            if (TweenManager.Rewind(tween, optionalBool))
                            {
                                num++;
                            }
                            break;

                        case OperationType.SmoothRewind:
                            if (TweenManager.SmoothRewind(tween))
                            {
                                num++;
                            }
                            break;

                        case OperationType.TogglePause:
                            if (TweenManager.TogglePause(tween))
                            {
                                num++;
                            }
                            break;

                        case OperationType.IsTweening:
                            if (tween.isComplete && tween.autoKill)
                            {
                                break;
                            }
                            num++;
                            break;
                        }
                    }
                }
            }
            if (flag)
            {
                for (int num5 = TweenManager._KillList.Count - 1; num5 > -1; num5--)
                {
                    TweenManager.RemoveActiveTween(TweenManager._KillList[num5]);
                }
                TweenManager._KillList.Clear();
            }
            return(num);
        }
Beispiel #10
0
        internal static void Update(UpdateType updateType, float deltaTime, float independentTime)
        {
            if (TweenManager._requiresActiveReorganization)
            {
                TweenManager.ReorganizeActiveTweens();
            }
            TweenManager.isUpdateLoop = true;
            bool flag = false;
            int  num  = TweenManager._maxActiveLookupId + 1;

            for (int i = 0; i < num; i++)
            {
                Tween tween = TweenManager._activeTweens[i];
                float num2;
                if (tween != null && tween.updateType == updateType)
                {
                    if (!tween.active)
                    {
                        flag = true;
                        TweenManager.MarkForKilling(tween);
                    }
                    else if (tween.isPlaying)
                    {
                        tween.creationLocked = true;
                        num2 = (tween.isIndependentUpdate ? independentTime : deltaTime) * tween.timeScale;
                        if (!tween.delayComplete)
                        {
                            num2 = tween.UpdateDelay(tween.elapsedDelay + num2);
                            if (num2 <= -1f)
                            {
                                flag = true;
                                TweenManager.MarkForKilling(tween);
                            }
                            else if (!(num2 <= 0f))
                            {
                                if (tween.playedOnce && tween.onPlay != null)
                                {
                                    Tween.OnTweenCallback(tween.onPlay);
                                }
                                goto IL_00d0;
                            }
                            continue;
                        }
                        goto IL_00d0;
                    }
                }
                continue;
IL_00d0:
                if (!tween.startupDone && !tween.Startup())
                {
                    flag = true;
                    TweenManager.MarkForKilling(tween);
                }
                else
                {
                    float position = tween.position;
                    bool  flag2    = position >= tween.duration;
                    int   num3     = tween.completedLoops;
                    if (tween.duration <= 0f)
                    {
                        position = 0f;
                        num3     = ((tween.loops == -1) ? (tween.completedLoops + 1) : tween.loops);
                    }
                    else
                    {
                        if (tween.isBackwards)
                        {
                            position -= num2;
                            while (position < 0f && num3 > 0)
                            {
                                position += tween.duration;
                                num3--;
                            }
                        }
                        else
                        {
                            position += num2;
                            while (true)
                            {
                                if (!(position >= tween.duration))
                                {
                                    break;
                                }
                                if (tween.loops != -1 && num3 >= tween.loops)
                                {
                                    break;
                                }
                                position -= tween.duration;
                                num3++;
                            }
                        }
                        if (flag2)
                        {
                            num3--;
                        }
                        if (tween.loops != -1 && num3 >= tween.loops)
                        {
                            position = tween.duration;
                        }
                    }
                    if (Tween.DoGoto(tween, position, num3, UpdateMode.Update))
                    {
                        flag = true;
                        TweenManager.MarkForKilling(tween);
                    }
                }
            }
            if (flag)
            {
                if (TweenManager._despawnAllCalledFromUpdateLoopCallback)
                {
                    TweenManager._despawnAllCalledFromUpdateLoopCallback = false;
                }
                else
                {
                    TweenManager.DespawnTweens(TweenManager._KillList, false);
                    for (int num4 = TweenManager._KillList.Count - 1; num4 > -1; num4--)
                    {
                        TweenManager.RemoveActiveTween(TweenManager._KillList[num4]);
                    }
                }
                TweenManager._KillList.Clear();
            }
            TweenManager.isUpdateLoop = false;
        }