37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
using System.Collections;
|
|
using UnityEngine;
|
|
|
|
namespace AibisDream.SaveSystem
|
|
{
|
|
/// <summary>
|
|
/// sections["env"]:场景内时间/天气(EnvironmentManager)。
|
|
/// RestoreOrder=20,在 scene 加载完成后、macro 之前还原环境。
|
|
/// </summary>
|
|
public class EnvironmentSnapshotProvider : ISnapshotProvider
|
|
{
|
|
public string SaveId => SnapshotProviderIds.Environment;
|
|
public int RestoreOrder => 20;
|
|
|
|
public object Capture()
|
|
{
|
|
if (EnvironmentManager.Instance == null)
|
|
{
|
|
Debug.LogWarning("[EnvironmentSnapshotProvider] EnvironmentManager 未初始化,跳过捕获。");
|
|
return null;
|
|
}
|
|
|
|
return EnvironmentManager.Instance.CaptureSnapshot();
|
|
}
|
|
|
|
public IEnumerator Restore(object dto)
|
|
{
|
|
if (dto is not EnvironmentSnapshotDto env)
|
|
{
|
|
yield break;
|
|
}
|
|
|
|
yield return EnvironmentManager.Instance.RestoreSnapshot(env);
|
|
}
|
|
}
|
|
}
|