public void btunload(string relativePath) { if ((this.m_currentBT != null) && (this.m_currentBT.GetName() == relativePath)) { BehaviorTree node = this.m_currentBT.GetNode() as BehaviorTree; this.btunload_pars(node); this.m_currentBT = null; } for (int i = 0; i < this.BTStack.Count; i++) { BehaviorTreeStackItem_t item = this.BTStack[i]; if (item.bt.GetName() == relativePath) { this.BTStack.Remove(item); 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); }
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; } } }
private EBTStatus btexec_() { if (this.m_currentBT == null) { return(EBTStatus.BT_INVALID); } EBTStatus status = this.m_currentBT.exec(this); if (this == null) { return(EBTStatus.BT_FAILURE); } while (status != EBTStatus.BT_RUNNING) { this.m_currentBT.reset(this); if (this.BTStack.Count <= 0) { return(status); } BehaviorTreeStackItem_t _t = this.BTStack[this.BTStack.Count - 1]; this.m_currentBT = _t.bt; this.BTStack.RemoveAt(this.BTStack.Count - 1); if (_t.triggerMode == TriggerMode.TM_Return) { string name = this.m_currentBT.GetName(); LogManager.Log(this, name, EActionResult.EAR_none, LogMode.ELM_return); if (!_t.triggerByEvent) { this.m_currentBT.resume(this, status); status = this.m_currentBT.exec(this); } } else { return(this.m_currentBT.exec(this)); } } return(status); }