public virtual void Close(Tick tick) { }
public virtual void Exit(Tick tick) { }
public virtual NodeStates Tick(Tick tick) { return(NodeStates.Error); }
public virtual void Open(Tick tick) { }
public virtual void Enter(Tick tick) { }
public virtual NodeStates Execute(Tick tick) { return(NodeStates.Error); }
public void Tick(GameObject target, Blackboard blackboard) { var tick = new Tick(); tick.target = target; tick.blackboard = blackboard; tick.tree = this; /* TICK NODE */ this.root.Execute(tick); /* CLOSE NODES FROM LAST TICK, IF NEEDED */ List <Node> lastOpenNodes; lastOpenNodes = new List <Node>(); try { lastOpenNodes = (List <Node>)blackboard.Get("openNodes", id).value; } catch (Exception) { } var currOpenNodes = new List <Node>(tick.openNodes); // does not close if it is still open in this tick var start = 0; int n = 0; if (lastOpenNodes == null) { n = currOpenNodes.Count; } else { n = Math.Min(lastOpenNodes.Count, currOpenNodes.Count); } if (lastOpenNodes != null) { for (int i = 0; i < n; i++) { start = i + 1; if ((Node)lastOpenNodes[i] != currOpenNodes[i]) { break; } } } else { start = currOpenNodes.Count; } // close the nodes if (lastOpenNodes != null) { for (var i = lastOpenNodes.Count - 1; i >= start; i--) { lastOpenNodes[i].Close(tick); } } /* POPULATE BLACKBOARD */ blackboard.Set("openNodes", currOpenNodes, id); blackboard.Set("nodeCount", tick.nodeCount, id); }