36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
using System.Collections;
|
||
|
||
namespace AibisDream.SaveSystem
|
||
{
|
||
/// <summary>sections["day2SleepPresentation"]:D2 Sleep 动态表现语义终态。</summary>
|
||
public sealed class Day2SleepPresentationSnapshotProvider : IAsyncSnapshotProvider
|
||
{
|
||
public string SaveId => SnapshotProviderIds.Day2SleepPresentation;
|
||
public int RestoreOrder => 70;
|
||
|
||
public object Capture()
|
||
{
|
||
var controller = Day2SleepPresentationController.Instance;
|
||
return controller != null && controller.HasPersistableState
|
||
? controller.CaptureSnapshot()
|
||
: null;
|
||
}
|
||
|
||
public IEnumerator RestoreAsync(object dto, SnapshotRestoreContext context)
|
||
{
|
||
if (dto is not Day2SleepPresentationSnapshotDto snapshot)
|
||
{
|
||
context.Warn("[Day2SleepPresentationSnapshotProvider] DTO 类型不匹配,跳过还原。");
|
||
yield break;
|
||
}
|
||
var controller = Day2SleepPresentationController.Instance;
|
||
if (controller == null)
|
||
{
|
||
context.Warn("[Day2SleepPresentationSnapshotProvider] 控制器未初始化,跳过还原。");
|
||
yield break;
|
||
}
|
||
yield return controller.RestoreSnapshotAsync(snapshot, context.Warn);
|
||
}
|
||
}
|
||
}
|