private static IEnumerator SelfDestroy(CoroutineRegularUpdater cru) { yield return(null); cru.gameObject.SetActive(false); yield return(null); }
private static IEnumerator SelfDestroy2(CoroutineRegularUpdater cru) { yield return(null); cru.gameObject.SetActive(false); // ReSharper disable once RedundantJumpStatement yield break; }
/// <summary> /// Outer waiter-- Will cb if cancelled /// </summary> public static void WaitThenCBEvenIfCancelled(CoroutineRegularUpdater Exec, ICancellee cT, float time, bool zeroToInfinity, Action cb) { cT.ThrowIfCancelled(); if (zeroToInfinity && time < float.Epsilon) { time = float.MaxValue; } Exec.RunRIEnumerator(WaitFor(time, cT, cb)); }
/// <summary> /// Outer waiter-- Will not cb if cancelled /// </summary> public static void WaitThenCB(CoroutineRegularUpdater Exec, ICancellee cT, float time, Func <bool> condition, Action cb) { cT.ThrowIfCancelled(); Exec.RunRIEnumerator(WaitForBoth(time, condition, cT, () => { if (!cT.Cancelled) { cb(); } })); }
/// <summary> /// Task style. Will return as soon as the time is up or cancellation is triggered. /// You must check cT.IsCancelled after awaiting this. /// </summary> /// <returns></returns> public static Task WaitForUnchecked(CoroutineRegularUpdater Exec, ICancellee cT, float time, bool zeroToInfinity) { cT.ThrowIfCancelled(); if (zeroToInfinity && time < float.Epsilon) { time = float.MaxValue; } if (time < float.Epsilon) { return(Task.CompletedTask); } Exec.RunRIEnumerator(WaitFor(time, cT, GetAwaiter(out Task t))); return(t); }
/// <summary> /// Outer waiter-- Will not cancel if cancelled /// </summary> public static void WaitThenCancel(CoroutineRegularUpdater Exec, ICancellee cT, float time, bool zeroToInfinity, Cancellable toCancel) { cT.ThrowIfCancelled(); if (zeroToInfinity && time < float.Epsilon) { time = float.MaxValue; } Exec.RunRIEnumerator(WaitFor(time, cT, () => { if (!cT.Cancelled) { toCancel.Cancel(); } })); }
private void Awake() { Main = this; }
/// <summary> /// Task style. Will return as soon as the condition is satisfied or cancellation is triggered. /// You must check cT.IsCancelled after awaiting this. /// </summary> /// <returns></returns> public static Task WaitForUnchecked(CoroutineRegularUpdater Exec, ICancellee cT, Func <bool> condition) { cT.ThrowIfCancelled(); Exec.RunRIEnumerator(WaitFor(condition, cT, GetAwaiter(out Task t))); return(t); }