31 lines
781 B
C++
31 lines
781 B
C++
#include "behaviour_action.h"
|
|
#include "core/object/object.h"
|
|
|
|
void BehaviourAction::_bind_methods() {
|
|
ClassDB::add_virtual_method(get_class_static(), _gdvirtual__execute_get_method_info());
|
|
ClassDB::add_virtual_method(get_class_static(), _gdvirtual__exit_get_method_info());
|
|
ClassDB::add_virtual_method(get_class_static(), _gdvirtual__enter_get_method_info());
|
|
}
|
|
|
|
void BehaviourAction::enter() {
|
|
GDVIRTUAL_CALL(_enter);
|
|
}
|
|
|
|
void BehaviourAction::execute() {
|
|
Status out_status{ Fail };
|
|
GDVIRTUAL_CALL(_execute, out_status);
|
|
set_status(out_status);
|
|
}
|
|
|
|
void BehaviourAction::exit() {
|
|
GDVIRTUAL_CALL(_exit);
|
|
}
|
|
|
|
BehaviourNode *BehaviourAction::get_next() {
|
|
switch (get_status()) {
|
|
case Running:
|
|
return this;
|
|
default:
|
|
return cast_to<BehaviourNode>(get_parent());
|
|
}
|
|
}
|