53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
using UnityEngine;
|
||
|
||
namespace AibisDream.SaveSystem
|
||
{
|
||
/// <summary>
|
||
/// sections["fixPanel"]:FixPanel 壳层 + 线缆/插头。RestoreOrder=66,在 fix 之后、bodyModule 之前。
|
||
/// </summary>
|
||
public class FixPanelSnapshotProvider : ISyncSnapshotProvider
|
||
{
|
||
public string SaveId => SnapshotProviderIds.FixPanel;
|
||
public int RestoreOrder => 66;
|
||
|
||
public object Capture()
|
||
{
|
||
if (!FixSceneSnapshotHelper.IsFixSceneActive())
|
||
{
|
||
return null;
|
||
}
|
||
|
||
if (FixSystem.FixPanelSystem.Instance == null)
|
||
{
|
||
Debug.LogWarning("[FixPanelSnapshotProvider] FixPanelSystem 未初始化,跳过捕获。");
|
||
return null;
|
||
}
|
||
|
||
return FixSystem.FixPanelSystem.Instance.CapturePanelSnapshot();
|
||
}
|
||
|
||
public void Restore(object dto, SnapshotRestoreContext context)
|
||
{
|
||
if (dto is not FixPanelSnapshotDto panelDto)
|
||
{
|
||
context.Warn("[FixPanelSnapshotProvider] DTO 类型不匹配,跳过还原。");
|
||
return;
|
||
}
|
||
|
||
if (!FixSceneSnapshotHelper.IsFixSceneActive())
|
||
{
|
||
context.Log("[FixPanelSnapshotProvider] 当前非维修场景,跳过还原。");
|
||
return;
|
||
}
|
||
|
||
if (FixSystem.FixPanelSystem.Instance == null)
|
||
{
|
||
context.Warn("[FixPanelSnapshotProvider] FixPanelSystem 未初始化,跳过还原。");
|
||
return;
|
||
}
|
||
|
||
FixSystem.FixPanelSystem.Instance.ApplyPanelSnapshot(panelDto);
|
||
}
|
||
}
|
||
}
|