public bool SetCurrentTree(BehaviourRootNode behaviourtree, bool stopCurrentTree, bool addIfNotPresent = true)
 {
     if (!_behaviourtrees.Contains(behaviourtree))
     {
         if (addIfNotPresent)
         {
             _behaviourtrees.Add(behaviourtree);
         }
         else
         {
             return(false);
         }
     }
     NextTree     = null;
     StoppingTree = false;
     if (stopCurrentTree)
     {
         if (RequestStopTree())
         {
             StoppingTree = true;
             NextTree     = behaviourtree;
         }
     }
     if (NextTree == null)
     {
         CurrentTree = behaviourtree;
     }
     return(true);
 }
 public void RemoveBehaviourTree(BehaviourRootNode behaviourtree)
 {
     _behaviourtrees.Remove(behaviourtree);
     if (behaviourtree == CurrentTree)
     {
         CurrentTree = _behaviourtrees.FirstOrDefault();
     }
 }
        public BehaviourRootNode AddBehaviourTree(string name)
        {
            var behaviourtree = new BehaviourRootNode(name);

            AddBehaviourTree(behaviourtree);

            if (CurrentTree == null)
            {
                CurrentTree = behaviourtree;
            }

            return(behaviourtree);
        }
        /*
         * public void AddBehaviourTree(BehaviourNode behaviourtree)
         * {
         *  m_behaviourtrees.Add(behaviourtree);
         * }*/

        private void AddBehaviourTree(BehaviourRootNode behaviourtree)
        {
            _behaviourtrees.Add(behaviourtree);
            behaviourtree.OnStopped.AddListener(BehaviourtreeOnStopped_Listener);
        }