MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _node_call_func

Method _node_call_func

scene/debugger/scene_debugger.cpp:1089–1151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1087}
1088
1089void LiveEditor::_node_call_func(int p_id, const StringName &p_method, const Variant **p_args, int p_argcount) {
1090 SceneTree *scene_tree = SceneTree::get_singleton();
1091 if (!scene_tree) {
1092 return;
1093 }
1094 if (!live_edit_node_path_cache.has(p_id)) {
1095 return;
1096 }
1097
1098 NodePath np = live_edit_node_path_cache[p_id];
1099 Node *base = nullptr;
1100 if (scene_tree->root->has_node(live_edit_root)) {
1101 base = scene_tree->root->get_node(live_edit_root);
1102 }
1103
1104 HashMap<String, HashSet<Node *>>::Iterator E = live_scene_edit_cache.find(live_edit_scene);
1105 if (!E) {
1106 return; //scene not editable
1107 }
1108
1109 for (Node *F : E->value) {
1110 Node *n = F;
1111
1112 if (base && !base->is_ancestor_of(n)) {
1113 continue;
1114 }
1115
1116 if (!n->has_node(np)) {
1117 continue;
1118 }
1119 Node *n2 = n->get_node(np);
1120
1121 // Do not change transform of edited scene root, unless it's the scene being played.
1122 // See GH-86659 for additional context.
1123 bool keep_transform = (n2 == n) && (n2->get_parent() != scene_tree->root);
1124 Variant orig_tf;
1125
1126 if (keep_transform) {
1127 if (n2->is_class("Node3D")) {
1128 orig_tf = n2->call("get_transform");
1129 } else if (n2->is_class("CanvasItem")) {
1130 orig_tf = n2->call("_edit_get_state");
1131 }
1132 }
1133
1134 Callable::CallError ce;
1135 n2->callp(p_method, p_args, p_argcount, ce);
1136
1137 if (keep_transform) {
1138 if (n2->is_class("Node3D")) {
1139 Variant new_tf = n2->call("get_transform");
1140 if (new_tf != orig_tf) {
1141 n2->call("set_transform", orig_tf);
1142 }
1143 } else if (n2->is_class("CanvasItem")) {
1144 Variant new_tf = n2->call("_edit_get_state");
1145 if (new_tf != orig_tf) {
1146 n2->call("_edit_set_state", orig_tf);

Callers 1

_msg_live_node_callMethod · 0.80

Calls 9

is_ancestor_ofMethod · 0.80
hasMethod · 0.45
has_nodeMethod · 0.45
get_nodeMethod · 0.45
findMethod · 0.45
get_parentMethod · 0.45
is_classMethod · 0.45
callMethod · 0.45
callpMethod · 0.45

Tested by

no test coverage detected