diff --git a/Assets/Scripts/SceneManagement/SceneCenter/SubwayCenter.cs b/Assets/Scripts/SceneManagement/SceneCenter/SubwayCenter.cs index ba84e7424..fcaa4c76c 100644 --- a/Assets/Scripts/SceneManagement/SceneCenter/SubwayCenter.cs +++ b/Assets/Scripts/SceneManagement/SceneCenter/SubwayCenter.cs @@ -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 StateMachine { get; private set; } + private string _currentNewsSpriteId; + #endregion public override void OnSingletonInit() @@ -71,6 +74,45 @@ namespace AibisDream } newsSpriteRenderer.sprite = handle.Result; + _currentNewsSpriteId = spriteId; + } + + /// Captures the macro subway scene snapshot. + public SubwaySnapshotDto CaptureSnapshot() + { + if (StateMachine == null || !StateMachine.HasState) + { + return null; + } + + return new SubwaySnapshotDto + { + state = StateMachine.CurState.ToString(), + args = "", + newsSpriteId = _currentNewsSpriteId + }; + } + + /// Restores the macro subway scene snapshot by jumping directly to the target state. + public IEnumerator RestoreSnapshot(SubwaySnapshotDto dto) + { + if (dto == null || string.IsNullOrEmpty(dto.state)) + { + yield break; + } + + if (!Enum.TryParse(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 @@ -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