Esempio n. 1
0
 public void btunload(string relativePath)
 {
     if (this.m_currentBT != null && this.m_currentBT.GetName() == relativePath)
     {
         BehaviorNode node = this.m_currentBT.GetNode();
         BehaviorTree bt   = node as BehaviorTree;
         this.btunload_pars(bt);
         this.m_currentBT = null;
     }
     for (int i = 0; i < this.BTStack.Count; i++)
     {
         Agent.BehaviorTreeStackItem_t behaviorTreeStackItem_t = this.BTStack[i];
         if (behaviorTreeStackItem_t.bt.GetName() == relativePath)
         {
             this.BTStack.Remove(behaviorTreeStackItem_t);
             break;
         }
     }
     for (int j = 0; j < this.BehaviorTreeTasks.Count; j++)
     {
         BehaviorTreeTask behaviorTreeTask = this.BehaviorTreeTasks[j];
         if (behaviorTreeTask.GetName() == relativePath)
         {
             Workspace.DestroyBehaviorTreeTask(behaviorTreeTask, this);
             this.BehaviorTreeTasks.Remove(behaviorTreeTask);
             break;
         }
     }
     Workspace.UnLoad(relativePath);
 }
Esempio n. 2
0
 private void _btsetcurrent(string relativePath, TriggerMode triggerMode, bool bByEvent)
 {
     if (!string.IsNullOrEmpty(relativePath))
     {
         if (!Workspace.Load(relativePath))
         {
             string text = base.GetType().get_FullName();
             text += "::";
             text += base.name;
         }
         else
         {
             Workspace.RecordBTAgentMapping(relativePath, this);
             if (this.m_currentBT != null)
             {
                 if (triggerMode == TriggerMode.TM_Return)
                 {
                     Agent.BehaviorTreeStackItem_t item = new Agent.BehaviorTreeStackItem_t(this.m_currentBT, triggerMode, bByEvent);
                     this.BTStack.Add(item);
                 }
                 else if (triggerMode == TriggerMode.TM_Transfer)
                 {
                     this.m_currentBT.abort(this);
                     this.m_currentBT.reset(this);
                 }
             }
             BehaviorTreeTask behaviorTreeTask = null;
             for (int i = 0; i < this.BehaviorTreeTasks.Count; i++)
             {
                 BehaviorTreeTask behaviorTreeTask2 = this.BehaviorTreeTasks[i];
                 if (behaviorTreeTask2.GetName() == relativePath)
                 {
                     behaviorTreeTask = behaviorTreeTask2;
                     break;
                 }
             }
             bool flag = false;
             if (behaviorTreeTask != null && this.BTStack.Count > 0)
             {
                 for (int j = 0; j < this.BTStack.Count; j++)
                 {
                     Agent.BehaviorTreeStackItem_t behaviorTreeStackItem_t = this.BTStack[j];
                     if (behaviorTreeStackItem_t.bt.GetName() == relativePath)
                     {
                         flag = true;
                         break;
                     }
                 }
             }
             if (behaviorTreeTask == null || flag)
             {
                 behaviorTreeTask = Workspace.CreateBehaviorTreeTask(relativePath);
                 this.BehaviorTreeTasks.Add(behaviorTreeTask);
             }
             this.m_currentBT = behaviorTreeTask;
         }
     }
 }
Esempio n. 3
0
        private EBTStatus btexec_()
        {
            if (this.m_currentBT == null)
            {
                return(EBTStatus.BT_INVALID);
            }
            EBTStatus eBTStatus = this.m_currentBT.exec(this);

            if (this == null)
            {
                return(EBTStatus.BT_FAILURE);
            }
            while (eBTStatus != EBTStatus.BT_RUNNING)
            {
                this.m_currentBT.reset(this);
                if (this.BTStack.Count <= 0)
                {
                    break;
                }
                Agent.BehaviorTreeStackItem_t behaviorTreeStackItem_t = this.BTStack[this.BTStack.Count - 1];
                this.m_currentBT = behaviorTreeStackItem_t.bt;
                this.BTStack.RemoveAt(this.BTStack.Count - 1);
                if (behaviorTreeStackItem_t.triggerMode != TriggerMode.TM_Return)
                {
                    eBTStatus = this.m_currentBT.exec(this);
                    break;
                }
                string name = this.m_currentBT.GetName();
                LogManager.Log(this, name, EActionResult.EAR_none, LogMode.ELM_return);
                if (!behaviorTreeStackItem_t.triggerByEvent)
                {
                    this.m_currentBT.resume(this, eBTStatus);
                    eBTStatus = this.m_currentBT.exec(this);
                }
            }
            return(eBTStatus);
        }