public bool Evaluate() { try { // if cancelled, throw exception cancellationToken.ThrowIfCancellationRequested(); // if owner is destroyed, behaves like a UnityEngine.Coroutine, ie: // "With this object's death, the thread of prophecy is severed. Restore a saved game to restore the // weave of fate, or persist in the doomed world you have created." if (!owner.IsAlive()) { return(true); } // if not completed, return false to put it back into a queue for next frame if (!instruction.IsCompleted()) { return(false); } } catch (Exception e) { // store exception in static field exception = e; // exception is rethrown in GetResult, at start of continuation continuation(); return(true); } // if we get here, it completed without exceptions and we can call continuation and be done with it continuation(); return(true); }