Beispiel #1
0
    public override BTResult Execute()
    {
        NodePort inPort = GetPort("inResult");

        if (inPort != null && inPort.GetConnections().Count != 0)
        {
            NodePort connection = inPort.GetConnection(0);

            if (connection != null)
            {
                BTResult result = (BTResult)connection.GetOutputValue();
                if (result == BTResult.SUCCESS)
                {
                    BehaviourTreeRuntimeData.RemoveRunningNode(context, this);
                }
                else if (result == BTResult.RUNNING)
                {
                    return(BTResult.RUNNING);
                }
                else
                {
                    BehaviourTreeRuntimeData.AddRunningNode(context, this);
                    return(BTResult.RUNNING);
                }
            }
        }
        return(BTResult.SUCCESS);
    }
Beispiel #2
0
 /// <summary>
 /// Checks that the current behavior tree is valid and has a root node
 /// </summary>
 private void Start()
 {
     isValid = ValidateAndSetRootNode();
     if (isValid)
     {
         BehaviourTreeRuntimeData.RegisterBehaviourTree(this);
     }
 }
Beispiel #3
0
 private void Start()
 {
     behaviourTreeMap = BehaviourTreeRuntimeData.GetBehaviourTrees(); // Retreives the static dictionary from BehaviourTreeRuntimeData
     contextDataMap   = BehaviourTreeRuntimeData.GetContextData();    // Retreives the static dictionary from BehaviourTreeRuntimeData
 }
Beispiel #4
0
 /// <summary>
 /// Saves the starting position value. Initializes the <see cref="AISensor"/> and registers the agent in <see cref="BehaviourTreeRuntimeData"/>
 /// </summary>
 private void Start()
 {
     startPosition = transform.position;
     sensor.Initialize(this, navAgent);
     BehaviourTreeRuntimeData.RegisterAgentContext(behaviourTreeType, aiContext);
 }