feat(SaveSystem): 读档编排 Phase+Barrier 与自动存档抑制
This commit is contained in:
@@ -28,6 +28,7 @@ namespace AibisDream.SaveSystem.Editor
|
||||
private int _deleteSlotIndex = 1;
|
||||
private string _testNodeName = "SomeNode";
|
||||
private string _testTags = "";
|
||||
private int _restoreSlotIndex;
|
||||
|
||||
private readonly List<SaveHistoryEntry> _saveHistory = new();
|
||||
private string _lastObservedSavedAt;
|
||||
@@ -149,6 +150,8 @@ namespace AibisDream.SaveSystem.Editor
|
||||
GUILayout.Space(12);
|
||||
DrawManualSlotSection();
|
||||
GUILayout.Space(12);
|
||||
DrawRestoreSection();
|
||||
GUILayout.Space(12);
|
||||
DrawSavePointEvaluationSection();
|
||||
GUILayout.Space(12);
|
||||
DrawUtilitySection();
|
||||
@@ -182,6 +185,9 @@ namespace AibisDream.SaveSystem.Editor
|
||||
var latest = SlotManager.GetLatestSlotIndex();
|
||||
EditorGUILayout.LabelField($"最近槽位: {(latest.HasValue ? latest.Value.ToString() : "无")}");
|
||||
EditorGUILayout.LabelField($"存档根目录: {ConstRef.SaveFilePath}");
|
||||
EditorGUILayout.LabelField(
|
||||
$"读档状态: IsRestoring={SaveRestoreOrchestrator.IsRestoring}, " +
|
||||
$"SuppressAutoSave={SaveRestoreOrchestrator.IsAutoSaveSuppressed}");
|
||||
|
||||
var viewModels = SlotManager.GetSlotViewModels();
|
||||
foreach (var vm in viewModels)
|
||||
@@ -322,6 +328,44 @@ namespace AibisDream.SaveSystem.Editor
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawRestoreSection()
|
||||
{
|
||||
EditorGUILayout.LabelField("读档验证 (P4)", EditorStyles.boldLabel);
|
||||
EditorGUILayout.HelpBox(
|
||||
"触发 SaveRestoreOrchestrator.RestoreFromSlot,验证 Phase + Barrier 编排、自动存档抑制与 Provider 还原日志。\n" +
|
||||
"需要在 Play Mode 下执行;不代表正式玩家 UI。",
|
||||
MessageType.None);
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
if (GUILayout.Button("Restore Latest"))
|
||||
{
|
||||
RestoreLatestSlot();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Restore slot_0"))
|
||||
{
|
||||
RestoreSlot(SlotIndex.Auto);
|
||||
}
|
||||
}
|
||||
|
||||
_restoreSlotIndex = EditorGUILayout.IntSlider("Restore 槽位", _restoreSlotIndex, 0, SlotIndex.ManualEnd);
|
||||
if (GUILayout.Button($"Restore slot_{_restoreSlotIndex}"))
|
||||
{
|
||||
RestoreSlot(_restoreSlotIndex);
|
||||
}
|
||||
|
||||
var restoreLog = SaveRestoreOrchestrator.LastRestoreLog;
|
||||
if (restoreLog.Count > 0)
|
||||
{
|
||||
EditorGUILayout.LabelField("Restore Pipeline Log", EditorStyles.boldLabel);
|
||||
foreach (var line in restoreLog)
|
||||
{
|
||||
EditorGUILayout.LabelField(line, EditorStyles.wordWrappedMiniLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawUtilitySection()
|
||||
{
|
||||
EditorGUILayout.LabelField("工具", EditorStyles.boldLabel);
|
||||
@@ -510,6 +554,42 @@ namespace AibisDream.SaveSystem.Editor
|
||||
}
|
||||
}
|
||||
|
||||
private void RestoreLatestSlot()
|
||||
{
|
||||
var latest = SlotManager.GetLatestSlotIndex();
|
||||
if (!latest.HasValue)
|
||||
{
|
||||
Log("没有 latest_slot,无法读档。");
|
||||
return;
|
||||
}
|
||||
|
||||
RestoreSlot(latest.Value);
|
||||
}
|
||||
|
||||
private void RestoreSlot(int slotIndex)
|
||||
{
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
Log("Restore 需要在 Play Mode 下执行。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (GameManager.Instance == null)
|
||||
{
|
||||
Log("GameManager 未初始化,无法启动读档协程。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SlotDirectory.Exists(slotIndex))
|
||||
{
|
||||
Log($"slot_{slotIndex} 不存在,无法读档。");
|
||||
return;
|
||||
}
|
||||
|
||||
GameManager.Instance.StartCoroutine(SaveRestoreOrchestrator.RestoreFromSlot(slotIndex));
|
||||
Log($"已启动 Restore slot_{slotIndex}。请观察 Restore Pipeline Log 与场景状态。");
|
||||
}
|
||||
|
||||
private void OpenSaveDirectory()
|
||||
{
|
||||
var path = ConstRef.SaveFilePath;
|
||||
|
||||
Reference in New Issue
Block a user