74 lines
2.3 KiB
C#
74 lines
2.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using AibisDream.Framework;
|
|
using AibisDream.Kit;
|
|
using AibisDream.SaveSystem;
|
|
using UnityEngine;
|
|
|
|
namespace AibisDream.FixSystem
|
|
{
|
|
public class FixSystemCenter : Singleton<FixSystemCenter>
|
|
{
|
|
public FixSceneMode CurrentMode => Director.CurrentMode;
|
|
|
|
public FixSceneMode defaultMode = FixSceneMode.Default;
|
|
|
|
public static IOCContainer SystemDic = new();
|
|
public static FixSceneContext Context;
|
|
public static FixSceneDirector Director;
|
|
|
|
public override void OnSingletonInit()
|
|
{
|
|
SystemDic ??= new IOCContainer();
|
|
Context = new FixSceneContext(SystemDic);
|
|
Director = new FixSceneDirector();
|
|
StartCoroutine(Director.Init(defaultMode));
|
|
}
|
|
|
|
public override void OnSingletonDestroy()
|
|
{
|
|
CameraKit.Instance.RemoveAllCam();
|
|
BubbleSlotKit.Instance.RemoveAll();
|
|
GameManager.Instance.StartCoroutine(Director.QuitCurrentMode());
|
|
Context?.Clear();
|
|
}
|
|
|
|
public IEnumerator TransitionTo(FixSceneMode nextMode, string args = "")
|
|
{
|
|
yield return Director.TransitionTo(nextMode, args);
|
|
}
|
|
|
|
public IEnumerator TransitionToImmediate(FixSceneMode nextMode, string args = "")
|
|
{
|
|
yield return Director.TransitionToImmediate(nextMode, args);
|
|
}
|
|
|
|
/// <summary>Captures the macro Fix scene cue snapshot.</summary>
|
|
public FixSnapshotDto CaptureSnapshot()
|
|
{
|
|
return new FixSnapshotDto
|
|
{
|
|
state = Director.CurrentMode.ToString(),
|
|
args = Director.CurrentArgs
|
|
};
|
|
}
|
|
|
|
/// <summary>Restores the macro Fix scene snapshot by jumping directly to the target cue endpoint.</summary>
|
|
public IEnumerator RestoreSnapshot(FixSnapshotDto dto)
|
|
{
|
|
if (dto == null || string.IsNullOrEmpty(dto.state))
|
|
{
|
|
yield break;
|
|
}
|
|
|
|
if (!Enum.TryParse<FixSceneMode>(dto.state, out var mode))
|
|
{
|
|
Debug.LogWarning($"[FixSystemCenter] Could not parse FixSceneMode: {dto.state}");
|
|
yield break;
|
|
}
|
|
|
|
yield return Director.TransitionToImmediate(mode, dto.args ?? "");
|
|
}
|
|
}
|
|
}
|