using System; using System.Collections; using UnityEngine; namespace SUISSEngine { [Obsolete] public class UnityCoroutineTask : ICoroutineTask { public UnityCoroutineTask(IEnumerator coroutine, MonoBehaviour runner) { this._coroutine = coroutine; this._running = true; this._isDone = false; this._unityCoroutine = runner.StartCoroutine(this.InternalRoutine()); } public void CheckForException() { if (this._exception != null) { throw this._exception; } } public void Stop() { this._running = false; } public bool Running { get { return this._running; } } public bool IsDone { get { return this._isDone; } } public object YieldUntilDone() { return this._unityCoroutine; } private IEnumerator InternalRoutine() { while (this._running) { try { if (!this._coroutine.MoveNext()) { this._running = false; this._isDone = true; yield break; } } catch (Exception exception) { this._exception = exception; this._running = false; this._isDone = true; yield break; } yield return this._coroutine.Current; } yield break; } private bool _running; private bool _isDone; private Exception _exception; private IEnumerator _coroutine; private Coroutine _unityCoroutine; } }