refactor: 拆分D2 Sleep表现并接入快照

This commit is contained in:
2026-07-22 00:50:16 +08:00
parent 6dc0983961
commit aed9998d1a
32 changed files with 1977 additions and 1404 deletions
@@ -0,0 +1,35 @@
using System.Collections;
namespace AibisDream.SaveSystem
{
/// <summary>sections["day2SleepPresentation"]D2 Sleep 动态表现语义终态。</summary>
public sealed class Day2SleepPresentationSnapshotProvider : IAsyncSnapshotProvider
{
public string SaveId => SnapshotProviderIds.Day2SleepPresentation;
public int RestoreOrder => 70;
public object Capture()
{
var controller = Day2SleepPresentationController.Instance;
return controller != null && controller.HasPersistableState
? controller.CaptureSnapshot()
: null;
}
public IEnumerator RestoreAsync(object dto, SnapshotRestoreContext context)
{
if (dto is not Day2SleepPresentationSnapshotDto snapshot)
{
context.Warn("[Day2SleepPresentationSnapshotProvider] DTO 类型不匹配,跳过还原。");
yield break;
}
var controller = Day2SleepPresentationController.Instance;
if (controller == null)
{
context.Warn("[Day2SleepPresentationSnapshotProvider] 控制器未初始化,跳过还原。");
yield break;
}
yield return controller.RestoreSnapshotAsync(snapshot, context.Warn);
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8f80937eaaba42da9baa4a2d8e73ff57
@@ -3,11 +3,11 @@ using AibisDream.UI;
namespace AibisDream.SaveSystem
{
/// <summary>sections["playTool"]:物品图与全屏图。RestoreOrder=70。</summary>
/// <summary>sections["playTool"]:物品图与全屏图。RestoreOrder=71。</summary>
public sealed class PlayToolSnapshotProvider : IAsyncSnapshotProvider
{
public string SaveId => SnapshotProviderIds.PlayTool;
public int RestoreOrder => 70;
public int RestoreOrder => 71;
public object Capture()
{
@@ -0,0 +1,34 @@
using System.Collections;
namespace AibisDream.SaveSystem
{
/// <summary>sections["showcase"]:梦境通用静态图片;先于场景专属表现恢复。</summary>
public sealed class ShowcaseSnapshotProvider : IAsyncSnapshotProvider
{
public string SaveId => SnapshotProviderIds.Showcase;
public int RestoreOrder => 69;
public object Capture()
{
return SpriteShowcase.Instance != null
? SpriteShowcase.Instance.CaptureSnapshot()
: null;
}
public IEnumerator RestoreAsync(object dto, SnapshotRestoreContext context)
{
if (dto is not ShowcaseSnapshotDto snapshot)
{
context.Warn("[ShowcaseSnapshotProvider] DTO 类型不匹配,跳过还原。");
yield break;
}
var showcase = SpriteShowcase.Instance;
if (showcase == null)
{
context.Warn("[ShowcaseSnapshotProvider] SpriteShowcase 未初始化,跳过还原。");
yield break;
}
yield return showcase.RestoreSnapshotAsync(snapshot, context.Warn);
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 83cccdfaca2a42a89ed515c16c6adfad
+5 -4
View File
@@ -1,4 +1,4 @@
# SaveSystem 存档快照层
# SaveSystem 存档快照层
> 当前代码包含 P1 快照层、P2 槽位/落盘基础版、P3 可存点判定基础版、P4 读档编排基础版。设计文档见 [`Docs/存档系统设计方案.md`](../../../Docs/存档系统设计方案.md)**§4.1 / D6** 描述读档编排模型)。
@@ -101,7 +101,8 @@ SaveSystem/
├── FixSnapshotProvider.cs order 65
├── FixPanelSnapshotProvider.cs order 66
├── ShowcaseSnapshotProvider.cs order 69
├── PlayToolSnapshotProvider.cs order 70
├── Day2SleepPresentationSnapshotProvider.cs order 70
├── PlayToolSnapshotProvider.cs order 71
└── ScreenSnapshotProvider.cs order 80
```
@@ -135,7 +136,7 @@ Phase 0 Yarn 变量(sync
Phase 1 场景加载(BarrierLoadSceneAsync)← 框架直管,不走 Provider
Phase 2 env / actor / audio / timeline / fix / showcase / playTool / screenProvider 按 RestoreOrder
Phase 2 env / actor / audio / timeline / fix / showcase / day2SleepPresentation / playTool / screenProvider 按 RestoreOrder
└─ timeline`Stopped` = untouched(从未 Evaluate),读档仅还原 `isActive`,不 Reset/Evaluate
Phase 2 可选 Barrier(如 Timeline Addressable 须显式等待)
@@ -202,7 +203,7 @@ Fix 场景各 State 的 `Enter()` 通常包含相机过渡、Timeline 播放、F
| `bodyModule` | `BodyModuleSnapshotDto` | 67 | 插线模块物理态 |
| `eye` | `EyeSnapshotDto` | 68 | Eye 叙事阶段 |
**还原顺序**punchTape → fixcue)→ fixPanel → bodyModule → eye → showcase → playTool → screen。`fixPanel` 须在 `fix` 之后,以覆盖 Cue `EnterImmediate` 中的 `ResetPlug`
**还原顺序**punchTape → fixcue)→ fixPanel → bodyModule → eye → showcase → day2SleepPresentation → playTool → screen。`fixPanel` 须在 `fix` 之后,以覆盖 Cue `EnterImmediate` 中的 `ResetPlug`;D2 动态表现须在通用 Showcase 图片之后恢复,才能叠加虚焦、缩放或场景专属动画
**维修场景门控**`FixSceneSnapshotHelper`):上述 section 仅在 `FixSystemCenter.Instance != null` 时 Capture/Restore。
+47
View File
@@ -190,6 +190,53 @@ namespace AibisDream.SaveSystem
public string fullScreenPicName;
}
public enum ShowcaseDisplayMode
{
None,
Small,
Large
}
/// <summary>sections["showcase"]:梦境通用静态图片与背景终态。</summary>
[Serializable]
public class ShowcaseSnapshotDto
{
public string displayMode;
public string picName;
public bool isBackgroundVisible;
}
public enum Day2SleepPresentationMode
{
None,
SmallMotion,
Kite,
LargeEffects
}
/// <summary>sections["day2SleepPresentation"]D2 Sleep 动态表现语义终态。</summary>
[Serializable]
public class Day2SleepPresentationSnapshotDto
{
public string mode;
public string picName;
public string motionProfile;
public float kiteHeight;
public int kiteWind;
public float kiteTurbulence;
public bool largeAnimationActive;
public string largeAnimationPrefix;
public int largeAnimationFrameCount;
public float largeAnimationSecondsPerFrame;
public float largeBlurAmount;
public float largeBlurSize;
public float largeScaleMultiplier = 1f;
public float largeAlpha = 1f;
}
/// <summary>sections["subway"]:地铁场景宏观状态(SubwayCenter / OutSideState)。</summary>
[Serializable]
public class SubwaySnapshotDto
@@ -16,6 +16,8 @@ namespace AibisDream.SaveSystem
public const string Timeline = "timeline";
public const string Screen = "screen";
public const string PlayTool = "playTool";
public const string Showcase = "showcase";
public const string Day2SleepPresentation = "day2SleepPresentation";
public const string Subway = "subway";
public const string PunchTape = "punchTape";
public const string Fix = "fix";
@@ -30,7 +32,7 @@ namespace AibisDream.SaveSystem
/// </summary>
public static readonly string[] RequiredForCapture =
{
Environment, Actor, Audio, Timeline, Subway, Fix, PlayTool, Screen
Environment, Actor, Audio, Timeline, Subway, Fix, Showcase, PlayTool, Screen
};
}
@@ -60,6 +62,8 @@ namespace AibisDream.SaveSystem
Register(new FixPanelSnapshotProvider());
Register(new BodyModuleSnapshotProvider());
Register(new EyeSnapshotProvider());
Register(new ShowcaseSnapshotProvider());
Register(new Day2SleepPresentationSnapshotProvider());
Register(new PlayToolSnapshotProvider());
Register(new ScreenSnapshotProvider());
}
@@ -257,6 +257,8 @@ namespace AibisDream.SaveSystem
SnapshotProviderIds.FixPanel => jobj.ToObject<FixPanelSnapshotDto>(),
SnapshotProviderIds.BodyModule => jobj.ToObject<BodyModuleSnapshotDto>(),
SnapshotProviderIds.Eye => jobj.ToObject<EyeSnapshotDto>(),
SnapshotProviderIds.Showcase => jobj.ToObject<ShowcaseSnapshotDto>(),
SnapshotProviderIds.Day2SleepPresentation => jobj.ToObject<Day2SleepPresentationSnapshotDto>(),
SnapshotProviderIds.PlayTool => jobj.ToObject<PlayToolSnapshotDto>(),
SnapshotProviderIds.Screen => jobj.ToObject<ScreenSnapshotDto>(),
_ => jobj