summaryrefslogtreecommitdiff
path: root/engine-ocean/Game/Systems/AI/btsequence.cpp
blob: ba6169d16a32094824552d3da4b34a6be7e99a2e (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
30
#include "btsequence.h"
#include <vector>

BTSequence::BTSequence()
{

}

void BTSequence::addChildren(BTNode *node){
    m_sequence.push_back(node);
}

Status BTSequence::update(float seconds){

    for (auto node : m_sequence){
        if (node->update(seconds) == Status::FAIL){
            return Status::RUNNING;
        }
        // if come across any node that fails
        if (node->update(seconds) == Status::FAIL){
            return Status::FAIL;
        }
    }

    // if no node is fail or running, sequence is completed
    return Status::SUCCESS;
}

void BTSequence::reset(){}