Beispiel #1
0
        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);
        }
Beispiel #2
0
        public static BehaviorTreeTask CreateBehaviorTreeTask(string relativePath)
        {
            BehaviorTree tree = null;

            if (BehaviorTrees.ContainsKey(relativePath))
            {
                tree = BehaviorTrees[relativePath];
            }
            else if (Load(relativePath))
            {
                tree = BehaviorTrees[relativePath];
            }
            if (tree == null)
            {
                return(null);
            }
            BehaviorTreeTask item = tree.CreateAndInitTask() as BehaviorTreeTask;

            if (!ms_allBehaviorTreeTasks.ContainsKey(relativePath))
            {
                ms_allBehaviorTreeTasks[relativePath] = new BTItem_t();
            }
            BTItem_t _t = ms_allBehaviorTreeTasks[relativePath];

            if (!_t.bts.Contains(item))
            {
                _t.bts.Add(item);
            }
            return(item);
        }