Esempio n. 1
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. 2
0
 private void _btsetcurrent(string relativePath, TriggerMode triggerMode, bool bByEvent)
 {
     if (!string.IsNullOrEmpty(relativePath))
     {
         if (!Workspace.Load(relativePath))
         {
             string str = base.GetType().FullName + "::" + base.name;
         }
         else
         {
             Workspace.RecordBTAgentMapping(relativePath, this);
             if (this.m_currentBT != null)
             {
                 if (triggerMode == TriggerMode.TM_Return)
                 {
                     BehaviorTreeStackItem_t _t = new BehaviorTreeStackItem_t(this.m_currentBT, triggerMode, bByEvent);
                     this.BTStack.Add(_t);
                 }
                 else if (triggerMode == TriggerMode.TM_Transfer)
                 {
                     this.m_currentBT.abort(this);
                     this.m_currentBT.reset(this);
                 }
             }
             BehaviorTreeTask item = null;
             for (int i = 0; i < this.BehaviorTreeTasks.Count; i++)
             {
                 BehaviorTreeTask task2 = this.BehaviorTreeTasks[i];
                 if (task2.GetName() == relativePath)
                 {
                     item = task2;
                     break;
                 }
             }
             bool flag3 = false;
             if ((item != null) && (this.BTStack.Count > 0))
             {
                 for (int j = 0; j < this.BTStack.Count; j++)
                 {
                     BehaviorTreeStackItem_t _t2 = this.BTStack[j];
                     if (_t2.bt.GetName() == relativePath)
                     {
                         flag3 = true;
                         break;
                     }
                 }
             }
             if ((item == null) || flag3)
             {
                 item = Workspace.CreateBehaviorTreeTask(relativePath);
                 this.BehaviorTreeTasks.Add(item);
             }
             this.m_currentBT = item;
         }
     }
 }