/// <summary>
    /// Registers the <see cref="BTContextData"/> for the behavior tree
    /// </summary>
    /// <param name="behaviourType"></param>
    /// <param name="aiContext"></param>
    public static void RegisterAgentContext(BehaviourTreeType behaviourType, BTContext aiContext)
    {
        if (!contextMap.ContainsKey(behaviourType))
        {
            contextMap[behaviourType] = new List <BTContextData>();
        }

        contextMap[behaviourType].Add(new BTContextData(aiContext));
    }
 /// <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);
         }
     }
 }
    /// <summary>
    /// Initiates the first startup of every behavior tree in <see cref="BehaviourTreeType"/>
    /// </summary>
    private void InitializeAllBehaviourTrees()
    {
        for (int i = 0; i < (int)BehaviourTreeType.COUNT; ++i)
        {
            BehaviourTreeType treeType = (BehaviourTreeType)i;

            if (behaviourTreeMap.ContainsKey(treeType))
            {
                InitializeTreeNodes(behaviourTreeMap[treeType].runtimeTree.nodes);
            }
        }
    }
    /// <summary>
    /// Clears the history of every behavior tree in <see cref="BehaviourTreeType"/>
    /// </summary>
#if UNITY_EDITOR
    private void ClearAgentHistory()
    {
        for (int i = 0; i < (int)BehaviourTreeType.COUNT; ++i)
        {
            BehaviourTreeType treeType = (BehaviourTreeType)i;

            if (behaviourTreeMap.ContainsKey(treeType))
            {
                if (contextDataMap.ContainsKey(treeType))
                {
                    contextDataMap[treeType].ForEach(x => x.owningContext.behaviourHistory.Clear());
                }
            }
        }
    }
    /// <summary>
    /// Activates every behavior tree in <see cref="BehaviourTreeType"/>
    /// </summary>
    private void StartAgents()
    {
        for (int i = 0; i < (int)BehaviourTreeType.COUNT; i++)
        {
            BehaviourTreeType treeType = (BehaviourTreeType)i;

            if (behaviourTreeMap.ContainsKey(treeType))
            {
                if (contextDataMap.ContainsKey(treeType))
                {
                    contextDataMap[treeType].ForEach(x => behaviourTreeMap[treeType].RunBehaviourTree(x));
                }
            }
        }
    }