public static bool Rewind(Tween t, bool includeDelay = true) { bool isPlaying = t.isPlaying; t.isPlaying = false; bool result = false; if (t.delay > 0f) { if (includeDelay) { result = (t.delay > 0f && t.elapsedDelay > 0f); t.elapsedDelay = 0f; t.delayComplete = false; } else { result = (t.elapsedDelay < t.delay); t.elapsedDelay = t.delay; t.delayComplete = true; } } if (t.position > 0f || t.completedLoops > 0 || !t.startupDone) { result = true; if (!Tween.DoGoto(t, 0f, 0, UpdateMode.Goto) && isPlaying && t.onPause != null) { Tween.OnTweenCallback(t.onPause); } } return(result); }
public static bool Complete(Tween t, bool modifyActiveLists = true) { if (t.loops == -1) { return(false); } if (!t.isComplete) { Tween.DoGoto(t, t.duration, t.loops, UpdateMode.Goto); t.isPlaying = false; if (t.autoKill) { if (TweenManager.isUpdateLoop) { t.active = false; } else { TweenManager.Despawn(t, modifyActiveLists); } } return(true); } return(false); }
public static bool Goto(Tween t, float to, bool andPlay = false, UpdateMode updateMode = UpdateMode.Goto) { bool isPlaying = t.isPlaying; t.isPlaying = andPlay; t.delayComplete = true; t.elapsedDelay = t.delay; int num = Mathf.FloorToInt(to / t.duration); float num2 = to % t.duration; if (t.loops != -1 && num >= t.loops) { num = t.loops; num2 = t.duration; } else if (num2 >= t.duration) { num2 = 0f; } bool flag = Tween.DoGoto(t, num2, num, updateMode); if (!andPlay && isPlaying && !flag && t.onPause != null) { Tween.OnTweenCallback(t.onPause); } return(flag); }
internal static bool Rewind(Tween t, bool includeDelay = true) { bool wasPlaying = t.isPlaying; // Manage onPause from this method because DoGoto won't detect it t.isPlaying = false; bool rewinded = false; if (t.delay > 0) { if (includeDelay) { rewinded = t.delay > 0 && t.elapsedDelay > 0; t.elapsedDelay = 0; t.delayComplete = false; } else { rewinded = t.elapsedDelay < t.delay; t.elapsedDelay = t.delay; t.delayComplete = true; } } if (t.position > 0 || t.completedLoops > 0 || !t.startupDone) { rewinded = true; bool needsKilling = Tween.DoGoto(t, 0, 0, UpdateMode.Goto); if (!needsKilling && wasPlaying && t.onPause != null) { Tween.OnTweenCallback(t.onPause); } } return(rewinded); }
internal static bool Complete(Tween t, bool modifyActiveLists = true, UpdateMode updateMode = UpdateMode.Goto) { if (t.loops == -1) { return(false); } if (!t.isComplete) { Tween.DoGoto(t, t.duration, t.loops, updateMode); t.isPlaying = false; // Despawn if needed if (t.autoKill) { if (isUpdateLoop) { t.active = false; // Just mark it for killing, so the update loop will take care of it } else { Despawn(t, modifyActiveLists); } } return(true); } return(false); }
// Returns TRUE if there was an error and the tween needs to be destroyed internal static bool Goto(Tween t, float to, bool andPlay = false, UpdateMode updateMode = UpdateMode.Goto) { bool wasPlaying = t.isPlaying; t.isPlaying = andPlay; t.delayComplete = true; t.elapsedDelay = t.delay; // int toCompletedLoops = (int)(to / t.duration); // With very small floats creates floating points imprecisions int toCompletedLoops = Mathf.FloorToInt(to / t.duration); // Still generates imprecision with some values (like 0.4) // int toCompletedLoops = (int)((decimal)to / (decimal)t.duration); // Takes care of floating points imprecision (nahh doesn't work correctly either) float toPosition = to % t.duration; if (t.loops != -1 && toCompletedLoops >= t.loops) { toCompletedLoops = t.loops; toPosition = t.duration; } else if (toPosition >= t.duration) { toPosition = 0; } // If andPlay is FALSE manage onPause from here because DoGoto won't detect it (since t.isPlaying was already set from here) bool needsKilling = Tween.DoGoto(t, toPosition, toCompletedLoops, updateMode); if (!andPlay && wasPlaying && !needsKilling && t.onPause != null) { Tween.OnTweenCallback(t.onPause); } return(needsKilling); }
// Returns TRUE if there was an error and the tween needs to be destroyed internal static bool Goto(Tween t, float to, bool andPlay = false, UpdateMode updateMode = UpdateMode.Goto) { bool wasPlaying = t.isPlaying; t.isPlaying = andPlay; t.delayComplete = true; t.elapsedDelay = t.delay; int toCompletedLoops = (int)(to / t.duration); float toPosition = to % t.duration; if (t.loops != -1 && toCompletedLoops >= t.loops) { toCompletedLoops = t.loops; toPosition = t.duration; } else if (toPosition >= t.duration) { toPosition = 0; } // If andPlay is FALSE manage onPause from here because DoGoto won't detect it (since t.isPlaying was already set from here) bool needsKilling = Tween.DoGoto(t, toPosition, toCompletedLoops, updateMode); if (!andPlay && wasPlaying && !needsKilling && t.onPause != null) { Tween.OnTweenCallback(t.onPause); } return(needsKilling); }
public static bool Rewind(Tween t, bool includeDelay = true) { bool isPlaying = t.isPlaying; t.isPlaying = false; bool flag2 = false; if (t.delay > 0f) { if (includeDelay) { flag2 = (t.delay > 0f) && (t.elapsedDelay > 0f); t.elapsedDelay = 0f; t.delayComplete = false; } else { flag2 = t.elapsedDelay < t.delay; t.elapsedDelay = t.delay; t.delayComplete = true; } } if (((t.position > 0f) || (t.completedLoops > 0)) || !t.startupDone) { flag2 = true; if ((!Tween.DoGoto(t, 0f, 0, UpdateMode.Goto) & isPlaying) && (t.onPause != null)) { Tween.OnTweenCallback(t.onPause); } } return(flag2); }
public static bool Goto(Tween t, float to, bool andPlay = false, UpdateMode updateMode = UpdateMode.Goto) { bool isPlaying = t.isPlaying; t.isPlaying = andPlay; t.delayComplete = true; t.elapsedDelay = t.delay; int toCompletedLoops = Mathf.FloorToInt(to / t.duration); float toPosition = to % t.duration; if ((t.loops != -1) && (toCompletedLoops >= t.loops)) { toCompletedLoops = t.loops; toPosition = t.duration; } else if (toPosition >= t.duration) { toPosition = 0f; } bool flag2 = Tween.DoGoto(t, toPosition, toCompletedLoops, updateMode); if (((!andPlay & isPlaying) && !flag2) && (t.onPause != null)) { Tween.OnTweenCallback(t.onPause); } return(flag2); }
internal static bool Rewind(Tween t, bool includeDelay = true) { t.isPlaying = false; bool rewinded = false; if (t.delay > 0) { if (includeDelay) { rewinded = t.delay > 0 && t.elapsedDelay > 0; t.elapsedDelay = 0; t.delayComplete = false; } else { rewinded = t.elapsedDelay < t.delay; t.elapsedDelay = t.delay; t.delayComplete = true; } } if (t.position > 0 || t.completedLoops > 0 || !t.startupDone) { rewinded = true; Tween.DoGoto(t, 0, 0, UpdateMode.Goto); } return(rewinded); }
// Returns TRUE if there was an error and the tween needs to be destroyed internal static bool Goto(Tween t, float to, bool andPlay = false, UpdateMode updateMode = UpdateMode.Goto) { t.isPlaying = andPlay; t.delayComplete = true; t.elapsedDelay = t.delay; int toCompletedLoops = (int)(to / t.duration); float toPosition = to % t.duration; if (t.loops != -1 && toCompletedLoops >= t.loops) { toCompletedLoops = t.loops; toPosition = t.duration; } else if (toPosition >= t.duration) { toPosition = 0; } return(Tween.DoGoto(t, toPosition, toCompletedLoops, updateMode)); }
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; }
// deltaTime will be passed as fixedDeltaTime in case of UpdateType.Fixed internal static void Update(UpdateType updateType, float deltaTime, float independentTime) { if (_requiresActiveReorganization) { ReorganizeActiveTweens(); } isUpdateLoop = true; #if DEBUG updateLoopCount++; VerifyActiveTweensList(); #endif bool willKill = false; // Debug.Log("::::::::::: " + updateType + " > " + (_maxActiveLookupId + 1)); int len = _maxActiveLookupId + 1; // Stored here so if _maxActiveLookupId changed during update loop (like if new tween is created at onComplete) new tweens are still ignored for (int i = 0; i < len; ++i) { Tween t = _activeTweens[i]; if (t == null || t.updateType != updateType) { continue; // Wrong updateType or was added to a Sequence (thus removed from active list) while inside current updateLoop } if (!t.active) { // Manually killed by another tween's callback willKill = true; MarkForKilling(t); continue; } if (!t.isPlaying) { continue; } t.creationLocked = true; // Lock tween creation methods from now on float tDeltaTime = (t.isIndependentUpdate ? independentTime : deltaTime) * t.timeScale; if (!t.delayComplete) { tDeltaTime = t.UpdateDelay(t.elapsedDelay + tDeltaTime); if (tDeltaTime <= -1) { // Error during startup (can happen with FROM tweens): mark tween for killing willKill = true; MarkForKilling(t); continue; } if (tDeltaTime <= 0) { continue; } // Delay elapsed - call OnPlay if required if (t.playedOnce && t.onPlay != null) { // Don't call in case it hasn't started because onStart routine will call it Tween.OnTweenCallback(t.onPlay); } } // Startup (needs to be here other than in Tween.DoGoto in case of speed-based tweens, to calculate duration correctly) if (!t.startupDone) { if (!t.Startup()) { // Startup failure: mark for killing willKill = true; MarkForKilling(t); continue; } } // Find update data float toPosition = t.position; bool wasEndPosition = toPosition >= t.duration; int toCompletedLoops = t.completedLoops; if (t.duration <= 0) { toPosition = 0; toCompletedLoops = t.loops == -1 ? t.completedLoops + 1 : t.loops; } else { if (t.isBackwards) { toPosition -= tDeltaTime; while (toPosition < 0 && toCompletedLoops > -1) { toPosition += t.duration; toCompletedLoops--; } if (toCompletedLoops < 0 || wasEndPosition && toCompletedLoops < 1) { // Result is equivalent to a rewind, so set values according to it toPosition = 0; toCompletedLoops = wasEndPosition ? 1 : 0; } // while (toPosition < 0 && toCompletedLoops > 0) { // toPosition += t.duration; // toCompletedLoops--; // } // if (wasEndPosition && toCompletedLoops <= 0) { // // Force-rewind // Rewind(t, false); // continue; // } } else { toPosition += tDeltaTime; while (toPosition >= t.duration && (t.loops == -1 || toCompletedLoops < t.loops)) { toPosition -= t.duration; toCompletedLoops++; } } if (wasEndPosition) { toCompletedLoops--; } if (t.loops != -1 && toCompletedLoops >= t.loops) { toPosition = t.duration; } } // Goto bool needsKilling = Tween.DoGoto(t, toPosition, toCompletedLoops, UpdateMode.Update); if (needsKilling) { willKill = true; MarkForKilling(t); } } // Kill all eventually marked tweens if (willKill) { if (_despawnAllCalledFromUpdateLoopCallback) { // Do not despawn tweens again, since Kill/DespawnAll was already called _despawnAllCalledFromUpdateLoopCallback = false; } else { DespawnActiveTweens(_KillList); } _KillList.Clear(); } isUpdateLoop = false; }
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; }
// deltaTime will be passed as fixedDeltaTime in case of UpdateType.Fixed internal static void Update(UpdateType updateType, float deltaTime, float independentTime) { if (_requiresActiveReorganization) { ReorganizeActiveTweens(); } isUpdateLoop = true; #if DEBUG updateLoopCount++; VerifyActiveTweensList(); #endif bool willKill = false; // Debug.Log("::::::::::: " + updateType + " > " + (_maxActiveLookupId + 1)); for (int i = 0; i < _maxActiveLookupId + 1; ++i) { Tween t = _activeTweens[i]; if (t == null || t.updateType != updateType) { continue; // Wrong updateType or was added to a Sequence (thus removed from active list) while inside current updateLoop } if (!t.active) { // Manually killed by another tween's callback willKill = true; MarkForKilling(t); continue; } if (!t.isPlaying) { continue; } t.creationLocked = true; // Lock tween creation methods from now on float tDeltaTime = (t.isIndependentUpdate ? independentTime : deltaTime) * t.timeScale; if (!t.delayComplete) { tDeltaTime = t.UpdateDelay(t.elapsedDelay + tDeltaTime); if (tDeltaTime <= -1) { // Error during startup (can happen with FROM tweens): mark tween for killing willKill = true; MarkForKilling(t); continue; } if (tDeltaTime <= 0) { continue; } } // Find update data float toPosition = t.position; bool wasEndPosition = toPosition >= t.duration; int toCompletedLoops = t.completedLoops; if (t.duration <= 0) { toPosition = 0; toCompletedLoops = t.loops == -1 ? t.completedLoops + 1 : t.loops; } else { if (t.isBackwards) { toPosition -= tDeltaTime; while (toPosition < 0 && toCompletedLoops > 0) { toPosition += t.duration; toCompletedLoops--; } } else { toPosition += tDeltaTime; while (toPosition > t.duration && (t.loops == -1 || toCompletedLoops < t.loops)) { toPosition -= t.duration; toCompletedLoops++; } } if (wasEndPosition) { toCompletedLoops--; } if (t.loops != -1 && toCompletedLoops >= t.loops) { toPosition = t.duration; } } // Goto bool needsKilling = Tween.DoGoto(t, toPosition, toCompletedLoops, UpdateMode.Update); if (needsKilling) { willKill = true; MarkForKilling(t); } } // Kill all eventually marked tweens if (willKill) { DespawnTweens(_KillList, false); int count = _KillList.Count - 1; for (int i = count; i > -1; --i) { RemoveActiveTween(_KillList[i]); } _KillList.Clear(); } isUpdateLoop = false; }
public static void Update(UpdateType updateType, float deltaTime, float independentTime) { if (_requiresActiveReorganization) { ReorganizeActiveTweens(); } isUpdateLoop = true; bool flag = false; int num = _maxActiveLookupId + 1; for (int i = 0; i < num; i++) { Tween t = _activeTweens[i]; if ((t != null) && (t.updateType == updateType)) { if (!t.active) { flag = true; MarkForKilling(t); } else if (t.isPlaying) { t.creationLocked = true; float num3 = (t.isIndependentUpdate ? independentTime : deltaTime) * t.timeScale; if (!t.delayComplete) { num3 = t.UpdateDelay(t.elapsedDelay + num3); if (num3 <= -1f) { flag = true; MarkForKilling(t); continue; } if (num3 <= 0f) { continue; } } if (!t.startupDone && !t.Startup()) { flag = true; MarkForKilling(t); } else { float position = t.position; bool flag2 = position >= t.duration; int completedLoops = t.completedLoops; if (t.duration <= 0f) { position = 0f; completedLoops = (t.loops == -1) ? (t.completedLoops + 1) : t.loops; } else { if (t.isBackwards) { position -= num3; while ((position < 0f) && (completedLoops > 0)) { position += t.duration; completedLoops--; } } else { position += num3; while ((position >= t.duration) && ((t.loops == -1) || (completedLoops < t.loops))) { position -= t.duration; completedLoops++; } } if (flag2) { completedLoops--; } if ((t.loops != -1) && (completedLoops >= t.loops)) { position = t.duration; } } if (Tween.DoGoto(t, position, completedLoops, UpdateMode.Update)) { flag = true; MarkForKilling(t); } } } } } if (flag) { DespawnTweens(_KillList, false); for (int j = _KillList.Count - 1; j > -1; j--) { RemoveActiveTween(_KillList[j]); } _KillList.Clear(); } isUpdateLoop = false; }