fix(save): 修复跨章节存档恢复校验

This commit is contained in:
2026-07-15 19:27:18 +08:00
parent ddb3aba4e5
commit c38c2f75be
3 changed files with 44 additions and 12 deletions
+25 -9
View File
@@ -73,17 +73,22 @@ namespace AibisDream.SaveSystem
if (!string.IsNullOrEmpty(snapshot.anchor.yarnProjectId))
{
var sceneSo = GameManager.Instance?.GetCurrentTalkSceneSo();
if (sceneSo?.yarnProject != null && sceneSo.yarnProject.name == snapshot.anchor.yarnProjectId)
if (sceneSo?.yarnProject == null)
{
if (runner.YarnProject == null || runner.YarnProject.name != snapshot.anchor.yarnProjectId)
{
dialog.LoadDialog(sceneSo.yarnProject);
}
context.Error($"章节 {snapshot.anchor.sceneSoName} 没有可用的 YarnProject。");
yield break;
}
else if (runner.YarnProject != null && runner.YarnProject.name != snapshot.anchor.yarnProjectId)
if (sceneSo.yarnProject.name != snapshot.anchor.yarnProjectId)
{
context.Warn(
$"YarnProject 不匹配:当前 {runner.YarnProject.name},存档 {snapshot.anchor.yarnProjectId}");
context.Error(
$"章节 YarnProject 不匹配:章节 {sceneSo.yarnProject.name},存档 {snapshot.anchor.yarnProjectId}");
yield break;
}
if (runner.YarnProject == null || runner.YarnProject.name != snapshot.anchor.yarnProjectId)
{
dialog.LoadDialog(sceneSo.yarnProject);
}
}
@@ -97,6 +102,14 @@ namespace AibisDream.SaveSystem
yield return runner.Stop();
}
if (runner.YarnProject == null
|| !System.Array.Exists(runner.YarnProject.NodeNames, node => node == snapshot.anchor.nodeName))
{
context.Error(
$"YarnProject {runner.YarnProject?.name ?? "none"} 不包含节点 {snapshot.anchor.nodeName}。");
yield break;
}
yield return runner.StartDialogue(snapshot.anchor.nodeName);
}
@@ -144,7 +157,10 @@ namespace AibisDream.SaveSystem
return;
}
gameManager.SetSceneSoByName(snapshot.anchor.sceneSoName);
if (!gameManager.SetSceneSoByName(snapshot.anchor.sceneSoName))
{
context.Error($"找不到章节 SO{snapshot.anchor.sceneSoName},无法恢复 YarnProject。");
}
}
/// <summary>