# LoadingContext.gd # Autoload Singleton # 负责在 start 场景和 LoadingScene 之间传递加载指令和必要的存档数据。 extends Node # 加载操作的类型 # 可能的值: "new_game", "load_game", 或空字符串 (表示无操作或已处理) var action_to_perform: String = "" # 当 action_to_perform 为 "load_game" 时,这里会存储从 SaveLoadManager 加载到的存档数据字典。 # 其他情况下应为空字典。 var save_data_for_loading: Dictionary = {} # 清理上下文,在 LoadingScene 读取完数据后调用,避免旧数据影响下一次加载。 func clear_context() -> void: action_to_perform = "" save_data_for_loading = {} print("LoadingContext: Context cleared.") # (可选) 一个辅助函数,用于在设置上下文时打印信息,方便调试 func set_context(action: String, data: Dictionary = {}) -> void: action_to_perform = action save_data_for_loading = data.duplicate(true) # 使用深拷贝以防外部修改 print("LoadingContext: Context set - Action: ", action_to_perform, ", Data keys: ", save_data_for_loading.keys())