101 lines
3.3 KiB
C#
101 lines
3.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using AibisDream.Framework;
|
|
using AibisDream.Kit;
|
|
using AibisDream.SaveSystem;
|
|
using UnityEngine;
|
|
using UnityEngine.Serialization;
|
|
|
|
namespace AibisDream.FixSystem
|
|
{
|
|
public class FixSystemCenter : Singleton<FixSystemCenter>
|
|
{
|
|
public FixSceneMode CurrentMode => Director.CurrentMode;
|
|
|
|
public FixSceneMode defaultMode = FixSceneMode.Default;
|
|
|
|
private readonly FixSystemData _data = new();
|
|
|
|
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(_data);
|
|
StartCoroutine(Director.Init(defaultMode));
|
|
DeepRepairDataRegistry.RegisterData(_data);
|
|
}
|
|
|
|
public override void OnSingletonDestroy()
|
|
{
|
|
DeepRepairDataRegistry.UnregisterData<FixSystemData>();
|
|
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 snapshot.</summary>
|
|
public FixSnapshotDto CaptureSnapshot()
|
|
{
|
|
var bodyModule = SystemDic.Get<BodyModuleSystem>();
|
|
var eyeSystem = SystemDic.Get<EyeSystem>();
|
|
var repairManager = RepairSystemManager.Instance;
|
|
|
|
return new FixSnapshotDto
|
|
{
|
|
state = Director.CurrentMode.ToString(),
|
|
args = _data.args,
|
|
moduleState = bodyModule?.GetCurrentModuleState().ToString(),
|
|
eyeColorState = eyeSystem?.GetCurrentColorState().ToString(),
|
|
isSystemOn = FixPanelSystem.Instance?.IsSystemOn ?? false,
|
|
currentRepairSystemType = repairManager?.GetCurrentSystemType()?.Name
|
|
};
|
|
}
|
|
|
|
/// <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 ?? "");
|
|
}
|
|
}
|
|
|
|
[Serializable]
|
|
[LoadIndex(2)]
|
|
public class FixSystemData : IData
|
|
{
|
|
[FormerlySerializedAs("curState")]
|
|
public FixSceneMode curMode;
|
|
public string args;
|
|
|
|
public IEnumerator Load()
|
|
{
|
|
yield return FixSystemCenter.Director.TransitionTo(curMode, args);
|
|
}
|
|
}
|
|
}
|