void Update(float deltaTime) { bool isBreak = false; // 如果不处于等待状态则前往下一个中断点 if (!isWaiting) { while (!Enumerator.MoveNext()) { if (Storages.Count > 0) { Enumerator = Storages.Pop(); } else { isBreak = true; break; } } } if (isBreak) { Coroutiner.Stop(this); return; } object current = Enumerator.Current; // 当中断点为空时跳过一帧 if (current == null) { return; } // 如果当前对象为指定中断指令 IInterruptInstruction yieldInstruction = current as IInterruptInstruction; if (yieldInstruction != null) { isWaiting = yieldInstruction.Await(deltaTime); return; } // 如果当前对象为新迭代器 IEnumerator enumerator = current as IEnumerator; if (enumerator != null) { if (Storages.Count > 100) { App.Warning("警告: 迭代器堆栈存放数据过大[{0}]", Storages.Count); } Storages.Push(Enumerator); // 保存现有迭代器 Enumerator = enumerator; return; } }
public void Setup(Coroutiner coroutineer) { Coroutiner = coroutineer; }