Files
aibis-dream/Assets/Scripts/SaveSystem/SnapshotService.cs
T
dingyuntian cc3e1dd138 refactor(save): 合并 SaveSystem 过度拆分的文件
将以下小文件合并到相关核心类中,减少文件数量并保持职责清晰:
- SaveSnapshotSummary -> SaveSnapshot
- SnapshotProviderIds + SnapshotBootstrap -> SnapshotRegistry
- SnapshotSectionDeserializer -> SnapshotRestore
- SnapshotSerializer -> SnapshotPersistence

同步更新 SnapshotService 与 YarnVariableStorage 的调用点。
2026-06-12 17:40:36 +08:00

39 lines
1.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections;
namespace AibisDream.SaveSystem
{
/// <summary>
/// 快照层对外 APICapture / Restore,不涉及文件与 UI。
/// 游戏逻辑应优先使用 <see cref="SaveRestoreOrchestrator"/> 完成存读档流程。
/// </summary>
public static class SnapshotService
{
/// <summary>捕获当前运行时快照。</summary>
public static SaveSnapshot Capture()
{
SnapshotRegistry.EnsureInitialized();
return SnapshotCapture.Capture(YarnVariableStorage.Instance);
}
/// <summary>
/// 还原快照。默认在 provider 还原后继续执行 <see cref="SnapshotRestore.RestoreAnchor"/>。
/// </summary>
/// <param name="restoreAnchor">为 false 时仅还原状态,不重进 Yarn 节点(供 P4 编排使用)。</param>
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);
}
}
}
}