From 80187caa5471757f4a875e24a7c2c4870741396b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= <41945903+qarmin@users.noreply.github.com> Date: Tue, 22 Jun 2021 07:00:48 +0200 Subject: [PATCH] AB (#57) --- AutomaticBugs/BasicData.gd | 2 +- AutomaticBugs/ValueCreator.gd | 30 +++++++++++----------- Nodes/Nodes.gd | 2 +- ReparentingDeleting/ReparentingDeleting.gd | 2 +- Start.gd | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/AutomaticBugs/BasicData.gd b/AutomaticBugs/BasicData.gd index b675fc9..0505e0c 100644 --- a/AutomaticBugs/BasicData.gd +++ b/AutomaticBugs/BasicData.gd @@ -295,7 +295,7 @@ func get_list_of_available_classes(must_be_instantable : bool = true) -> Array: continue - if !must_be_instantable || ClassDB.can_instance(name_of_class): + if !must_be_instantable || ClassDB.can_instantiate(name_of_class): classes.push_back(name_of_class) c+= 1 diff --git a/AutomaticBugs/ValueCreator.gd b/AutomaticBugs/ValueCreator.gd index 1e4f1d8..3da74d4 100644 --- a/AutomaticBugs/ValueCreator.gd +++ b/AutomaticBugs/ValueCreator.gd @@ -279,7 +279,7 @@ func get_object(object_name: String) -> Object: while true: var choosen_class: String = classes[randi() % classes.size()] if ( - ClassDB.can_instance(choosen_class) + ClassDB.can_instantiate(choosen_class) && (ClassDB.is_parent_class(choosen_class, "Node") || obj_is_reference(choosen_class)) && !(choosen_class in BasicData.disabled_classes) ): @@ -289,7 +289,7 @@ func get_object(object_name: String) -> Object: if should_be_always_valid: var to_use_classes = ClassDB.get_inheriters_from_class(object_name) to_use_classes.append(object_name) - if !ClassDB.can_instance(object_name) && object_name in BasicData.disabled_classes: + if !ClassDB.can_instantiate(object_name) && object_name in BasicData.disabled_classes: assert(to_use_classes.size() > 0, "Cannot find proper instantable child for ") while true: @@ -299,7 +299,7 @@ func get_object(object_name: String) -> Object: # This shouldn't happens, but sadly happen with e.g. SpatialGizmo assert(false, "Cannot find proper instantable child for ") var choosen_class: String = to_use_classes[randi() % to_use_classes.size()] - if ClassDB.can_instance(choosen_class) && !(choosen_class in BasicData.disabled_classes): + if ClassDB.can_instantiate(choosen_class) && !(choosen_class in BasicData.disabled_classes): return Autoload.get_instance_from_name(choosen_class) else: while true: @@ -307,13 +307,13 @@ func get_object(object_name: String) -> Object: if a > 50: assert(false, "Cannot find proper instantable child for ") var choosen_class: String = classes[randi() % classes.size()] - if ClassDB.can_instance(choosen_class) && !ClassDB.is_parent_class(choosen_class, object_name) && !(choosen_class in BasicData.disabled_classes): + if ClassDB.can_instantiate(choosen_class) && !ClassDB.is_parent_class(choosen_class, object_name) && !(choosen_class in BasicData.disabled_classes): return Autoload.get_instance_from_name(choosen_class) # Non Node/Resource object var to_use_classes = ClassDB.get_inheriters_from_class(object_name) to_use_classes.append(object_name) - if !ClassDB.can_instance(object_name) && object_name in BasicData.disabled_classes: + if !ClassDB.can_instantiate(object_name) && object_name in BasicData.disabled_classes: assert(to_use_classes.size() > 0, "Cannot find proper instantable child for ") while true: @@ -323,17 +323,17 @@ func get_object(object_name: String) -> Object: # This shouldn't happens, but sadly happen with e.g. SpatialGizmo assert(false, "Cannot find proper instantable child for ") var choosen_class: String = to_use_classes[randi() % to_use_classes.size()] - if ClassDB.can_instance(choosen_class) && !(choosen_class in BasicData.disabled_classes): + if ClassDB.can_instantiate(choosen_class) && !(choosen_class in BasicData.disabled_classes): return Autoload.get_instance_from_name(choosen_class) else: - if ClassDB.can_instance(object_name): # E.g. Texture is not instantable or shouldn't be, but LargeTexture is + if ClassDB.can_instantiate(object_name): # E.g. Texture is not instantable or shouldn't be, but LargeTexture is return Autoload.get_instance_from_name(object_name) else: # Found child of non instantable object var list_of_class = ClassDB.get_inheriters_from_class(object_name) assert(list_of_class.size() > 0, "Cannot find proper instantable child for ") # Number of inherited class of non instantable class must be greater than 0, otherwise this function would be useless for i in list_of_class: - if ClassDB.can_instance(i) && (ClassDB.is_parent_class(i, "Node") || obj_is_reference(i)): + if ClassDB.can_instantiate(i) && (ClassDB.is_parent_class(i, "Node") || obj_is_reference(i)): return Autoload.get_instance_from_name(i) assert(false, "Cannot find proper instantable child for ") @@ -352,14 +352,14 @@ func get_object_string(object_name: String) -> String: if object_name == "Object": while true: var choosen_class: String = classes[randi() % classes.size()] - if ClassDB.can_instance(choosen_class) && (ClassDB.is_parent_class(choosen_class, "Node") || obj_is_reference(choosen_class)): + if ClassDB.can_instantiate(choosen_class) && (ClassDB.is_parent_class(choosen_class, "Node") || obj_is_reference(choosen_class)): return choosen_class if ClassDB.is_parent_class(object_name, "Node") || obj_is_reference(object_name): if should_be_always_valid: var to_use_classes = ClassDB.get_inheriters_from_class(object_name) to_use_classes.append(object_name) - if !ClassDB.can_instance(object_name): + if !ClassDB.can_instantiate(object_name): assert(to_use_classes.size() > 0, "Cannot find proper instantable child for ") while true: @@ -369,7 +369,7 @@ func get_object_string(object_name: String) -> String: # This shouldn't happens, but sadly happen with e.g. SpatialGizmo assert(false, "Cannot find proper instantable child for ") var choosen_class: String = to_use_classes[randi() % to_use_classes.size()] - if ClassDB.can_instance(choosen_class): + if ClassDB.can_instantiate(choosen_class): return choosen_class else: while true: @@ -383,7 +383,7 @@ func get_object_string(object_name: String) -> String: # Non Node/Resource object var to_use_classes = ClassDB.get_inheriters_from_class(object_name) to_use_classes.append(object_name) - if !ClassDB.can_instance(object_name) && object_name in BasicData.disabled_classes: + if !ClassDB.can_instantiate(object_name) && object_name in BasicData.disabled_classes: assert(to_use_classes.size() > 0, "Cannot find proper instantable child for ") while true: @@ -393,17 +393,17 @@ func get_object_string(object_name: String) -> String: # This shouldn't happens, but sadly happen with e.g. SpatialGizmo assert(false, "Cannot find proper instantable child for ") var choosen_class: String = to_use_classes[randi() % to_use_classes.size()] - if ClassDB.can_instance(choosen_class) && !(choosen_class in BasicData.disabled_classes): + if ClassDB.can_instantiate(choosen_class) && !(choosen_class in BasicData.disabled_classes): return choosen_class else: - if ClassDB.can_instance(object_name): # E.g. Texture is not instantable or shouldn't be, but LargeTexture is + if ClassDB.can_instantiate(object_name): # E.g. Texture is not instantable or shouldn't be, but LargeTexture is return object_name else: # Found child of non instantable object var list_of_class = ClassDB.get_inheriters_from_class(object_name) assert(list_of_class.size() > 0, "Cannot find proper instantable child for ") # Number of inherited class of non instantable class must be greater than 0, otherwise this function would be useless for i in list_of_class: - if ClassDB.can_instance(i) && (ClassDB.is_parent_class(i, "Node") || obj_is_reference(i)): + if ClassDB.can_instantiate(i) && (ClassDB.is_parent_class(i, "Node") || obj_is_reference(i)): return i assert(false, "Cannot find proper instantable child for ") diff --git a/Nodes/Nodes.gd b/Nodes/Nodes.gd index 8774c50..adae39e 100644 --- a/Nodes/Nodes.gd +++ b/Nodes/Nodes.gd @@ -17,7 +17,7 @@ func _populate() -> void: for name_of_class in ClassDB.get_class_list(): if name_of_class in disabled_classes: continue - if !ClassDB.can_instance(name_of_class): + if !ClassDB.can_instantiate(name_of_class): continue diff --git a/ReparentingDeleting/ReparentingDeleting.gd b/ReparentingDeleting/ReparentingDeleting.gd index 8a40f96..b7a1b52 100644 --- a/ReparentingDeleting/ReparentingDeleting.gd +++ b/ReparentingDeleting/ReparentingDeleting.gd @@ -24,7 +24,7 @@ func collect() -> void: continue if disabled_classes.has(name_of_class): # Class is disabled continue - if ClassDB.can_instance(name_of_class): # Only instantable nodes can be used + if ClassDB.can_instantiate(name_of_class): # Only instantable nodes can be used collected_nodes.append(name_of_class) func _ready() -> void: diff --git a/Start.gd b/Start.gd index 90a4d58..7837968 100644 --- a/Start.gd +++ b/Start.gd @@ -22,5 +22,5 @@ func _process(_delta): print("Changed scene to " + Autoload.alone_steps[current_scene]) for _i in range(NUMBER_OF_INSTANCES): - var scene: Node = load(Autoload.alone_steps[current_scene]).instance() + var scene: Node = load(Autoload.alone_steps[current_scene]).instantiate() add_child(scene)