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

44 lines
1.4 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 System.Collections;
using UnityEngine;
namespace AibisDream.SaveSystem
{
/// <summary>
/// sections["fix"]Fix 场景宏观状态(FixStateMachine)。
/// RestoreOrder=65,在 timeline(60) 之后、screen(70) 之前。
/// </summary>
public class FixSnapshotProvider : IAsyncSnapshotProvider
{
public string SaveId => SnapshotProviderIds.Fix;
public int RestoreOrder => 65;
public object Capture()
{
if (FixSystem.FixSystemCenter.Instance == null)
{
Debug.LogWarning("[FixSnapshotProvider] FixSystemCenter 未初始化,跳过捕获。");
return null;
}
return FixSystem.FixSystemCenter.Instance.CaptureSnapshot();
}
public IEnumerator RestoreAsync(object dto, SnapshotRestoreContext context)
{
if (dto is not FixSnapshotDto fix)
{
context.Warn("[FixSnapshotProvider] DTO 类型不匹配,跳过还原。");
yield break;
}
if (FixSystem.FixSystemCenter.Instance == null)
{
context.Warn("[FixSnapshotProvider] FixSystemCenter 未初始化,跳过还原。");
yield break;
}
yield return FixSystem.FixSystemCenter.Instance.RestoreSnapshot(fix);
}
}
}