/// <summary> /// Check if the current instruction is another list of instructions, if so add it to /// <see cref="RecursiveInstructions" /> /// </summary> private void CheckForInstructionRecursion() { var enumeratorInstruction = CurrentInstructions.Current as IEnumerator; if (enumeratorInstruction == null) { var coroutineInstruction = CurrentInstructions.Current as Coroutine; enumeratorInstruction = coroutineInstruction?.CurrentInstructions; if (enumeratorInstruction == null) { return; } } RecursiveInstructions.AddLast(enumeratorInstruction); CurrentInstructions = enumeratorInstruction; }
/// <summary> /// Update the current recursive instructions and set it null if there are none left /// </summary> /// <returns>True if we have anymore instructions</returns> private bool UpdateCurrentInstructions() { RecursiveInstructions.RemoveLast(); CurrentInstructions = RecursiveInstructions.Last?.Value; return(true); }