/// <summary>
    /// Removes a currently running node
    /// </summary>
    /// <param name="nodeContext"></param>
    /// <param name="node"></param>
    public static void RemoveRunningNode(BTContext nodeContext, BTNode node)
    {
        BTContextData data = contextMap[nodeContext.contextOwner.behaviourTreeType].Find(x => x.owningContext == nodeContext);

        if (data != null)
        {
            data.RemoveRunningNode(node);
        }
    }
 /// <summary>
 /// Removes a registered <see cref="BTContext"/> from <see cref="contextMap"/>
 /// </summary>
 /// <param name="behaviourType"></param>
 /// <param name="aiContext"></param>
 public static void UnregisterAgentContext(BehaviourTreeType behaviourType, BTContext aiContext)
 {
     if (contextMap.ContainsKey(behaviourType))
     {
         BTContextData data = contextMap[behaviourType].Find(x => x.owningContext == aiContext);
         if (data != null)
         {
             contextMap[behaviourType].Remove(data);
         }
     }
 }
Example #3
0
 /// <summary>
 /// Activates the behavior tree and returns its child nodes
 /// </summary>
 /// <param name="currentContextData"></param>
 public virtual void RunBehaviourTree(BTContextData currentContextData)
 {
     if (isValid)
     {
         BTNode runningNode;
         if (currentContextData.HasRunningNodes(out runningNode))
         {
             //Running node will attempt to get context from parent node
             //So we need to override the parents node context event if it's not executed
             BTNode parentNode = runningNode.GetPort("outResult").Connection.node as BTNode;
             if (parentNode != null)
             {
                 parentNode.context = currentContextData.owningContext;
             }
             runningNode.GetPort("outResult").GetOutputValue();
         }
         else
         {
             rootNode.context = currentContextData.owningContext;
             rootNode.GetInputValue("inResult", BTResult.FAILURE);
         }
     }
 }