using System.Collections; namespace AibisDream.SaveSystem { /// /// 快照层对外 API:Capture / Restore,不涉及文件与 UI。 /// 游戏逻辑应优先使用 完成存读档流程。 /// public static class SnapshotService { /// 捕获当前运行时快照。 public static SaveSnapshot Capture() { SnapshotRegistry.EnsureInitialized(); return SnapshotCapture.Capture(YarnVariableStorage.Instance); } /// /// 还原快照。默认在 provider 还原后继续执行 。 /// /// 为 false 时仅还原状态,不重进 Yarn 节点(供 P4 编排使用)。 public static IEnumerator Restore(SaveSnapshot snapshot, bool restoreAnchor = true) { if (snapshot == null) { yield break; } SnapshotRegistry.EnsureInitialized(); yield return SnapshotRestore.Restore(YarnVariableStorage.Instance, snapshot); if (restoreAnchor) { yield return SnapshotRestore.RestoreAnchor(snapshot); } } } }