dungeon/src/IfHealthBelow.cpp

18 lines
486 B
C++
Raw Permalink Normal View History

2017-09-17 13:43:13 +02:00
#include "IfHealthBelow.h"
#include "BehaviourTree.h"
#include "Actor.h"
IfHealthBelow::IfHealthBelow(BehaviourTreeNode * root, int healthBelow) : BehaviourTreeNode(root) {
this->healthBelow = healthBelow;
}
2017-09-26 15:49:11 +02:00
IfHealthBelow::~IfHealthBelow() = default;
2017-09-17 13:43:13 +02:00
BehaviourTreeStatus IfHealthBelow::tick(BTTick * tick) {
2017-09-26 15:49:11 +02:00
if (children.empty()) return BT_ERROR;
if (tick->target->get_health() < healthBelow) {
2017-09-17 13:43:13 +02:00
return children[0]->execute(tick);
}
return BT_FAILED;
}