21 TreeNodeStatus
execute(const AIPtr& entity, int64_t deltaMillis)
override {
25 int index = getSelectorState(entity);
26 if (index == AI_NOTHING_SELECTED) {
29 const std::size_t size = _children.size();
30 TreeNodeStatus overallResult = FINISHED;
31 std::size_t i = index;
32 for (std::size_t j = 0; j < i; ++j) {
33 _children[j]->resetState(entity);
35 for (; i < size; ++i) {
36 const TreeNodePtr& child = _children[i];
37 const TreeNodeStatus result = child->execute(entity, deltaMillis);
38 if (result == RUNNING) {
39 setSelectorState(entity, static_cast<int>(i));
40 }
else if (result == CANNOTEXECUTE || result == FAILED) {
41 child->resetState(entity);
42 setSelectorState(entity, AI_NOTHING_SELECTED);
45 setSelectorState(entity, AI_NOTHING_SELECTED);
47 child->resetState(entity);
48 overallResult = result;
51 for (++i; i < size; ++i) {
52 _children[i]->resetState(entity);
54 return state(entity, overallResult);
virtual TreeNodeStatus execute(const AIPtr &entity, int64_t deltaMillis)
Definition: TreeNodeImpl.h:184
This node tries to execute all the attached children until one succeeds. This composite only fails if...
Definition: PrioritySelector.h:17
Base class for all type of TreeNode selectors.
Definition: Selector.h:25
TreeNodeStatus execute(const AIPtr &entity, int64_t deltaMillis) override
Definition: PrioritySelector.h:21