43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
using UnityEngine;
|
|
|
|
namespace AibisDream.SaveSystem
|
|
{
|
|
/// <summary>
|
|
/// sections["actor"]:场景中各角色显隐、槽位、动画状态、透明度等(ActorManager)。
|
|
/// RestoreOrder=40,依赖 scene 与 env 已就绪。
|
|
/// </summary>
|
|
public class ActorSnapshotProvider : ISyncSnapshotProvider
|
|
{
|
|
public string SaveId => SnapshotProviderIds.Actor;
|
|
public int RestoreOrder => 40;
|
|
|
|
public object Capture()
|
|
{
|
|
if (ActorManager.Instance == null)
|
|
{
|
|
Debug.LogWarning("[ActorSnapshotProvider] ActorManager 未初始化,跳过捕获。");
|
|
return null;
|
|
}
|
|
|
|
return ActorManager.Instance.CaptureSnapshot();
|
|
}
|
|
|
|
public void Restore(object dto, SnapshotRestoreContext context)
|
|
{
|
|
if (dto is not ActorSnapshotDto actors)
|
|
{
|
|
context.Warn("[ActorSnapshotProvider] DTO 类型不匹配,跳过还原。");
|
|
return;
|
|
}
|
|
|
|
if (ActorManager.Instance == null)
|
|
{
|
|
context.Warn("[ActorSnapshotProvider] ActorManager 未初始化,跳过还原。");
|
|
return;
|
|
}
|
|
|
|
ActorManager.Instance.RestoreSnapshot(actors);
|
|
}
|
|
}
|
|
}
|