protected override bool CanAddChild(BTNode child, ref string errorMessage) {
   if (_children.Count > 0) {
     errorMessage = "Decorator Node cannot have more than 1 child!";
     return false;
   }
   return true;
 }
 public void NodeDidStart(BTNode node) {
   if (_activeNodes.Contains(node)) {
     Debug.LogError("NodeDidStart - started node was in active nodes!");
     return;
   }
   _activeNodes.Add(node);
 }
 public void NodeDidFinish(BTNode node) {
   if (!_activeNodes.Contains(node)) {
     Debug.LogError("NodeDidFinish - finished node was not in active nodes!");
     return;
   }
   _activeNodes.Remove(node);
 }
 public virtual void AddChild(BTNode child, ref string errorMessage) {
   if (!this.CanAddChild(child, ref errorMessage)) {
     return;
   }
   
   _children.Add(child);
 }
 protected override void ReturnStateBasedOnFinishedChild(BTNode child) {
   if (child.State == BTNodeState.SUCCESS || child.State == BTNodeState.FAILURE) {
     Succeed();
   } else {
     // let parent handle invalid state
     base.ReturnStateBasedOnFinishedChild(child);
   }
 }
 protected override void HandleChildFinish(BTNode child) {
   if (child.IsRunning()) {
     Debug.LogError("BTDecoratorNode::HandleChildFinish - called when child is running");
     return;
   }
  
   this.ReturnStateBasedOnFinishedChild(child);
 }
 protected virtual void ReturnStateBasedOnFinishedChild(BTNode child) {
   if (child.State == BTNodeState.SUCCESS) {
     Succeed();
   } else if (child.State == BTNodeState.FAILURE) {
     Fail();
   } else {
     Debug.LogError("BTDecoratorNode::ReturnStateBasedOnFinishedChild - child state is not handled: " + child.State + "!");
     return;
   }
 }
 protected override void ReturnStateBasedOnFinishedChild(BTNode child) {
   if (child.State == BTNodeState.SUCCESS) {
     this.ProcessOneChild();
   } else if (child.State == BTNodeState.FAILURE) {
     Fail();
   } else {
     // let parent handle invalid state
     base.ReturnStateBasedOnFinishedChild(child);
   }
 }
 protected override void HandleChildFinish(BTNode child) {
   if (child.State == BTNodeState.SUCCESS) {
     _succeededNodes++;
   } else if (child.State != BTNodeState.FAILURE) {
     Debug.LogError("BTSequenceCNode::HandleChildFinish - invalid child state!");
   }
   
   if (_succeededNodes > _minSucceededNodes) {
     Succeed();
   } else {
     if (_chosenNodes.Count < _children.Count) {
       ProcessOneChild();
     } else {
       Fail();
     }
   }
 }
 protected override void ReturnStateBasedOnFinishedChild(BTNode child) {
   if (_numberOfRepeats == 0) {
     if (child.State == BTNodeState.SUCCESS) {
       Succeed();
     } else if (child.State == BTNodeState.FAILURE) {
       Fail();
     } else {
       // let parent handle invalid state
       base.ReturnStateBasedOnFinishedChild(child);
     }
   } else {
     this.ProcessOneChild();
     
     if (_numberOfRepeats > 0) {
       _numberOfRepeats--;
     }
   }
 }
 public BTSucceederDNode(int nodeId, BehaviourTree tree, BTNode parent) : base(nodeId, tree, parent) {}
예제 #12
0
 public BTRandomWeightedSNode(int nodeId, BehaviourTree tree, BTNode parent, int maxFailedNodes) : base(nodeId, tree, parent, maxFailedNodes)
 {
     _nodeWeightMap = new Dictionary <int, int>();
 }
 public BTRepeatUntilFailureDNode(int nodeId, BehaviourTree tree, BTNode parent) : base(nodeId, tree, parent) {}
 public BTSelectorCNode(int nodeId, BehaviourTree tree, BTNode parent) : this(nodeId, tree, parent, 0) {}
 protected abstract void HandleChildFinish(BTNode child);
 public BTRepeatUntilFailureDNode(int nodeId, BehaviourTree tree, BTNode parent) : base(nodeId, tree, parent)
 {
 }
 public BTRepeaterDNode(int nodeId, BehaviourTree tree, BTNode parent, int numRepeats) : base(nodeId, tree, parent) {
   _numberOfRepeats = numRepeats;
 }
 public BTNode(int nodeId, BehaviourTree tree, BTNode parent) {
   _nodeId = nodeId;
   _tree = tree;
   _parent = parent;
   _state = BTNodeState.SUCCESS;
 }
예제 #19
0
 protected override bool CanAddChild(BTNode child, ref string errorMessage)
 {
     return(false);
 }
 public BTRepeaterDNode(int nodeId, BehaviourTree tree, BTNode parent) : this(nodeId, tree, parent, -1) {}
예제 #21
0
 protected override void HandleChildFinish(BTNode child)
 {
     Debug.LogError("BTLeafNode::HandleChildFinish - leaf node should not have a child that could've finished!");
 }
예제 #22
0
 public BTLeafNode(int nodeId, BehaviourTree tree, BTNode parent) : base(nodeId, tree, parent)
 {
 }
예제 #23
0
 protected abstract void HandleChildFinish(BTNode child);
예제 #24
0
 public BTRandomWeightedSNode(int nodeId, BehaviourTree tree, BTNode parent) : base(nodeId, tree, parent, 0)
 {
 }
 public override void AddChild(BTNode child, ref string errorMessage) {
   base.AddChild(child, ref errorMessage);
   
   _nodeWeightMap[child.NodeId] = DEFAULT_CHILD_NODE_WEIGHT;
 }
 public BTInverterDNode(int nodeId, BehaviourTree tree, BTNode parent) : base(nodeId, tree, parent) {}
 public BTRandomSNode(int nodeId, BehaviourTree tree, BTNode parent) : base(nodeId, tree, parent, 0) {}
 public BTSequenceCNode(int nodeId, BehaviourTree tree, BTNode parent, int maxFailedNodes) : base(nodeId, tree, parent) {
   _maxFailedNodes = maxFailedNodes;
 }
 protected override void HandleChildFinish(BTNode child) {
   Debug.LogError("BTLeafNode::HandleChildFinish - leaf node should not have a child that could've finished!");
 }
 protected virtual bool CanAddChild(BTNode child, ref string errorMessage) {
   return true;
 }
 public BTRandomWeightedSNode(int nodeId, BehaviourTree tree, BTNode parent, int maxFailedNodes) : base(nodeId, tree, parent, maxFailedNodes) {
   _nodeWeightMap = new Dictionary<int, int>();
 }
 public BTInverterDNode(int nodeId, BehaviourTree tree, BTNode parent) : base(nodeId, tree, parent)
 {
 }
예제 #33
0
        public override void AddChild(BTNode child, ref string errorMessage)
        {
            base.AddChild(child, ref errorMessage);

            _nodeWeightMap[child.NodeId] = DEFAULT_CHILD_NODE_WEIGHT;
        }
 protected override bool CanAddChild(BTNode child, ref string errorMessage) {
   return false;
 }
 public BTDecoratorNode(int nodeId, BehaviourTree tree, BTNode parent) : base(nodeId, tree, parent)
 {
 }
 public BTSelectorCNode(int nodeId, BehaviourTree tree, BTNode parent, int minSucceededNodes) : base(nodeId, tree, parent) {
   _minSucceededNodes = minSucceededNodes;
 }
예제 #37
0
 protected virtual bool CanAddChild(BTNode child, ref string errorMessage)
 {
     return(true);
 }
 public BTCompositeNode(int nodeId, BehaviourTree tree, BTNode parent) : base(nodeId, tree, parent) {}
 public BTDecoratorNode(int nodeId, BehaviourTree tree, BTNode parent) : base(nodeId, tree, parent) {}     
 public BTRandomSNode(int nodeId, BehaviourTree tree, BTNode parent, int maxFailedNodes) : base(nodeId, tree, parent, maxFailedNodes) {}
 public BTLeafNode(int nodeId, BehaviourTree tree, BTNode parent) : base(nodeId, tree, parent) {}