Ejemplo n.º 1
0
        public void Init(MyObjectBuilder_BotMemory builder)
        {
            if (builder.BehaviorTreeMemory != null)
            {
                var treeBotMemory = new MyPerTreeBotMemory();
                foreach (var nodeMemoryBuilder in builder.BehaviorTreeMemory.Memory)
                {
                    var nodeMemoryObj = MyBehaviorTreeNodeMemoryFactory.CreateNodeMemory(nodeMemoryBuilder);
                    nodeMemoryObj.Init(nodeMemoryBuilder);
                    treeBotMemory.AddNodeMemory(nodeMemoryObj);
                }

                if (builder.BehaviorTreeMemory.BlackboardMemory != null)
                {
                    foreach (var bbMemInstance in builder.BehaviorTreeMemory.BlackboardMemory)
                    {
                        treeBotMemory.AddBlackboardMemoryInstance(bbMemInstance.MemberName, bbMemInstance.Value);
                    }
                }
                CurrentTreeBotMemory = treeBotMemory;
            }

            if (builder.OldPath != null)
            {
                for (int i = 0; i < builder.OldPath.Count; i++)
                {
                    m_oldNodePath.Add(i);
                }
            }
            if (builder.NewPath != null)
            {
                for (int i = 0; i < builder.NewPath.Count; i++)
                {
                    m_newNodePath.Push(builder.NewPath[i]);
                }
            }

            LastRunningNodeIndex = builder.LastRunningNodeIndex;
            TickCounter          = 0;
        }
Ejemplo n.º 2
0
 public void Init(MyObjectBuilder_BotMemory builder)
 {
     if (builder.BehaviorTreeMemory != null)
     {
         MyPerTreeBotMemory memory = new MyPerTreeBotMemory();
         foreach (MyObjectBuilder_BehaviorTreeNodeMemory memory2 in builder.BehaviorTreeMemory.Memory)
         {
             MyBehaviorTreeNodeMemory nodeMemory = MyBehaviorTreeNodeMemoryFactory.CreateNodeMemory(memory2);
             nodeMemory.Init(memory2);
             memory.AddNodeMemory(nodeMemory);
         }
         if (builder.BehaviorTreeMemory.BlackboardMemory != null)
         {
             foreach (MyObjectBuilder_BotMemory.BehaviorTreeBlackboardMemory memory4 in builder.BehaviorTreeMemory.BlackboardMemory)
             {
                 memory.AddBlackboardMemoryInstance(memory4.MemberName, memory4.Value);
             }
         }
         this.CurrentTreeBotMemory = memory;
     }
     if (builder.OldPath != null)
     {
         for (int i = 0; i < builder.OldPath.Count; i++)
         {
             this.m_oldNodePath.Add(i);
         }
     }
     if (builder.NewPath != null)
     {
         for (int i = 0; i < builder.NewPath.Count; i++)
         {
             this.m_newNodePath.Push(builder.NewPath[i]);
         }
     }
     this.LastRunningNodeIndex = builder.LastRunningNodeIndex;
     this.TickCounter          = 0;
 }