authority/decorator_nodes.cpp
2026-03-13 10:38:52 +01:00

30 lines
955 B
C++

#include "decorator_nodes.h"
#include "behaviour_nodes/behaviour_node.h"
#include "core/variant/variant.h"
void BehaviourAlwaysSuccess::_bind_methods() {}
PackedStringArray BehaviourAlwaysSuccess::get_configuration_warnings() const {
PackedStringArray warnings{ super_type::get_configuration_warnings() };
if (get_child_behaviours().size() != 1) {
warnings.push_back("BehaviourAlwaysSuccess should have exactly one child");
}
return warnings;
}
void BehaviourAlwaysSuccess::execute() {
if (get_child_behaviours().is_empty()) {
set_status(Fail);
ERR_FAIL_EDMSG("BehaviourSequence executed with no children.");
} else if (get_status() == Running) {
set_status(get_child_behaviours().get(0)->get_status() == Running ? Running : Success);
} else {
set_status(Running);
}
}
BehaviourNode *BehaviourAlwaysSuccess::get_next() {
return get_status() == Running
? get_child_behaviours().get(0)
: cast_to<BehaviourNode>(get_parent());
}