dungeon/src/IfHealthBelow.cpp

18 lines
476 B
C++
Raw 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;
}
IfHealthBelow::~IfHealthBelow() {}
BehaviourTreeStatus IfHealthBelow::tick(BTTick * tick) {
if (children.size() == 0) return BT_ERROR;
if (tick->target->health < healthBelow) {
return children[0]->execute(tick);
}
return BT_FAILED;
}