BVB Source Codes

CRYENGINE Show SelectionTreeDebugger.cpp Source code

Return Download CRYENGINE: download SelectionTreeDebugger.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #include "StdAfx.h"
  4. #include "SelectionTreeDebugger.h"
  5. #include "SelectionTreeTemplate.h"
  6.  
  7. #ifndef RELEASE
  8.  
  9. CSelectionTreeDebugger* CSelectionTreeDebugger::GetInstance()
  10. {
  11.         static CSelectionTreeDebugger instance;
  12.         return &instance;
  13. }
  14.  
  15. CSelectionTreeDebugger::CSelectionTreeDebugger()
  16.         : m_pObserver(NULL)
  17.         , m_AI(NULL)
  18. {
  19.  
  20. }
  21.  
  22. void CSelectionTreeDebugger::StartEvaluation(const CAIActor* pActor, const SelectionTree& tree, const SelectionVariables& vars)
  23. {
  24.         m_AI = NULL;
  25.         if (m_pObserver && pActor->GetName() == m_AIName)
  26.         {
  27.                 m_AI = pActor;
  28.  
  29.                 const char* treename = tree.GetTemplate().GetName();
  30.                 assert(treename);
  31.  
  32.                 if (m_CurrTree != treename)
  33.                 {
  34.                         ISelectionTreeObserver::STreeNodeInfo root;
  35.                         ReadNodeInfo(tree, root, tree.GetNodeAt(0));
  36.                         m_pObserver->SetSelectionTree(treename, root);
  37.                         m_CurrTree = treename;
  38.                 }
  39.  
  40.                 ISelectionTreeObserver::TVariableStateMap varsDump;
  41.                 const SelectionVariableDeclarations::VariableDescriptions& varDesc = tree.GetTemplate().GetVariableDeclarations().GetDescriptions();
  42.                 for (SelectionVariableDeclarations::VariableDescriptions::const_iterator it = varDesc.begin(); it != varDesc.end(); ++it)
  43.                 {
  44.                         bool value;
  45.                         const SelectionVariableID id = it->first;
  46.                         const char* name = it->second.name.c_str();
  47.                         bool ok = vars.GetVariable(id, &value);
  48.                         assert(ok);
  49.                         varsDump[name] = value;
  50.                 }
  51.  
  52.                 if (m_pObserver)
  53.                 {
  54.                         m_pObserver->DumpVars(varsDump);
  55.                         m_pObserver->StartEval();
  56.                 }
  57.         }
  58. }
  59.  
  60. void CSelectionTreeDebugger::EvaluateNode(const SelectionTreeNode& node)
  61. {
  62.         if (m_AI && m_pObserver)
  63.         {
  64.                 m_pObserver->EvalNode(node.GetNodeID());
  65.         }
  66. }
  67.  
  68. void CSelectionTreeDebugger::EvaluateNodeCondition(const SelectionTreeNode& node, bool condition)
  69. {
  70.         if (m_AI && m_pObserver)
  71.         {
  72.                 m_pObserver->EvalNodeCondition(node.GetNodeID(), condition);
  73.         }
  74. }
  75.  
  76. void CSelectionTreeDebugger::EvaluateStateCondition(const SelectionTreeNode& node, bool condition)
  77. {
  78.         if (m_AI && m_pObserver)
  79.         {
  80.                 m_pObserver->EvalStateCondition(node.GetNodeID(), condition);
  81.         }
  82. }
  83.  
  84. void CSelectionTreeDebugger::EndEvaluation(const CAIActor* pActor, SelectionNodeID currentNodeId)
  85. {
  86.         if (m_AI == pActor && m_pObserver)
  87.         {
  88.                 m_pObserver->StopEval(currentNodeId);
  89.         }
  90.         m_AI = NULL;
  91. }
  92.  
  93. void CSelectionTreeDebugger::SetObserver(ISelectionTreeObserver* pListener, const char* nameAI)
  94. {
  95.         m_pObserver = pListener;
  96.         m_AI = NULL;
  97.         m_AIName = nameAI;
  98.         m_CurrTree = "";
  99. }
  100.  
  101. void CSelectionTreeDebugger::ReadNodeInfo(const SelectionTree& tree, ISelectionTreeObserver::STreeNodeInfo& outNode, const SelectionTreeNode& inNode)
  102. {
  103.         outNode.Id = inNode.GetNodeID();
  104.         outNode.Childs.resize(inNode.GetChildren().size());
  105.         int i = 0;
  106.         for (SelectionTreeNode::Children::const_iterator it = inNode.GetChildren().begin(); it != inNode.GetChildren().end(); ++it)
  107.                 ReadNodeInfo(tree, outNode.Childs[i++], tree.GetNode(it->childID));
  108. }
  109.  
  110. #endif
  111.  
downloadSelectionTreeDebugger.cpp Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top