feat(save): 支持无节点 anchor 恢复与延迟屏幕遮罩应用

This commit is contained in:
2026-06-29 15:59:21 +08:00
parent 08b8f34bde
commit 3775aed368
3 changed files with 41 additions and 7 deletions
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using AibisDream.Framework;
@@ -208,6 +208,7 @@ namespace AibisDream.SaveSystem
yield return null;
FinalizeGameSessionAfterRestore();
yield return FadeOutForRestore();
ScreenSnapshotHelper.ApplyDeferredFadeScreenIfNeeded();
}
finally
{
@@ -247,6 +248,7 @@ namespace AibisDream.SaveSystem
FinalizeGameSessionAfterRestore();
yield return FadeOutForRestore();
ScreenSnapshotHelper.ApplyDeferredFadeScreenIfNeeded();
}
finally
{
@@ -10,6 +10,9 @@ namespace AibisDream.SaveSystem
/// </summary>
public static class ScreenSnapshotHelper
{
private static bool _hasDeferredFadeScreenCovered;
private static bool _deferredFadeScreenCovered;
public static ScreenSnapshotDto Capture()
{
var dto = new ScreenSnapshotDto();
@@ -42,9 +45,29 @@ namespace AibisDream.SaveSystem
if (UIManager.Instance != null)
{
if (SaveRestoreOrchestrator.IsRestoring)
{
_hasDeferredFadeScreenCovered = true;
_deferredFadeScreenCovered = dto.isFadeScreenCovered;
return;
}
var panel = UIManager.Instance.GetPanel<PlayToolPanel>();
panel?.ApplyFadeScreenCovered(dto.isFadeScreenCovered);
}
}
/// <summary>读档 FadeOut 完成后应用延迟的遮罩终态。</summary>
public static void ApplyDeferredFadeScreenIfNeeded()
{
if (!_hasDeferredFadeScreenCovered)
{
return;
}
_hasDeferredFadeScreenCovered = false;
var panel = UIManager.Instance?.GetPanel<PlayToolPanel>();
panel?.ApplyFadeScreenCovered(_deferredFadeScreenCovered);
}
}
}
+15 -6
View File
@@ -39,30 +39,34 @@ namespace AibisDream.SaveSystem
}
/// <summary>
/// Phase 3:按 <see cref="AnchorSnapshot"/> 加载对话工程重新进入 Yarn 节点。
/// Phase 3:按 <see cref="AnchorSnapshot"/> 加载对话工程;若有节点名则重新进入 Yarn 节点。
/// </summary>
public static IEnumerator RestoreAnchor(SaveSnapshot snapshot, SnapshotRestoreContext context = null)
{
if (snapshot?.anchor == null || string.IsNullOrEmpty(snapshot.anchor.nodeName))
if (snapshot?.anchor == null)
{
context?.Log("Phase 3: No anchor node, skip RestoreAnchor");
context?.Log("Phase 3: No anchor, skip RestoreAnchor");
yield break;
}
context ??= new SnapshotRestoreContext(snapshot);
context.Log($"Phase 3: Restore anchor {snapshot.anchor.nodeName}");
var hasNode = !string.IsNullOrEmpty(snapshot.anchor.nodeName);
context.Log(hasNode
? $"Phase 3: Restore anchor {snapshot.anchor.nodeName}"
: "Phase 3: No anchor node, restore YarnProject only");
var dialog = DialogController.Instance;
if (dialog == null)
{
context.Warn("DialogController 未初始化,无法重进 Yarn 节点。");
context.Warn("DialogController 未初始化,无法恢复 Yarn 状态。");
yield break;
}
var runner = dialog.DialogueRunner;
if (runner == null)
{
context.Warn("DialogueRunner 未初始化,无法重进 Yarn 节点。");
context.Warn("DialogueRunner 未初始化,无法恢复 Yarn 状态。");
yield break;
}
@@ -83,6 +87,11 @@ namespace AibisDream.SaveSystem
}
}
if (!hasNode)
{
yield break;
}
if (runner.IsDialogueRunning)
{
yield return runner.Stop();