| 79 | } |
| 80 | |
| 81 | Node *InstancePlaceholder::create_instance(bool p_replace, const Ref<PackedScene> &p_custom_scene) { |
| 82 | ERR_FAIL_COND_V(!is_inside_tree(), nullptr); |
| 83 | |
| 84 | Node *base = get_parent(); |
| 85 | if (!base) { |
| 86 | return nullptr; |
| 87 | } |
| 88 | |
| 89 | Ref<PackedScene> ps; |
| 90 | if (p_custom_scene.is_valid()) { |
| 91 | ps = p_custom_scene; |
| 92 | } else { |
| 93 | ps = ResourceLoader::load(path, "PackedScene"); |
| 94 | } |
| 95 | |
| 96 | if (ps.is_null()) { |
| 97 | return nullptr; |
| 98 | } |
| 99 | Node *instance = ps->instantiate(); |
| 100 | if (!instance) { |
| 101 | return nullptr; |
| 102 | } |
| 103 | instance->set_name(get_name()); |
| 104 | instance->set_multiplayer_authority(get_multiplayer_authority()); |
| 105 | int pos = get_index(); |
| 106 | |
| 107 | for (const PropSet &E : stored_values) { |
| 108 | set_value_on_instance(this, instance, E); |
| 109 | } |
| 110 | |
| 111 | if (p_replace) { |
| 112 | queue_free(); |
| 113 | base->remove_child(this); |
| 114 | } |
| 115 | |
| 116 | base->add_child(instance); |
| 117 | base->move_child(instance, pos); |
| 118 | |
| 119 | return instance; |
| 120 | } |
| 121 | |
| 122 | void InstancePlaceholder::set_value_on_instance(InstancePlaceholder *p_placeholder, Node *p_instance, const PropSet &p_set) { |
| 123 | bool is_valid; |
nothing calls this directly
no test coverage detected