public bool AssignBotToBehaviorTree(MyBehaviorTree behaviorTree, IMyBot bot)
 {
     Debug.Assert(!m_BTDataByName[behaviorTree.BehaviorTreeId].ContainsBot(bot), "Bot has already been added.");
     Debug.Assert(behaviorTree.IsCompatibleWithBot(bot.ActionCollection), "Bot is not compatible with the behavior tree.");
     if (!behaviorTree.IsCompatibleWithBot(bot.ActionCollection))
     {
         return(false);
     }
     AssignBotBehaviorTreeInternal(behaviorTree, bot);
     return(true);
 }
Ejemplo n.º 2
0
        public bool ChangeBehaviorTree(string behaviorTreeName, IMyBot bot)
        {
            bool           flag         = false;
            MyBehaviorTree behaviorTree = null;

            if (!this.TryGetBehaviorTreeByName(behaviorTreeName, out behaviorTree))
            {
                return(false);
            }
            if (!behaviorTree.IsCompatibleWithBot(bot.ActionCollection))
            {
                return(false);
            }
            MyBehaviorTree tree2 = this.TryGetBehaviorTreeForBot(bot);

            if (tree2 == null)
            {
                flag = true;
            }
            else if (tree2.BehaviorTreeId == behaviorTree.BehaviorTreeId)
            {
                flag = false;
            }
            else
            {
                this.UnassignBotBehaviorTree(bot);
                flag = true;
            }
            if (flag)
            {
                this.AssignBotBehaviorTreeInternal(behaviorTree, bot);
            }
            return(flag);
        }
Ejemplo n.º 3
0
 public bool AssignBotToBehaviorTree(MyBehaviorTree behaviorTree, IMyBot bot)
 {
     if (!behaviorTree.IsCompatibleWithBot(bot.ActionCollection))
     {
         return(false);
     }
     this.AssignBotBehaviorTreeInternal(behaviorTree, bot);
     return(true);
 }
Ejemplo n.º 4
0
        public bool ChangeBehaviorTree(string behaviorTreeName, IMyBot bot)
        {
            bool           assign       = false;
            MyBehaviorTree behaviorTree = null;

            if (!TryGetBehaviorTreeByName(behaviorTreeName, out behaviorTree))
            {
                return(false);
            }
            if (!behaviorTree.IsCompatibleWithBot(bot.ActionCollection))
            {
                return(false);
            }
            var tree = TryGetBehaviorTreeForBot(bot);

            if (tree != null)
            {
                if (tree.BehaviorTreeId == behaviorTree.BehaviorTreeId)
                {
                    assign = false;
                }
                else
                {
                    UnassignBotBehaviorTree(bot);
                    assign = true;
                }
            }
            else
            {
                assign = true;
            }

            if (assign)
            {
                AssignBotBehaviorTreeInternal(behaviorTree, bot);
            }
            return(assign);
        }