refactor(actor-kit): SubwayCenter 迁移为显式快照
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Collections;
|
||||
using AibisDream.Framework;
|
||||
using AibisDream.Kit;
|
||||
using AibisDream.SaveSystem;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
@@ -19,6 +20,8 @@ namespace AibisDream
|
||||
|
||||
public static StateMachine<OutSideState> StateMachine { get; private set; }
|
||||
|
||||
private string _currentNewsSpriteId;
|
||||
|
||||
#endregion
|
||||
|
||||
public override void OnSingletonInit()
|
||||
@@ -71,6 +74,45 @@ namespace AibisDream
|
||||
}
|
||||
|
||||
newsSpriteRenderer.sprite = handle.Result;
|
||||
_currentNewsSpriteId = spriteId;
|
||||
}
|
||||
|
||||
/// <summary>Captures the macro subway scene snapshot.</summary>
|
||||
public SubwaySnapshotDto CaptureSnapshot()
|
||||
{
|
||||
if (StateMachine == null || !StateMachine.HasState)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new SubwaySnapshotDto
|
||||
{
|
||||
state = StateMachine.CurState.ToString(),
|
||||
args = "",
|
||||
newsSpriteId = _currentNewsSpriteId
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Restores the macro subway scene snapshot by jumping directly to the target state.</summary>
|
||||
public IEnumerator RestoreSnapshot(SubwaySnapshotDto dto)
|
||||
{
|
||||
if (dto == null || string.IsNullOrEmpty(dto.state))
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (!Enum.TryParse<OutSideState>(dto.state, out var state))
|
||||
{
|
||||
Debug.LogWarning($"[SubwayCenter] Could not parse OutSideState: {dto.state}");
|
||||
yield break;
|
||||
}
|
||||
|
||||
yield return StateMachine.SwitchStateImmediate(state, dto.args ?? "");
|
||||
|
||||
if (!string.IsNullOrEmpty(dto.newsSpriteId))
|
||||
{
|
||||
yield return SwitchNews(dto.newsSpriteId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +125,12 @@ namespace AibisDream
|
||||
yield return CameraKit.Instance.SwitchCamera(CameraEnum.Subway);
|
||||
DialogUIManager.Instance.LoadBubbles(BubbleSlotKit.Instance.CollectData(BubbleSlotEnum.Subway));
|
||||
}
|
||||
|
||||
public IEnumerator EnterImmediate()
|
||||
{
|
||||
yield return CameraKit.Instance.SwitchCamera(CameraEnum.Subway, true);
|
||||
DialogUIManager.Instance.LoadBubbles(BubbleSlotKit.Instance.CollectData(BubbleSlotEnum.Subway));
|
||||
}
|
||||
}
|
||||
|
||||
public struct SubwayTVState : IState<OutSideState>
|
||||
@@ -95,6 +143,12 @@ namespace AibisDream
|
||||
// 要加载气泡吗?
|
||||
DialogUIManager.Instance.LoadBubbles(BubbleSlotKit.Instance.CollectData(BubbleSlotEnum.SubwayTV));
|
||||
}
|
||||
|
||||
public IEnumerator EnterImmediate()
|
||||
{
|
||||
yield return CameraKit.Instance.SwitchCamera(CameraEnum.SubwayTV, true);
|
||||
DialogUIManager.Instance.LoadBubbles(BubbleSlotKit.Instance.CollectData(BubbleSlotEnum.SubwayTV));
|
||||
}
|
||||
}
|
||||
|
||||
public enum OutSideState
|
||||
|
||||
Reference in New Issue
Block a user