SimpleAI
 All Classes Namespaces Files Functions Variables Typedefs Macros Groups Pages
Selector.h
Go to the documentation of this file.
1 
4 #pragma once
5 
6 #include "tree/TreeNode.h"
7 
8 namespace ai {
9 
10 #define SELECTOR_CLASS(NodeName) \
11  NodeName(const std::string& name, const std::string& parameters, const ConditionPtr& condition) : \
12  Selector(name, parameters, condition) { \
13  _type = AI_STRINGIFY(NodeName); \
14  } \
15  virtual ~NodeName() { \
16  } \
17  \
18  NODE_FACTORY(NodeName)
19 
25 class Selector: public TreeNode {
26 public:
28 
29 
32  virtual void getRunningChildren(const AIPtr& entity, std::vector<bool>& active) const override {
33  int n = 0;
34  int selectorState = getSelectorState(entity);
35  for (TreeNodes::const_iterator i = _children.begin(); i != _children.end(); ++i, ++n) {
36  active.push_back(selectorState == n);
37  }
38  }
39 };
40 
41 }
Base class for all type of TreeNode selectors.
Definition: Selector.h:25
The base class for all behaviour tree actions.
Definition: TreeNode.h:88
#define NODE_CLASS(NodeName)
A node class macro that also defines a factory.
Definition: TreeNode.h:69
virtual void getRunningChildren(const AIPtr &entity, std::vector< bool > &active) const override
Will only deliver valid results if the debugging for the given entity is active.
Definition: Selector.h:32