using System; using System.Collections.Generic; namespace AibisDream.SaveSystem { /// /// 当前快照 schema 的版本号。结构变更时递增。 /// public static class SaveSnapshotSchema { public const int CurrentVersion = 1; } /// /// 存档快照根对象:描述「进入可存节点那一刻」的完整游戏状态。 /// /// 与槽位/文件路径解耦;序列化后写入 JSON。对应需求§3 四分类: /// anchor(恢复锚点)、sections(宏观 scene/macro + 表现类)、yarnVariables、deepRepair(深度维修,P5)。 /// /// /// 宏观阶段(场景 / 章节 SO / YarnProject)不单独冗余存储,统一以 sections["scene"] / sections["macro"] /// 为唯一来源;槽位 UI 等需要摘要时通过 现算派生,避免重复字段漂移。 /// /// [Serializable] public class SaveSnapshot { /// 快照结构版本,对应 public int schemaVersion = SaveSnapshotSchema.CurrentVersion; /// 保存时的 Application.version public string gameVersion; /// 保存时间(本地),格式 yyyy-MM-dd HH:mm:ss public string savedAt; /// 恢复锚点:读档后从此 Yarn 节点重新进入(所见即所存)。 public AnchorSnapshot anchor = new(); /// 全部 Yarn 运行时变量(来自 )。 public YarnVariablesSnapshot yarnVariables = new(); /// /// 各子系统表现类快照,key 为 中的稳定 id。 /// public Dictionary sections = new(); /// /// 深度维修段。P1 捕获时不写入(null);P5 按模块策略填充。 /// public DeepRepairSnapshot deepRepair; } /// /// 恢复锚点。读档时在场景与状态还原完成后,从 重新 StartDialogue。 /// [Serializable] public class AnchorSnapshot { public string yarnProjectId; public string nodeName; } /// Yarn 变量三分组,与 Yarn Spinner 支持的类型一致。 [Serializable] public class YarnVariablesSnapshot { public Dictionary floats = new(); public Dictionary strings = new(); public Dictionary bools = new(); } #region Provider DTOs /// sections["scene"]:当前加载的场景。 [Serializable] public class SceneSnapshotDto { public string sceneName; } /// sections["macro"]:章节与 Yarn 工程绑定。 [Serializable] public class MacroSnapshotDto { public string sceneSoName; public string yarnProjectId; } /// sections["env"]:环境时间/天气。 [Serializable] public class EnvironmentSnapshotDto { /// 枚举名。 public string curTime; /// 枚举名。 public string curWeather; public bool isInitialized; } /// sections["actor"]:场景中所有角色的逐项状态。 [Serializable] public class ActorSnapshotDto { public List actors = new(); } /// 单个角色的快照条目。 [Serializable] public class ActorEntrySnapshotDto { public string actorName; public string slotName; public string actorType; public string stateName; public float alpha; public float faceParam; } /// sections["audio"]:FMOD 音乐/SFX 终态与 AMB 状态(不记播放进度)。 [Serializable] public class AudioSnapshotDto { /// key → FMOD event path。 public Dictionary musicPaths = new(); public Dictionary sfxPaths = new(); /// 枚举名。 public string ambState; } /// /// Timeline 终/初态标记(决策 D1.1:不按时间轴逐帧还原)。 /// 序列化进 JSON 时使用字符串形式存入 。 /// public enum TimelinePlaybackPhase { AtStart, AtEnd, Stopped } /// sections["timeline"]:各 PlayableDirector 的终/初态。 [Serializable] public class TimelineSnapshotDto { public List entries = new(); } [Serializable] public class TimelineEntrySnapshotDto { public string directorName; public bool isActive; /// 的字符串名。 public string phase; /// 若由 Addressables 加载 Timeline,记录 key;否则为空。 public string loadedAddressableKey; } /// sections["screen"]:屏幕饱和度与演出淡入淡出遮罩。 [Serializable] public class ScreenSnapshotDto { /// Post-process Volume weight(0=正常,1=完全褪色)。 public float saturationWeight; /// /// 演出遮罩终态:true = 黑屏盖住(FadeIn 完成); /// false = 画面可见(FadeOut 完成或遮罩未启用)。不记录转场中间 alpha。 /// public bool isFadeScreenCovered; } #endregion }