37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using System.Collections;
|
|
using AibisDream.UI;
|
|
|
|
namespace AibisDream.SaveSystem
|
|
{
|
|
/// <summary>sections["playTool"]:物品图与全屏图。RestoreOrder=71。</summary>
|
|
public sealed class PlayToolSnapshotProvider : IAsyncSnapshotProvider
|
|
{
|
|
public string SaveId => SnapshotProviderIds.PlayTool;
|
|
public int RestoreOrder => 71;
|
|
|
|
public object Capture()
|
|
{
|
|
var panel = UIManager.Instance?.GetPanel<PlayToolPanel>();
|
|
return panel != null ? panel.CaptureSnapshot() : null;
|
|
}
|
|
|
|
public IEnumerator RestoreAsync(object dto, SnapshotRestoreContext context)
|
|
{
|
|
if (dto is not PlayToolSnapshotDto snapshot)
|
|
{
|
|
context.Warn("[PlayToolSnapshotProvider] DTO 类型不匹配,跳过还原。");
|
|
yield break;
|
|
}
|
|
|
|
var panel = UIManager.Instance?.GetPanel<PlayToolPanel>();
|
|
if (panel == null)
|
|
{
|
|
context.Warn("[PlayToolSnapshotProvider] PlayToolPanel 未初始化,跳过还原。");
|
|
yield break;
|
|
}
|
|
|
|
yield return panel.RestoreSnapshotAsync(snapshot, context.Warn);
|
|
}
|
|
}
|
|
}
|