Atoms Crowd  7.0.0
BehaviourTreeModule.h
1 #pragma once
2 // ===========================================================================
3 // Copyright (c) 2015 Toolchefs Ltd. All rights reserved.
4 //
5 // Use of this software is subject to the terms of the Toolchefs license
6 // agreement provided at the time of installation or download, or which
7 // otherwise accompanies this software in either electronic or hard copy form.
8 // ===========================================================================
9 
10 #include <Atoms/BehaviourModule.h>
11 #include <Atoms/BehaviourTree/BehaviourTree.h>
12 #include <Atoms/BehaviourTree/BehaviourTreeContext.h>
13 #include <map>
14 #include <AtomsModules/Globals.h>
15 
16 namespace AtomsModules
17 {
18  class ATOMSMODULES_EXPORT BehaviourTreeModule : public Atoms::BehaviourModule
19  {
20  public:
22 
24 
25  void initSimulation(Atoms::AgentGroup* agentGroup = nullptr);
26 
27  void agentsCreated(const std::vector<Atoms::Agent*>& agents, Atoms::AgentGroup* agentGroup = nullptr);
28 
29  void agentsKilled(const std::vector<Atoms::Agent*>& agents, Atoms::AgentGroup* agentGroup= nullptr);
30 
31  void initFrame(const std::vector<Atoms::Agent*>& agents, Atoms::AgentGroup* agentGroup = nullptr);
32 
33  void endFrame(const std::vector<Atoms::Agent*>& agents, Atoms::AgentGroup* agentGroup = nullptr);
34 
35  void prePhysics(const std::vector<Atoms::Agent*>& agents, Atoms::AgentGroup* agentGroup = nullptr);
36 
37  void postPhysics(const std::vector<Atoms::Agent*>& agents, Atoms::AgentGroup* agentGroup = nullptr);
38 
39  void tickTree(const std::vector<Atoms::Agent*>& agents, Atoms::AgentGroup* agentGroup = nullptr);
40 
41  static Atoms::BehaviourModule* creator(const std::string& parameter);
42 
43  bool hasDynamicAttributes() const;
44 
46 
47  void getContextIndexes(std::vector<int> &indexes) const;
48  const Atoms::BehaviourTreeContext* getContext(const int groupId) const;
49 
50  private:
51 
53  Atoms::Blackboard blackboard;
54  Atoms::BlackboardInstance blackboardInstance;
55  std::map<int, Atoms::BehaviourTreeContext> contexts;
56  std::mutex mutex;
57  std::vector<Atoms::BlackboardEntryPosition> cachedMetadata;
58  bool hasPythonNodes;
59 
60  };
61 }
Agent group.
Definition: AgentGroup.h:36
Behaviour module.
Definition: BehaviourModule.h:32
Definition: BehaviourTreeContext.h:24
Definition: BehaviourTree.h:27
Definition: Blackboard.h:35
Definition: Blackboard.h:76
Definition: BehaviourTreeModule.h:19
void initSimulation(Atoms::AgentGroup *agentGroup=nullptr)
Init simulation.
void prePhysics(const std::vector< Atoms::Agent * > &agents, Atoms::AgentGroup *agentGroup=nullptr)
Pre Physics.
void agentsCreated(const std::vector< Atoms::Agent * > &agents, Atoms::AgentGroup *agentGroup=nullptr)
Agents Created.
void refreshAttributes()
Refresh the attribute map metadata.
void initFrame(const std::vector< Atoms::Agent * > &agents, Atoms::AgentGroup *agentGroup=nullptr)
Init frame.
void postPhysics(const std::vector< Atoms::Agent * > &agents, Atoms::AgentGroup *agentGroup=nullptr)
Post Physics.
void agentsKilled(const std::vector< Atoms::Agent * > &agents, Atoms::AgentGroup *agentGroup=nullptr)
Post frame.
bool hasDynamicAttributes() const
Check if this module can generate attribute dynamically.
void endFrame(const std::vector< Atoms::Agent * > &agents, Atoms::AgentGroup *agentGroup=nullptr)
End frame.