示例#1
0
 public void PreTickClear()
 {
     if (HasPathToSave)
     {
         PrepareForNewNodePath();
     }
     CurrentTreeBotMemory.ClearNodesData();
 }
示例#2
0
 public void ResetMemory(bool clearMemory = false)
 {
     if (m_behaviorTree == null)
     {
         return;
     }
     if (clearMemory)
     {
         ClearPathMemory(true);
     }
     CurrentTreeBotMemory.Clear();
     ResetMemoryInternal(m_behaviorTree, CurrentTreeBotMemory);
 }
示例#3
0
 public void AssignBehaviorTree(MyBehaviorTree behaviorTree)
 {
     if (CurrentBehaviorTree == null || behaviorTree.BehaviorTreeId == CurrentBehaviorTree.BehaviorTreeId)
     {
         CurrentTreeBotMemory = CreateBehaviorTreeMemory(behaviorTree);
     }
     else
     {
         bool isValid = ValidateMemoryForBehavior(behaviorTree);
         if (!isValid)
         {
             CurrentTreeBotMemory.Clear();
             ClearPathMemory(false);
             ResetMemoryInternal(behaviorTree, CurrentTreeBotMemory);
         }
     }
 }
示例#4
0
        public void ResetMemory(MyBehaviorTree behaviorTree, bool clearMemory = false)
        {
            if (clearMemory)
            {
                ClearPathMemory(true);
            }

            if (CurrentBehaviorTree.BehaviorTreeId == behaviorTree.BehaviorTreeId)
            {
                CurrentTreeBotMemory.Clear();
            }
            else
            {
                CurrentTreeBotMemory = new MyPerTreeBotMemory();
            }

            ResetMemoryInternal(behaviorTree, CurrentTreeBotMemory);
        }
示例#5
0
        public bool ValidateMemoryForBehavior(MyBehaviorTree behaviorTree)
        {
            bool isValid = true;

            if (CurrentTreeBotMemory.NodesMemoryCount != behaviorTree.TotalNodeCount)
            {
                isValid = false;
            }
            else
            {
                for (int i = 0; i < CurrentTreeBotMemory.NodesMemoryCount; i++)
                {
                    var nodeMemory = CurrentTreeBotMemory.GetNodeMemoryByIndex(i);
                    if (nodeMemory.GetType() != behaviorTree.GetNodeByIndex(i).MemoryType)
                    {
                        isValid = false;
                        break;
                    }
                }
            }
            return(isValid);
        }