Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement