private void OnCoroutineFinished(RocCoroutine coroutine, bool isStopped) { if (ActiveCoroutines.Contains(coroutine.Key)) { ActiveCoroutines.Remove(coroutine.Key); } }
private static void StartCoroutine(string key, IEnumerator iEnumerator, Action <bool> onFinished = null) { Log.Debug("Coroutine will be started. Key: " + key); RocCoroutine coroutine = new RocCoroutine(key, iEnumerator, onFinished); coroutine.Finished += OnCoroutineFinished; coroutine.Start(); Coroutines.Add(key, coroutine); if (CoroutineStarted != null) { CoroutineStarted(coroutine); } }
/// <summary> /// Stops coroutine started with a key /// </summary> public static void StopCoroutine(string key) { if (!Coroutines.ContainsKey(key)) { Log.Error("Coroutine does NOT exist! Key: " + key); return; } RocCoroutine targetCoroutine = Coroutines[key]; targetCoroutine.Stop(); Coroutines.Remove(key); if (CoroutineFinished != null) { CoroutineFinished(targetCoroutine, true); } Log.Debug("Coroutine is STOPPED! Key: " + key); }
private static void OnCoroutineFinished(RocCoroutine rocCoroutine, bool isStopped) { rocCoroutine.Finished -= OnCoroutineFinished; if (isStopped) { return; } //Coroutine died by itself! if (!Coroutines.ContainsKey(rocCoroutine.Key)) { Log.Error("Coroutine does NOT exist! Key: " + rocCoroutine.Key); return; } Coroutines.Remove(rocCoroutine.Key); if (CoroutineFinished != null) { CoroutineFinished(rocCoroutine, false); } }
private void OnCoroutineStarted(RocCoroutine coroutine) { ActiveCoroutines.Add(coroutine.Key); }