extends RefCounted ## Aisla todas las suites del perfil del jugador. Nunca escribe ni borra su guardado. ## Funciona tanto si el runner cargo autoloads como si usa un SceneTree independiente. static func prepare(tree: SceneTree) -> PlayerProgressStore: var path: String = "user://__test_progress_%d_%d.json" % [OS.get_process_id(), Time.get_ticks_usec()] var profile: PlayerProgressStore = tree.root.get_node_or_null("PlayerProgress") as PlayerProgressStore if profile == null: profile = preload("res://game/player_progress.tscn").instantiate() as PlayerProgressStore profile.name = "PlayerProgress" profile.save_path = path tree.root.add_child(profile) else: profile.save_path = path profile.set("_owned_ids", {}) profile.set("_save_blocked", false) profile.set("_primary_is_valid", false) profile.last_error = "" profile.tree_exiting.connect(_remove_test_files.bind(path)) return profile static func _remove_test_files(path: String) -> void: if not path.begins_with("user://__test_progress_"): return for suffix: String in ["", ".tmp", ".bak"]: if FileAccess.file_exists(path + suffix): DirAccess.remove_absolute(ProjectSettings.globalize_path(path + suffix))