This commit is contained in:
Rafał Mikrut 2021-06-22 07:00:48 +02:00 committed by GitHub
parent 87cf21e0e5
commit 80187caa54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 19 deletions

View File

@ -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

View File

@ -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 ")

View File

@ -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

View File

@ -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:

View File

@ -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)