Files
aibis-dream/Assets/Scripts/SaveSystem/Providers/EyeSnapshotProvider.cs
T

56 lines
1.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using AibisDream;
using UnityEngine;
namespace AibisDream.SaveSystem
{
/// <summary>
/// sections["eye"]Eye 维修叙事阶段。RestoreOrder=67,在 bodyModule 之后。
/// </summary>
public class EyeSnapshotProvider : ISyncSnapshotProvider
{
public string SaveId => SnapshotProviderIds.Eye;
public int RestoreOrder => 68;
public object Capture()
{
if (!FixSceneSnapshotHelper.IsFixSceneActive())
{
return null;
}
var eyeSystem = FixSystem.FixSystemCenter.SystemDic.Get<EyeSystem>();
if (eyeSystem == null)
{
Debug.LogWarning("[EyeSnapshotProvider] EyeSystem 未初始化,跳过捕获。");
return null;
}
return eyeSystem.CaptureEyeSnapshot();
}
public void Restore(object dto, SnapshotRestoreContext context)
{
if (dto is not EyeSnapshotDto eyeDto)
{
context.Warn("[EyeSnapshotProvider] DTO 类型不匹配,跳过还原。");
return;
}
if (!FixSceneSnapshotHelper.IsFixSceneActive())
{
context.Log("[EyeSnapshotProvider] 当前非维修场景,跳过还原。");
return;
}
var eyeSystem = FixSystem.FixSystemCenter.SystemDic.Get<EyeSystem>();
if (eyeSystem == null)
{
context.Warn("[EyeSnapshotProvider] EyeSystem 未初始化,跳过还原。");
return;
}
eyeSystem.ApplyEyeSnapshot(eyeDto);
}
}
}