diff --git a/.gitignore b/.gitignore index a9d162a..1802f0b 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ logs/ .godot/imported/ .godot/editor shader_cache/ +.import/ diff --git a/Autoload/Autoload.gd b/Autoload/Autoload.gd index e20df98..92bb590 100644 --- a/Autoload/Autoload.gd +++ b/Autoload/Autoload.gd @@ -24,9 +24,18 @@ const alone_steps: Array = [ "res://AutomaticBugs/FunctionExecutor.tscn", # Only runs ] +var time_object : Object func _init(): - start_time = OS.get_ticks_msec() + if ClassDB.class_exists("_Time"): + time_object = ClassDB.instance("_Time") + elif ClassDB.class_exists("Time"): + time_object = ClassDB.instance("_Time") + else: + time_object = ClassDB.instance("_OS") + + + start_time = time_object.get_ticks_msec() # In case when user doesn't provide time time_for_each_step = time_to_show / (alone_steps.size()) @@ -40,7 +49,7 @@ func _init(): func _process(delta: float) -> void: - var current_run_time: int = OS.get_ticks_msec() - start_time + var current_run_time: int = time_object.get_ticks_msec() - start_time # While loop instead if, will allow to properly flush results under heavy operations(e.g. Thread sanitizer) while current_run_time > time_to_print_next_time: @@ -50,3 +59,6 @@ func _process(delta: float) -> void: if current_run_time > time_to_show && can_be_closed: print("######################## Ending test ########################") get_tree().quit() + +func _exit_tree() -> void: + time_object.free() diff --git a/Start.gd b/Start.gd index 4e37154..cae8aae 100644 --- a/Start.gd +++ b/Start.gd @@ -11,11 +11,11 @@ func _ready(): Autoload.can_be_closed = false for i in Autoload.alone_steps.size() + 1: - array_with_time_to_change.append(OS.get_ticks_msec() + i * Autoload.time_for_each_step) + array_with_time_to_change.append(Autoload.time_object.get_ticks_msec() + i * Autoload.time_for_each_step) func _process(_delta): - if current_scene < Autoload.alone_steps.size() - 1 && OS.get_ticks_msec() > array_with_time_to_change[current_scene + 1]: + if current_scene < Autoload.alone_steps.size() - 1 && Autoload.time_object.get_ticks_msec() > array_with_time_to_change[current_scene + 1]: current_scene += 1 if current_scene == Autoload.alone_steps.size() - 1: Autoload.can_be_closed = true