/// <summary> Yield or start coroutine to play the branch </summary> private IEnumerator PlayBranchRoutine() { IsRunning = true; BranchSucceed = false; _currentTask = _root; while (_currentTask != null) { yield return(_currentTask.StartTask()); if (_currentTask.Succeed) { var newOut = _currentTask.GetCurrentOut(); var next = _currentTask.GetConnectionSafe(newOut); if (next == null) { BranchSucceed = true; break; } _currentTask = next; } else { BranchSucceed = false; break; } } IsRunning = false; }
internal BranchPlayer(BehaviourTask root) { if (root == null) { throw new System.NullReferenceException("BranchPlayer root task must not be null"); } _root = root; _coroutineRunner = _root.CoroutineRunner; }