66 lines
1.6 KiB
C#
66 lines
1.6 KiB
C#
using System;
|
|
using System.Collections;
|
|
using AibisDream.Framework;
|
|
|
|
namespace AibisDream.FixSystem
|
|
{
|
|
public class FixSystemCenter : Kit.Singleton<FixSystemCenter>
|
|
{
|
|
public FixState CurState => StateMachine.CurState;
|
|
|
|
private readonly FixSystemData _data = new();
|
|
|
|
public override void OnSingletonInit()
|
|
{
|
|
SystemDic ??= new IOCContainer();
|
|
|
|
// 初始化状态机
|
|
StateMachine = new FixStateMachine();
|
|
StartCoroutine(StateMachine.SwitchState(FixState.Clinic));
|
|
|
|
// 注册
|
|
StorageSystem.Instance.RegisterData(_data);
|
|
}
|
|
|
|
public override void OnSingletonDestroy()
|
|
{
|
|
CameraKit.Instance.RemoveAllCam();
|
|
GameLoopManager.Instance.StartCoroutine(StateMachine.QuitState());
|
|
SystemDic.Clear();
|
|
|
|
// 注销
|
|
StorageSystem.Instance.UnregisterData<FixSystemData>();
|
|
}
|
|
|
|
#region 系统索引
|
|
|
|
// 容纳System
|
|
public static IOCContainer SystemDic = new();
|
|
|
|
#endregion
|
|
|
|
#region 状态机相关
|
|
|
|
public static FixStateMachine StateMachine;
|
|
|
|
#endregion
|
|
}
|
|
|
|
[Serializable]
|
|
[LoadIndex(1)]
|
|
public class FixSystemData : IData
|
|
{
|
|
private FixState _curState;
|
|
|
|
public FixState CurState
|
|
{
|
|
get => FixSystemCenter.Instance.CurState;
|
|
set => _curState = value;
|
|
}
|
|
|
|
public IEnumerator Load()
|
|
{
|
|
yield return FixSystemCenter.StateMachine.SwitchState(_curState);
|
|
}
|
|
}
|
|
} |