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

44 lines
1.3 KiB
C#

using System.Collections;
using UnityEngine;
namespace AibisDream.SaveSystem
{
/// <summary>
/// sections["subway"]:地铁场景宏观状态(SubwayCenter)。
/// RestoreOrder=64,在 timeline(60) 之后、fix(65) 之前。
/// </summary>
public class SubwaySnapshotProvider : IAsyncSnapshotProvider
{
public string SaveId => SnapshotProviderIds.Subway;
public int RestoreOrder => 64;
public object Capture()
{
if (SubwayCenter.Instance == null)
{
Debug.LogWarning("[SubwaySnapshotProvider] SubwayCenter 未初始化,跳过捕获。");
return null;
}
return SubwayCenter.Instance.CaptureSnapshot();
}
public IEnumerator RestoreAsync(object dto, SnapshotRestoreContext context)
{
if (dto is not SubwaySnapshotDto subway)
{
context.Warn("[SubwaySnapshotProvider] DTO 类型不匹配,跳过还原。");
yield break;
}
if (SubwayCenter.Instance == null)
{
context.Warn("[SubwaySnapshotProvider] SubwayCenter 未初始化,跳过还原。");
yield break;
}
yield return SubwayCenter.Instance.RestoreSnapshot(subway);
}
}
}