Story排版
This commit is contained in:
@@ -24,6 +24,20 @@ namespace Ichni.Story
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写入整型剧情变量、保存到 StorySaveModule,并立即重新推导当前故事树。
|
||||
/// 路线选项可通过本方法写入 Forbidden Condition 所读取的变量,确保玩家确认选择后,
|
||||
/// 同一帧内即可把其它路线的 Block 更新为 Forbidden。
|
||||
/// </summary>
|
||||
public static bool SetIntAndRefresh(string variableName, int value)
|
||||
{
|
||||
if (!TrySetIntAndSave(variableName, value))
|
||||
return false;
|
||||
|
||||
StoryManager.instance?.treeController?.RefreshAllStates();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理一次 TutorialBlock 的选择结果。
|
||||
/// 无论选择“游玩”还是“跳过”,都会将其进度变量设为 true,并将教程节点标记为完成。
|
||||
@@ -112,5 +126,28 @@ namespace Ichni.Story
|
||||
GameSaveManager.instance.StorySaveModule.SaveVariables();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 整型变量的保存实现。Yarn 底层会以 float 字典持久化数字,具体存储细节由
|
||||
/// StoryVariables.SetInt 统一处理,调用方不应直接操作 StorySaveModule.variables。
|
||||
/// </summary>
|
||||
private static bool TrySetIntAndSave(string variableName, int value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(variableName))
|
||||
{
|
||||
Debug.LogWarning("[StoryProgress] 剧情变量名为空,拒绝写入。");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (GameSaveManager.instance == null || GameSaveManager.instance.StorySaveModule == null)
|
||||
{
|
||||
Debug.LogWarning("[StoryProgress] StorySaveModule 未就绪,拒绝写入剧情变量。");
|
||||
return false;
|
||||
}
|
||||
|
||||
StoryVariables.SetInt(variableName, value);
|
||||
GameSaveManager.instance.StorySaveModule.SaveVariables();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user