BVB Source Codes

CRYENGINE Show BehaviorTreeManager.h Source code

Return Download CRYENGINE: download BehaviorTreeManager.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #pragma once
  4.  
  5. #include <CryAISystem/BehaviorTree/IBehaviorTree.h>
  6. #include <CryAISystem/BehaviorTree/NodeFactory.h>
  7. #include <CryGame/IGameWebDebug.h>
  8.  
  9. namespace BehaviorTree
  10. {
  11. class MetaExtensionFactory;
  12. #ifdef USING_BEHAVIOR_TREE_EXECUTION_STACKS_FILE_LOG
  13. class ExecutionStackFileLogger;
  14. #endif
  15.  
  16. #if defined(DEBUG_MODULAR_BEHAVIOR_TREE)
  17.         #define DEBUG_MODULAR_BEHAVIOR_TREE_WEB
  18. #endif
  19.  
  20. class BehaviorTreeManager
  21.         : public IBehaviorTreeManager
  22. #if defined(DEBUG_MODULAR_BEHAVIOR_TREE_WEB)
  23.           , public IGameWebDebugEntityChannel
  24. #endif
  25. {
  26. public:
  27.         BehaviorTreeManager();
  28.         virtual ~BehaviorTreeManager();
  29.  
  30.         // IBehaviorTreeManager
  31.         virtual IMetaExtensionFactory&              GetMetaExtensionFactory() override;
  32.         virtual INodeFactory&                       GetNodeFactory() override;
  33. #ifdef USING_BEHAVIOR_TREE_SERIALIZATION
  34.         virtual Serialization::ClassFactory<INode>& GetNodeSerializationFactory() override;
  35. #endif
  36.         virtual void                                LoadFromDiskIntoCache(const char* behaviorTreeName) override;
  37.         virtual bool                                StartModularBehaviorTree(const EntityId entityId, const char* treeName) override;
  38.         virtual bool                                StartModularBehaviorTreeFromXml(const EntityId entityId, const char* treeName, XmlNodeRef treeXml) override;
  39.         virtual void                                StopModularBehaviorTree(const EntityId entityId) override;
  40.  
  41.         virtual void                                HandleEvent(const EntityId entityId, Event& event) override;
  42.  
  43.         virtual Variables::Collection*              GetBehaviorVariableCollection_Deprecated(const EntityId entityId) const override;
  44.         virtual const Variables::Declarations*      GetBehaviorVariableDeclarations_Deprecated(const EntityId entityId) const override;
  45.         // ~IBehaviorTreeManager
  46.  
  47. #if defined(DEBUG_MODULAR_BEHAVIOR_TREE_WEB)
  48.         // IGameWebDebugEntityChannel
  49.         virtual void Subscribe(const TGameWebDebugClientId clientId, const EntityId entityId) override;
  50.         virtual void Unsubscribe(const TGameWebDebugClientId clientId) override;
  51.         //~IGameWebDebugEntityChannel
  52. #endif
  53.  
  54.         void                    Reset();
  55.         void                    Update();
  56.  
  57.         size_t                  GetTreeInstanceCount() const;
  58.         EntityId                GetTreeInstanceEntityIdByIndex(const size_t index) const;
  59.  
  60.         BehaviorTreeInstancePtr CreateBehaviorTreeInstanceFromXml(const char* behaviorTreeName, XmlNodeRef behaviorTreeXmlNode);
  61.  
  62. #ifdef CRYAISYSTEM_DEBUG
  63.         void DrawMemoryInformation();
  64. #endif
  65.  
  66. private:
  67.         BehaviorTreeInstancePtr CreateBehaviorTreeInstanceFromDiskCache(const char* behaviorTreeName);
  68.         BehaviorTreeInstancePtr LoadFromCache(const char* behaviorTreeName);
  69.         bool                    StartBehaviorInstance(const EntityId entityId, BehaviorTreeInstancePtr instance, const char* treeName);
  70.         void                    StopAllBehaviorTreeInstances();
  71.  
  72.         bool                    LoadBehaviorTreeTemplate(const char* behaviorTreeName, XmlNodeRef behaviorTreeXmlNode, BehaviorTreeTemplate& behaviorTreeTemplate);
  73.  
  74.         BehaviorTreeInstance*   GetBehaviorTree(const EntityId entityId) const;
  75.  
  76. #if defined(DEBUG_MODULAR_BEHAVIOR_TREE)
  77.         void UpdateDebugVisualization(UpdateContext updateContext, const EntityId entityId, DebugTree debugTree, BehaviorTreeInstance& instance, IEntity* agentEntity);
  78. #endif // DEBUG_MODULAR_BEHAVIOR_TREE
  79.  
  80. #ifdef USING_BEHAVIOR_TREE_EXECUTION_STACKS_FILE_LOG
  81.         void UpdateExecutionStackLogging(UpdateContext updateContext, const EntityId entityId, DebugTree debugTree, BehaviorTreeInstance& instance);
  82. #endif
  83.  
  84.         std::unique_ptr<NodeFactory>          m_nodeFactory;
  85.         std::unique_ptr<MetaExtensionFactory> m_metaExtensionFactory;
  86.  
  87. #if defined(DEBUG_MODULAR_BEHAVIOR_TREE_WEB)
  88.         void UpdateWebDebugChannel(const EntityId entityId, UpdateContext& updateContext, DebugTree& debugTree, BehaviorTreeInstance& instance, const bool bExecutionError);
  89. #endif
  90.  
  91.         typedef string                                                                                                              BehaviorTreeName;
  92.         typedef std::unordered_map<BehaviorTreeName, BehaviorTreeTemplatePtr, stl::hash_stricmp<string>, stl::hash_stricmp<string>> BehaviorTreeCache;
  93.         BehaviorTreeCache m_behaviorTreeCache;
  94.  
  95.         typedef VectorMap<EntityId, BehaviorTreeInstancePtr> Instances;
  96.         Instances m_instances;
  97.  
  98.         typedef std::vector<EntityId> EntityIdVector;
  99. #ifdef DEBUG_MODULAR_BEHAVIOR_TREE
  100.         EntityIdVector m_errorStatusTrees;
  101. #endif // DEBUG_MODULAR_BEHAVIOR_TREE
  102.  
  103. #ifdef DEBUG_MODULAR_BEHAVIOR_TREE_WEB
  104.         typedef VectorMap<TGameWebDebugClientId, EntityId> WebSubscribers;
  105.         WebSubscribers m_webSubscribers;
  106.         bool           m_bRegisteredAsDebugChannel;
  107. #endif
  108.  
  109. #ifdef USING_BEHAVIOR_TREE_EXECUTION_STACKS_FILE_LOG
  110.         typedef std::shared_ptr<ExecutionStackFileLogger>        ExecutionStackFileLoggerPtr;
  111.         typedef VectorMap<EntityId, ExecutionStackFileLoggerPtr> ExecutionStackFileLoggerInstances;
  112.         ExecutionStackFileLoggerInstances m_executionStackFileLoggerInstances;
  113. #endif
  114. };
  115. }
  116.  
downloadBehaviorTreeManager.h 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