1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Add is_instance() helper method to Node

This commit is contained in:
kobewi
2024-12-15 17:01:30 +01:00
parent 4d1f26e1fd
commit 11adf408ab
8 changed files with 29 additions and 26 deletions

View File

@@ -732,7 +732,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Has
// save the child instantiated scenes that are chosen as editable, so they can be restored
// upon load back
if (p_node != p_owner && !p_node->get_scene_file_path().is_empty() && p_owner->is_editable_instance(p_node)) {
if (p_node != p_owner && p_node->is_instance() && p_owner->is_editable_instance(p_node)) {
editable_instances.push_back(p_owner->get_path_to(p_node));
// Node is the root of an editable instance.
is_editable_instance = true;
@@ -766,7 +766,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Has
bool instantiated_by_owner = false;
Vector<SceneState::PackState> states_stack = PropertyUtils::get_node_states_stack(p_node, p_owner, &instantiated_by_owner);
if (!p_node->get_scene_file_path().is_empty() && p_node->get_owner() == p_owner && instantiated_by_owner) {
if (p_node->is_instance() && p_node->get_owner() == p_owner && instantiated_by_owner) {
if (p_node->get_scene_instance_load_placeholder()) {
//it's a placeholder, use the placeholder path
nd.instance = _vm_get_variant(p_node->get_scene_file_path(), variant_map);
@@ -1106,7 +1106,7 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, HashMap<String
ERR_CONTINUE(!common_parent);
if (common_parent != p_owner && common_parent->get_scene_file_path().is_empty()) {
if (common_parent != p_owner && !common_parent->is_instance()) {
common_parent = common_parent->get_owner();
}
@@ -1166,8 +1166,7 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, HashMap<String
nl = nullptr;
} else {
if (!nl->get_scene_file_path().is_empty()) {
//is an instance
if (nl->is_instance()) {
Ref<SceneState> state = nl->get_scene_instance_state();
if (state.is_valid()) {
int from_node = state->find_node_by_path(nl->get_path_to(p_node));