public static BehaviorTreeTask CreateBehaviorTreeTask(string relativePath) { BehaviorTree behaviorTree = null; if (Workspace.BehaviorTrees.ContainsKey(relativePath)) { behaviorTree = Workspace.BehaviorTrees.get_Item(relativePath); } else { bool flag = Workspace.Load(relativePath); if (flag) { behaviorTree = Workspace.BehaviorTrees.get_Item(relativePath); } } if (behaviorTree != null) { BehaviorTask behaviorTask = behaviorTree.CreateAndInitTask(); BehaviorTreeTask behaviorTreeTask = behaviorTask as BehaviorTreeTask; if (!Workspace.ms_allBehaviorTreeTasks.ContainsKey(relativePath)) { Workspace.ms_allBehaviorTreeTasks.set_Item(relativePath, new Workspace.BTItem_t()); } Workspace.BTItem_t bTItem_t = Workspace.ms_allBehaviorTreeTasks.get_Item(relativePath); if (!bTItem_t.bts.Contains(behaviorTreeTask)) { bTItem_t.bts.Add(behaviorTreeTask); } return(behaviorTreeTask); } return(null); }
public void btreloadall() { this.m_currentBT = null; this.BTStack.Clear(); if (this.m_behaviorTreeTasks != null) { List <string> list = new List <string>(); using (ListView <BehaviorTreeTask> .Enumerator enumerator = this.m_behaviorTreeTasks.GetEnumerator()) { while (enumerator.MoveNext()) { BehaviorTreeTask current = enumerator.get_Current(); string name = current.GetName(); if (list.IndexOf(name) == -1) { list.Add(name); } } } for (int i = 0; i < list.get_Count(); i++) { string relativePath = list.get_Item(i); Workspace.Load(relativePath, true); } this.BehaviorTreeTasks.Clear(); } this.Variables.Unload(); }
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; } } }
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; } } }
public bool btload(string relativePath, bool bForce) { bool flag = Workspace.Load(relativePath, bForce); if (flag) { Workspace.RecordBTAgentMapping(relativePath, this); } return(flag); }
protected override void load(int version, string agentType, List <property_t> properties) { base.load(version, agentType, properties); foreach (property_t _t in properties) { if (_t.name == "ReferenceFilename") { this.m_referencedBehaviorPath = _t.value; bool flag = Workspace.Load(this.m_referencedBehaviorPath); } } }
protected override void load(int version, string agentType, List <property_t> properties) { base.load(version, agentType, properties); using (List <property_t> .Enumerator enumerator = properties.GetEnumerator()) { while (enumerator.MoveNext()) { property_t current = enumerator.get_Current(); if (current.name == "ReferenceFilename") { this.m_referencedBehaviorPath = current.value; bool flag = Workspace.Load(this.m_referencedBehaviorPath); } } } }
protected override void load(int version, string agentType, List <property_t> properties) { base.load(version, agentType, properties); foreach (property_t p in properties) { if (p.name == "ReferenceFilename") { this.m_referencedBehaviorPath = p.value; bool bOk = Workspace.Load(this.m_referencedBehaviorPath); Debug.Check(bOk); } else { //Debug.Check(0, "unrecognised property %s", p.name); } } }
public void btreloadall() { this.m_currentBT = null; this.BTStack.Clear(); if (this.m_behaviorTreeTasks != null) { List <string> list = new List <string>(); foreach (BehaviorTreeTask current in this.m_behaviorTreeTasks) { string name = current.GetName(); if (list.IndexOf(name) == -1) { list.Add(name); } } for (int i = 0; i < list.get_Count(); i++) { string relativePath = list.get_Item(i); Workspace.Load(relativePath, true); } this.BehaviorTreeTasks.Clear(); } this.Variables.Unload(); }
public static bool Load(string relativePath) { return(Workspace.Load(relativePath, false)); }