public override bool Process(BehaviorTree tree) { if (NextNode == null) { Debug.LogWarning("Root node finished processing as non-leaf node"); return(true); } return(NextNode.Process(tree)); }
public override bool Process(BehaviorTree tree) { bool value = false; if (Logic != null) { value = Logic.Evaluate(tree.currentAI.localBlackboard); } if (value) { return(nodeOnTrue.Process(tree)); } else { return(nodeOnFalse.Process(tree)); } }
public override bool Process(BehaviorTree tree) { if (!tree.currentAI.instanceSequencePositions.ContainsKey(this)) { tree.currentAI.instanceSequencePositions.Add(this, 0); tree.QueueNode(this); } if (tree.currentAI.instanceSequencePositions[this] >= sequenceNodes.Length) { tree.currentAI.instanceSequencePositions[this] = 0; return(true); } Node nodeInSequence = sequenceNodes[tree.currentAI.instanceSequencePositions[this]]; tree.currentAI.instanceSequencePositions[this]++; return(nodeInSequence.Process(tree)); }
public virtual void ProcessTree(AIController ai) { currentAI = ai; Node activeNode = ai.ActiveNode; if (activeNode == null) { activeNode = root; } if (activeNode.Process(this)) { if (currentAI.NodesToProcess.Count > 0) { if (currentAI.ActiveNode is Sequence) { currentAI.instanceSequencePositions.Remove(currentAI.ActiveNode as Sequence); } //Debug.Log("Popping " + currentAI.ActiveNode + " for " + currentAI); currentAI.NodesToProcess.Pop(); } } currentAI = null; }