summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-08-21 23:21:47 +0200
committerGitHub <noreply@github.com>2017-08-21 23:21:47 +0200
commitd37bd15cb92295ef22731a2ab171d0647ff541db (patch)
tree5364852006018d2d2b59a97c8f5d51c919ef4c82 /scene/main
parentc9b0787724474d1740abd5638b3eb4e7a8e94192 (diff)
parent390f7def39a6ff9a34a3a85f6b180d341b52d869 (diff)
Merge pull request #10443 from karroffel/propagate_call
add "propagate_call" method to Node
Diffstat (limited to 'scene/main')
-rwxr-xr-xscene/main/node.cpp18
-rw-r--r--scene/main/node.h2
2 files changed, 20 insertions, 0 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 0474c6fd26..8a31b1ef01 100755
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -1954,6 +1954,23 @@ void Node::propagate_notification(int p_notification) {
data.blocked--;
}
+void Node::propagate_call(const StringName &p_method, const Array &p_args, const bool p_parent_first) {
+
+ data.blocked++;
+
+ if (p_parent_first && has_method(p_method))
+ callv(p_method, p_args);
+
+ for (int i = 0; i < data.children.size(); i++) {
+ data.children[i]->propagate_call(p_method, p_args, p_parent_first);
+ }
+
+ if (!p_parent_first && has_method(p_method))
+ callv(p_method, p_args);
+
+ data.blocked--;
+}
+
void Node::_propagate_replace_owner(Node *p_owner, Node *p_by_owner) {
if (get_owner() == p_owner)
set_owner(p_by_owner);
@@ -2761,6 +2778,7 @@ void Node::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_filename", "filename"), &Node::set_filename);
ClassDB::bind_method(D_METHOD("get_filename"), &Node::get_filename);
ClassDB::bind_method(D_METHOD("propagate_notification", "what"), &Node::propagate_notification);
+ ClassDB::bind_method(D_METHOD("propagate_call", "method", "args", "parent_first"), &Node::propagate_call, DEFVAL(Array()), DEFVAL(false));
ClassDB::bind_method(D_METHOD("set_fixed_process", "enable"), &Node::set_fixed_process);
ClassDB::bind_method(D_METHOD("get_fixed_process_delta_time"), &Node::get_fixed_process_delta_time);
ClassDB::bind_method(D_METHOD("is_fixed_processing"), &Node::is_fixed_processing);
diff --git a/scene/main/node.h b/scene/main/node.h
index bb8d80a0c8..180ec05773 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -298,6 +298,8 @@ public:
void propagate_notification(int p_notification);
+ void propagate_call(const StringName &p_method, const Array &p_args = Array(), const bool p_parent_first = false);
+
/* PROCESSING */
void set_fixed_process(bool p_process);
float get_fixed_process_delta_time() const;