summaryrefslogtreecommitdiff
path: root/engine-ocean/Game/Systems/AI/btselector.cpp
blob: 96528389e0753095b6831f9a6dee3e2190e20ad2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "btselector.h"
#include <iostream>

BTSelector::BTSelector()
{

}

void BTSelector::addChildren(BTNode* node){
    m_children.push_back(node);
}

Status BTSelector::update(float seconds){
    // update each children until one doesnt fail
    for (auto node : m_children){
        Status result = node->update(seconds);

        // select this one and return its status --> this node is currently running
        if (result != Status::FAIL){
            m_selected_node = node;
            return result;
        }
    }

    // otherwise if all children fail, then fail this selector
    return Status::FAIL;
}

void BTSelector::reset(){}