Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.75 KB | None | 0 0
  1. internal static bool DoGoto(Tween t, float toPosition, int toCompletedLoops, UpdateMode updateMode)
  2. {
  3.     if (!t.startupDone && !t.Startup())
  4.     {
  5.         return true;
  6.     }
  7.     if (!t.playedOnce && updateMode == UpdateMode.Update)
  8.     {
  9.         t.playedOnce = true;
  10.         if (t.onStart != null)
  11.         {
  12.             Tween.OnTweenCallback(t.onStart);
  13.             if (!t.active)
  14.             {
  15.                 return true;
  16.             }
  17.         }
  18.         if (t.onPlay != null)
  19.         {
  20.             Tween.OnTweenCallback(t.onPlay);
  21.             if (!t.active)
  22.             {
  23.                 return true;
  24.             }
  25.         }
  26.     }
  27.     float prevPosition = t.position;
  28.     int num = t.completedLoops;
  29.     t.completedLoops = toCompletedLoops;
  30.     bool flag = t.position <= 0f && num <= 0;
  31.     bool flag2 = t.isComplete;
  32.     if (t.loops != -1)
  33.     {
  34.         t.isComplete = (t.completedLoops == t.loops);
  35.     }
  36.     int num2 = 0;
  37.     if (updateMode == UpdateMode.Update)
  38.     {
  39.         if (t.isBackwards)
  40.         {
  41.             num2 = ((t.completedLoops < num) ? (num - t.completedLoops) : ((toPosition <= 0f && !flag) ? 1 : 0));
  42.             if (flag2)
  43.             {
  44.                 num2--;
  45.             }
  46.         }
  47.         else
  48.         {
  49.             num2 = ((t.completedLoops > num) ? (t.completedLoops - num) : 0);
  50.         }
  51.     }
  52.     else if (t.tweenType == TweenType.Sequence)
  53.     {
  54.         num2 = num - toCompletedLoops;
  55.         if (num2 < 0)
  56.         {
  57.             num2 = -num2;
  58.         }
  59.     }
  60.     t.position = toPosition;
  61.     if (t.position > t.duration)
  62.     {
  63.         t.position = t.duration;
  64.     }
  65.     else if (t.position <= 0f)
  66.     {
  67.         if (t.completedLoops > 0 || t.isComplete)
  68.         {
  69.             t.position = t.duration;
  70.         }
  71.         else
  72.         {
  73.             t.position = 0f;
  74.         }
  75.     }
  76.     bool flag3 = t.isPlaying;
  77.     if (t.isPlaying)
  78.     {
  79.         if (!t.isBackwards)
  80.         {
  81.             t.isPlaying = !t.isComplete;
  82.         }
  83.         else
  84.         {
  85.             t.isPlaying = (t.completedLoops != 0 || t.position > 0f);
  86.         }
  87.     }
  88.     bool useInversePosition = t.loopType == LoopType.Yoyo && ((t.position < t.duration) ? (t.completedLoops % 2 != 0) : (t.completedLoops % 2 == 0));
  89.     UpdateNotice updateNotice = (!flag && ((t.loopType == LoopType.Restart && t.completedLoops != num) || (t.position <= 0f && t.completedLoops <= 0))) ? UpdateNotice.RewindStep : UpdateNotice.None;
  90.     if (t.ApplyTween(prevPosition, num, num2, useInversePosition, updateMode, updateNotice))
  91.     {
  92.         return true;
  93.     }
  94.     if (t.onUpdate != null && updateMode != UpdateMode.IgnoreOnUpdate)
  95.     {
  96.         Tween.OnTweenCallback(t.onUpdate);
  97.     }
  98.     if (t.position <= 0f && t.completedLoops <= 0 && !flag && t.onRewind != null)
  99.     {
  100.         Tween.OnTweenCallback(t.onRewind);
  101.     }
  102.     if (num2 > 0 && updateMode == UpdateMode.Update && t.onStepComplete != null)
  103.     {
  104.         for (int i = 0; i < num2; i++)
  105.         {
  106.             Tween.OnTweenCallback(t.onStepComplete);
  107.         }
  108.     }
  109.     if (t.isComplete && !flag2 && t.onComplete != null)
  110.     {
  111.         Tween.OnTweenCallback(t.onComplete);
  112.     }
  113.     if ((!t.isPlaying & flag3) && (!t.isComplete || !t.autoKill) && t.onPause != null)
  114.     {
  115.         Tween.OnTweenCallback(t.onPause);
  116.     }
  117.     return t.autoKill && t.isComplete;
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement