BVB Source Codes

CRYENGINE Show SelectionTree.cpp Source code

Return Download CRYENGINE: download SelectionTree.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 "SelectionTree.h"
  5. #include "SelectionContext.h"
  6. #include "SelectionTreeManager.h"
  7.  
  8. SelectionTree::SelectionTree()
  9.         : m_currentNodeID(0) // @Marcio: What if the first node is selected. Then the selected node and the current will not differ and no behavior will be selected? /Jonas 2010-08-25
  10.         , m_templateID(0)
  11. {
  12. }
  13.  
  14. SelectionTree::SelectionTree(const SelectionTreeTemplateID& templateID)
  15.         : m_currentNodeID(0)
  16.         , m_templateID(templateID)
  17. {
  18. }
  19.  
  20. SelectionTree::SelectionTree(const SelectionTree& selectionTree)
  21.         : m_currentNodeID(selectionTree.m_currentNodeID)
  22.         , m_templateID(selectionTree.m_templateID)
  23.         , m_nodes(selectionTree.m_nodes)
  24. {
  25. }
  26.  
  27. void SelectionTree::Clear()
  28. {
  29.         m_currentNodeID = 0;
  30.         SelectionTreeNodes().swap(m_nodes);
  31. }
  32.  
  33. void SelectionTree::Reset()
  34. {
  35.         m_currentNodeID = 0;
  36. }
  37.  
  38. const SelectionNodeID& SelectionTree::Evaluate(const SelectionVariables& variables)
  39. {
  40.         SelectionContext context(m_nodes, m_currentNodeID, variables);
  41.         if (!m_nodes.front().Evaluate(context, m_currentNodeID))
  42.                 m_currentNodeID = 0;
  43.  
  44.         return m_currentNodeID;
  45. }
  46.  
  47. SelectionNodeID SelectionTree::AddNode(const SelectionTreeNode& node)
  48. {
  49.         m_nodes.push_back(node);
  50.         m_nodes.back().SetNodeID(static_cast<SelectionNodeID>(m_nodes.size()));
  51.         return static_cast<SelectionNodeID>(m_nodes.size());
  52. }
  53.  
  54. SelectionTreeNode& SelectionTree::GetNode(const NodeID& nodeID)
  55. {
  56.         return m_nodes[nodeID - 1];
  57. }
  58.  
  59. const SelectionTreeNode& SelectionTree::GetNode(const NodeID& nodeID) const
  60. {
  61.         return m_nodes[nodeID - 1];
  62. }
  63.  
  64. const SelectionNodeID& SelectionTree::GetCurrentNodeID() const
  65. {
  66.         return m_currentNodeID;
  67. }
  68.  
  69. const SelectionTreeTemplateID& SelectionTree::GetTemplateID() const
  70. {
  71.         return m_templateID;
  72. }
  73.  
  74. const SelectionTreeTemplate& SelectionTree::GetTemplate() const
  75. {
  76.         return gAIEnv.pSelectionTreeManager->GetTreeTemplate(m_templateID);
  77. }
  78.  
  79. uint32 SelectionTree::GetNodeCount() const
  80. {
  81.         return m_nodes.size();
  82. }
  83.  
  84. const SelectionTreeNode& SelectionTree::GetNodeAt(uint32 index) const
  85. {
  86.         assert(index < m_nodes.size());
  87.  
  88.         return m_nodes[index];
  89. }
  90.  
  91. void SelectionTree::ReserveNodes(uint32 nodeCount)
  92. {
  93.         m_nodes.reserve(nodeCount);
  94. }
  95.  
  96. void SelectionTree::Swap(SelectionTree& other)
  97. {
  98.         std::swap(m_templateID, other.m_templateID);
  99.         std::swap(m_currentNodeID, other.m_currentNodeID);
  100.         m_nodes.swap(other.m_nodes);
  101. }
  102.  
  103. bool SelectionTree::Empty() const
  104. {
  105.         return m_nodes.empty();
  106. }
  107.  
  108. void SelectionTree::Validate()
  109. {
  110.         SelectionTreeNodes(m_nodes).swap(m_nodes);
  111. }
  112.  
  113. void SelectionTree::Serialize(TSerialize ser)
  114. {
  115.         ser.Value("m_currentNodeID", m_currentNodeID);
  116. }
  117.  
  118. void SelectionTree::DebugDraw() const
  119. {
  120. }
  121.  
downloadSelectionTree.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