class_name WorkerPrompt extends Control ## ## ## signal prompted() var _worker_thread := Thread.new() ## ## ## @export var label: Label = null ## ## ## @export var progress: Range = null ## ## ## func prompt(display_message: String, steps: Array) -> void: LocalPlayer.override_controls(hidden) show() prompted.emit() if label != null: label.text = display_message _worker_thread.start(func () -> void: var count := steps.size() var total := float(count) for i in count: steps[i].call() if progress != null: progress.value = i / total) while _worker_thread.is_alive(): await get_tree().process_frame _worker_thread.wait_to_finish() hide()