SimpleAI
 All Classes Namespaces Files Functions Variables Typedefs Macros Groups Pages
Succeed.h
Go to the documentation of this file.
1 
4 #pragma once
5 
6 #include "tree/TreeNode.h"
7 #include "common/Types.h"
8 
9 namespace ai {
10 
16 class Succeed: public TreeNode {
17 public:
19 
20  TreeNodeStatus execute(const AIPtr& entity, int64_t deltaMillis) override {
21  if (_children.size() != 1) {
22  ai_assert(false, "Succeed must have exactly one child");
23  }
24 
25  if (TreeNode::execute(entity, deltaMillis) == CANNOTEXECUTE) {
26  return CANNOTEXECUTE;
27  }
28 
29  const TreeNodePtr& treeNode = *_children.begin();
30  const TreeNodeStatus status = treeNode->execute(entity, deltaMillis);
31  if (status == RUNNING) {
32  return state(entity, RUNNING);
33  }
34  return state(entity, FINISHED);
35  }
36 };
37 
38 }
#define ai_assert(condition,...)
Provide your own assert - this is only executed in DEBUG mode.
Definition: Types.h:75
virtual TreeNodeStatus execute(const AIPtr &entity, int64_t deltaMillis)
Definition: TreeNodeImpl.h:184
A decorator node with only one child attached. The result of the attached child is only taken into ac...
Definition: Succeed.h:16
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
TreeNodeStatus execute(const AIPtr &entity, int64_t deltaMillis) override
Definition: Succeed.h:20