22 TreeNodeStatus
execute(const AIPtr& entity, int64_t deltaMillis)
override {
27 TreeNodes childrenShuffled = _children;
28 const std::size_t size = childrenShuffled.size();
29 ai::shuffle(childrenShuffled.begin(), childrenShuffled.end());
30 TreeNodeStatus overallResult = FINISHED;
32 for (i = 0; i < size; ++i) {
33 const TreeNodePtr& child = childrenShuffled[i];
34 const TreeNodeStatus result = child->execute(entity, deltaMillis);
35 if (result == RUNNING) {
37 }
else if (result == CANNOTEXECUTE || result == FAILED) {
38 overallResult = result;
40 child->resetState(entity);
42 for (++i; i < size; ++i) {
43 childrenShuffled[i]->resetState(entity);
45 return state(entity, overallResult);
virtual TreeNodeStatus execute(const AIPtr &entity, int64_t deltaMillis)
Definition: TreeNodeImpl.h:184
Base class for all type of TreeNode selectors.
Definition: Selector.h:25
TreeNodeStatus execute(const AIPtr &entity, int64_t deltaMillis) override
Definition: RandomSelector.h:22
This node executes all the attached children in random order. This composite only fails if all childr...
Definition: RandomSelector.h:18