Add 'modules/behaviour_nodes/' from commit 'd51f4da2a9'
git-subtree-dir: modules/behaviour_nodes git-subtree-mainline:07d69bf55egit-subtree-split:d51f4da2a9
This commit is contained in:
commit
5c8fb517a0
17 changed files with 560 additions and 0 deletions
29
modules/behaviour_nodes/behaviour_composite.cpp
Normal file
29
modules/behaviour_nodes/behaviour_composite.cpp
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include "behaviour_composite.h"
|
||||
#include "core/variant/typed_array.h"
|
||||
|
||||
void BehaviourComposite::_bind_methods() {}
|
||||
|
||||
void BehaviourComposite::child_order_changed() {
|
||||
this->child_behaviours.clear();
|
||||
for (Variant var : get_children()) {
|
||||
if (BehaviourNode * node{ cast_to<BehaviourNode>(var) }) {
|
||||
this->child_behaviours.push_back(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BehaviourComposite::_notification(int what) {
|
||||
switch (what) {
|
||||
default:
|
||||
return;
|
||||
case NOTIFICATION_READY:
|
||||
child_order_changed();
|
||||
set_leaf(get_child_behaviours().is_empty());
|
||||
return;
|
||||
case NOTIFICATION_CHILD_ORDER_CHANGED:
|
||||
if (is_ready()) {
|
||||
child_order_changed();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue