protected override IEnumerator process(BehaviourTreeAgent agent) { BehaviourTreeNodeState myState = stateForAgent(agent); foreach (ConnectionPort knob in outputPorts) { if (knob.connected()) { BehaviourTreeNode node = knob.connection(0).body as BehaviourTreeNode; BehaviourTreeNodeState childState = node.stateForAgent(agent); yield return(agent.StartCoroutine(node.routine(childState))); if (childState.actualCondition == processCondition.Sucess) { myState.actualCondition = processCondition.Sucess; } if (myState.actualCondition == processCondition.Sucess) { yield break; } } } if (myState.actualCondition == processCondition.Running) { myState.actualCondition = processCondition.Failure; } }
protected override IEnumerator process(BehaviourTreeAgent agent) { BehaviourTreeNodeState state = stateForAgent(agent); BehaviourTreeNode child = outputKnob.connection(0).body as BehaviourTreeNode; BehaviourTreeNodeState childState = child.stateForAgent(agent); yield return(agent.StartCoroutine(child.routine(childState))); state.actualCondition = processCondition.Sucess; }
protected override IEnumerator process(BehaviourTreeAgent agent) { actualRepetition = 0; BehaviourTreeNodeState state = stateForAgent(agent); BehaviourTreeNode child = outputKnob.connection(0).body as BehaviourTreeNode; BehaviourTreeNodeState childState = child.stateForAgent(agent); while (repeatForever || actualRepetition < repetitionQuantity) { yield return(agent.StartCoroutine(child.routine(childState))); actualRepetition++; } state.actualCondition = childState.actualCondition; }
protected override IEnumerator process(BehaviourTreeAgent agent) { actualRepetition = 0; BehaviourTreeNodeState state = stateForAgent(agent); BehaviourTreeNode child = outputKnob.connection(0).body as BehaviourTreeNode; BehaviourTreeNodeState childState = child.stateForAgent(agent); do { yield return(agent.StartCoroutine(child.routine(childState))); actualRepetition++; } while ((repeatForever || actualRepetition < repetitionQuantity) && childState.actualCondition != processCondition.Failure); if (childState.actualCondition == processCondition.Failure) { state.actualCondition = processCondition.Sucess; } if (childState.actualCondition == processCondition.Sucess) { state.actualCondition = processCondition.Failure; } }
void StartThinking() { BehaviourTreeNodeState rootState = nodes.Where(x => x.node == root).First(); coroutine = StartCoroutine(root.routine(rootState)); }