Esempio n. 1
0
        public MyObjectBuilder_BotMemory GetObjectBuilder()
        {
            var builder = new MyObjectBuilder_BotMemory();

            builder.LastRunningNodeIndex = LastRunningNodeIndex;
            builder.NewPath = m_newNodePath.ToList();
            builder.OldPath = m_oldNodePath.ToList();

            // tree memory + blackboard
            var behaviorTreeMemory = new MyObjectBuilder_BotMemory.BehaviorTreeNodesMemory();

            behaviorTreeMemory.BehaviorName = m_behaviorTree.BehaviorTreeName;
            behaviorTreeMemory.Memory       = new List <MyObjectBuilder_BehaviorTreeNodeMemory>(CurrentTreeBotMemory.NodesMemoryCount);
            foreach (var nodeMemory in CurrentTreeBotMemory.NodesMemory)
            {
                behaviorTreeMemory.Memory.Add(nodeMemory.GetObjectBuilder());
            }
            behaviorTreeMemory.BlackboardMemory = new List <MyObjectBuilder_BotMemory.BehaviorTreeBlackboardMemory>();
            foreach (var bbMemInstance in CurrentTreeBotMemory.BBMemory)
            {
                var bbMemoryBuilder = new MyObjectBuilder_BotMemory.BehaviorTreeBlackboardMemory();
                bbMemoryBuilder.MemberName = bbMemInstance.Key.ToString();
                bbMemoryBuilder.Value      = bbMemInstance.Value;
                behaviorTreeMemory.BlackboardMemory.Add(bbMemoryBuilder);
            }
            builder.BehaviorTreeMemory = behaviorTreeMemory;

            return(builder);
        }
Esempio n. 2
0
        public MyObjectBuilder_BotMemory GetObjectBuilder()
        {
            MyObjectBuilder_BotMemory memory = new MyObjectBuilder_BotMemory {
                LastRunningNodeIndex = this.LastRunningNodeIndex,
                NewPath = this.m_newNodePath.ToList <int>(),
                OldPath = this.m_oldNodePath.ToList <int>()
            };

            MyObjectBuilder_BotMemory.BehaviorTreeNodesMemory memory2 = new MyObjectBuilder_BotMemory.BehaviorTreeNodesMemory {
                BehaviorName = this.m_behaviorTree.BehaviorTreeName,
                Memory       = new List <MyObjectBuilder_BehaviorTreeNodeMemory>(this.CurrentTreeBotMemory.NodesMemoryCount)
            };
            foreach (MyBehaviorTreeNodeMemory memory3 in this.CurrentTreeBotMemory.NodesMemory)
            {
                memory2.Memory.Add(memory3.GetObjectBuilder());
            }
            memory2.BlackboardMemory = new List <MyObjectBuilder_BotMemory.BehaviorTreeBlackboardMemory>();
            foreach (KeyValuePair <MyStringId, MyBBMemoryValue> pair in this.CurrentTreeBotMemory.BBMemory)
            {
                MyObjectBuilder_BotMemory.BehaviorTreeBlackboardMemory item = new MyObjectBuilder_BotMemory.BehaviorTreeBlackboardMemory();
                item.MemberName = pair.Key.ToString();
                item.Value      = pair.Value;
                memory2.BlackboardMemory.Add(item);
            }
            memory.BehaviorTreeMemory = memory2;
            return(memory);
        }