internal void recycle() { isDone = true; waitTimer = 0; waitForCoroutine = null; enumerator = null; }
void IPoolable.reset() { isDone = true; waitTimer = 0; waitForCoroutine = null; enumerator = null; }
void IPoolable.Reset() { IsDone = true; WaitTimer = 0; WaitForCoroutine = null; Enumerator = null; UseUnscaledDeltaTime = false; }
void IPoolable.reset() { isDone = true; waitTimer = 0; waitForCoroutine = null; enumerator = null; useUnscaledDeltaTime = false; }
/// <summary> /// ticks a coroutine. returns true if the coroutine should continue to run next frame. This method will put finished coroutines /// back in the Pool! /// </summary> /// <returns><c>true</c>, if coroutine was ticked, <c>false</c> otherwise.</returns> /// <param name="coroutine">Coroutine.</param> bool TickCoroutine(CoroutineImpl coroutine) { // This coroutine has finished if (!coroutine.Enumerator.MoveNext() || coroutine.IsDone) { Pool <CoroutineImpl> .Free(coroutine); return(false); } if (coroutine.Enumerator.Current == null) { // yielded null. run again next frame return(true); } if (coroutine.Enumerator.Current is WaitForSeconds) { coroutine.WaitTimer = (coroutine.Enumerator.Current as WaitForSeconds).waitTime; return(true); } if (coroutine.Enumerator.Current is IEnumerator enumerator) { coroutine.WaitForCoroutine = StartCoroutine(enumerator) as CoroutineImpl; return(true); } #if DEBUG // deprecation warning for yielding an int/float if (coroutine.Enumerator.Current is int) { Debug.Error( "yield Coroutine.waitForSeconds instead of an int. Yielding an int will not work in a release build."); coroutine.WaitTimer = (int)coroutine.Enumerator.Current; return(true); } if (coroutine.Enumerator.Current is float) { Debug.Error( "yield Coroutine.waitForSeconds instead of a float. Yielding a float will not work in a release build."); coroutine.WaitTimer = (float)coroutine.Enumerator.Current; return(true); } #endif if (coroutine.Enumerator.Current is CoroutineImpl) { coroutine.WaitForCoroutine = coroutine.Enumerator.Current as CoroutineImpl; return(true); } else { // This coroutine yielded some value we don't understand. run it next frame. return(true); } }
/// <summary> /// ticks a coroutine. returns true if the coroutine should continue to run next frame. This method will put finished coroutines /// back in the Pool! /// </summary> /// <returns><c>true</c>, if coroutine was ticked, <c>false</c> otherwise.</returns> /// <param name="coroutine">Coroutine.</param> bool tickCoroutine(CoroutineImpl coroutine) { // This coroutine has finished if (!coroutine.enumerator.MoveNext() || coroutine.isDone) { Pool <CoroutineImpl> .free(coroutine); return(false); } if (coroutine.isDone) { Debug.break_(); } if (coroutine.enumerator.Current == null) { // yielded null. run again next frame return(true); } else if (coroutine.enumerator.Current is int) { var wait = (int)coroutine.enumerator.Current; coroutine.waitTimer = wait; return(true); } else if (coroutine.enumerator.Current is float) { var wait = (float)coroutine.enumerator.Current; coroutine.waitTimer = wait; return(true); } else if (coroutine.enumerator.Current is CoroutineImpl) { coroutine.waitForCoroutine = coroutine.enumerator.Current as CoroutineImpl; return(true); } else { // This coroutine yielded null, or some other value we don't understand. run it next frame. return(true); } }
/// <summary> /// ticks a coroutine. returns true if the coroutine should continue to run next frame. This method will put finished coroutines /// back in the Pool! /// </summary> /// <returns><c>true</c>, if coroutine was ticked, <c>false</c> otherwise.</returns> /// <param name="coroutine">Coroutine.</param> bool tickCoroutine( CoroutineImpl coroutine ) { // This coroutine has finished if( !coroutine.enumerator.MoveNext() || coroutine.isDone ) { Pool<CoroutineImpl>.free( coroutine ); return false; } if( coroutine.enumerator.Current == null ) { // yielded null. run again next frame return true; } if( coroutine.enumerator.Current is WaitForSeconds ) { coroutine.waitTimer = ( coroutine.enumerator.Current as WaitForSeconds ).waitTime; return true; } #if DEBUG // deprecation warning for yielding an int/float if( coroutine.enumerator.Current is int ) { Debug.error( "yield Coroutine.waitForSeconds instead of an int. Yielding an int will not work in a release build." ); coroutine.waitTimer = (int)coroutine.enumerator.Current; return true; } if( coroutine.enumerator.Current is float ) { Debug.error( "yield Coroutine.waitForSeconds instead of a float. Yielding a float will not work in a release build." ); coroutine.waitTimer = (float)coroutine.enumerator.Current; return true; } #endif if( coroutine.enumerator.Current is CoroutineImpl ) { coroutine.waitForCoroutine = coroutine.enumerator.Current as CoroutineImpl; return true; } else { // This coroutine yielded some value we don't understand. run it next frame. return true; } }