@@ -34,6 +34,8 @@ void MultiGodot::_bind_methods() {
3434 ClassDB::bind_method (D_METHOD (" _on_p2p_session_request" , " remote_id" ), &MultiGodot::_on_p2p_session_request);
3535 ClassDB::bind_method (D_METHOD (" _on_p2p_session_connect_fail" , " steam_id" , " session_error" ), &MultiGodot::_on_p2p_session_connect_fail);
3636 ClassDB::bind_method (D_METHOD (" _on_nodes_reparented" , " nodes" , " new_parent" ), &MultiGodot::_on_nodes_reparented);
37+ ClassDB::bind_method (D_METHOD (" _on_node_created" , " node" , " type" , " is_custom_type" , " weird_type" ), &MultiGodot::_on_node_created);
38+ ClassDB::bind_method (D_METHOD (" _on_scenes_instantiated" , " parent" , " paths" , " index" ), &MultiGodot::_on_scenes_instantiated);
3739
3840 // Remote Callables
3941
@@ -52,6 +54,8 @@ void MultiGodot::_bind_methods() {
5254 ClassDB::bind_method (D_METHOD (" _apply_action" ), &MultiGodot::_apply_action);
5355 ClassDB::bind_method (D_METHOD (" _instantiate_resource" , " node_path" , " resource_path" , " type" ), &MultiGodot::_instantiate_resource);
5456 ClassDB::bind_method (D_METHOD (" _reparent_nodes" , " old" , " new" ), &MultiGodot::_reparent_nodes);
57+ ClassDB::bind_method (D_METHOD (" _create_node" , " parent_path" , " type" , " is_custom_type" , " weird_type" ), &MultiGodot::_create_node);
58+ ClassDB::bind_method (D_METHOD (" _instantiate_scenes" , " parent_path" , " paths" , " index" ), &MultiGodot::_instantiate_scenes);
5559
5660 // Button signals
5761
@@ -118,7 +122,11 @@ void MultiGodot::_ready() {
118122
119123 filesystem_scanner.start (_threaded_filesystem_scanner, this );
120124
121- SceneTreeDock::get_singleton ()->connect (" nodes_reparented" , Callable (this , " _on_nodes_reparented" ));
125+ SceneTreeDock *scene_tree_dock = SceneTreeDock::get_singleton ();
126+
127+ scene_tree_dock->connect (" nodes_reparented" , Callable (this , " _on_nodes_reparented" ));
128+ scene_tree_dock->connect (" node_created_type" , Callable (this , " _on_node_created" ));
129+ scene_tree_dock->connect (" scenes_instantiated" , Callable (this , " _on_scenes_instantiated" ));
122130 button_notifier->connect (" editor_tab_changed" , Callable (this , " _on_editor_tab_changed" ));
123131 button_notifier->connect (" current_script_path_changed" , Callable (this , " _on_current_script_path_changed" ));
124132 steam->connect (" lobby_created" , Callable (this , " _on_lobby_created" ));
@@ -1125,6 +1133,35 @@ void MultiGodot::_reparent_nodes(Array paths, String new_parent_path) {
11251133 }
11261134}
11271135
1136+ void MultiGodot::_create_node (String parent_path, String type, bool is_custom_type, String weird_type) {
1137+ Node *root = EditorNode::get_singleton ()->get_edited_scene ();
1138+ Node *parent = root->get_node (parent_path);
1139+
1140+ Variant obj;
1141+ if (is_custom_type) {
1142+ if (ScriptServer::is_global_class (type)) {
1143+ obj = EditorNode::get_editor_data ().script_class_instance (type);
1144+ Node *n = Object::cast_to<Node>(obj);
1145+ if (n) {
1146+ n->set_name (type);
1147+ }
1148+ } else {
1149+ obj = EditorNode::get_editor_data ().instantiate_custom_type (weird_type, type);
1150+ }
1151+ } else {
1152+ obj = ClassDB::instantiate (type);
1153+ }
1154+
1155+ obj.operator Object *();
1156+ Node *node = Object::cast_to<Node>(obj);
1157+ parent->add_child (node, true );
1158+ }
1159+
1160+ void MultiGodot::_instantiate_scenes (String parent_path, Vector<String> paths, int index) {
1161+ Node *root = EditorNode::get_singleton ()->get_edited_scene ();
1162+ SceneTreeDock::get_singleton ()->_perform_instantiate_scenes (paths, root->get_node (parent_path), index, false );
1163+ }
1164+
11281165// SIGNALS
11291166
11301167void MultiGodot::_on_lobby_created (int connect, uint64_t this_lobby_id) {
@@ -1290,6 +1327,22 @@ void MultiGodot::_on_nodes_reparented(Array nodes, NodePath new_parent) {
12901327 _call_func (this , " _reparent_nodes" , {nodes, new_parent});
12911328}
12921329
1330+ void MultiGodot::_on_node_created (Node *node, String type, bool is_custom_type, String weird_type) {
1331+ if (VERBOSE_DEBUG) {
1332+ print_line (" Node created with type " + type);
1333+ }
1334+ Node *root = EditorNode::get_singleton ()->get_edited_scene ();
1335+ _call_func (this , " _create_node" , {root->get_path_to (node->get_parent ()), type, is_custom_type, weird_type});
1336+ }
1337+
1338+ void MultiGodot::_on_scenes_instantiated (Node *parent, Vector<String> paths, int index) {
1339+ if (VERBOSE_DEBUG) {
1340+ print_line (" Some scenes were instantiated" );
1341+ }
1342+ Node *root = EditorNode::get_singleton ()->get_edited_scene ();
1343+ _call_func (this , " _instantiate_scenes" , {root->get_path_to (parent), paths, index});
1344+ }
1345+
12931346// PLUGIN
12941347
12951348MultiGodotPlugin::MultiGodotPlugin () {
0 commit comments