using AibisDream.Framework; using AibisDream.Kit; using UnityEngine; namespace AibisDream.FixSystem { public class FixSystemCenter : Singleton { public FixState curState; public override void OnSingletonInit() { SystemDic ??= new IOCContainer(); InitTransitionDic(); // TODO 这个回头要改 curState = FixState.Clinic; } #region 系统索引 // 容纳System public static IOCContainer SystemDic = new(); #endregion #region 转场管理 private static readonly StateDictionary TransitionDic = new(); private void InitTransitionDic() { TransitionDic.Add(FixState.Clinic, FixState.BodyModule, new ClinicToBodyModuleCommand()); TransitionDic.Add(FixState.BodyModule, FixState.Clinic, new BodyModuleToClinicCommand()); TransitionDic.Add(FixState.BodyModule, FixState.Engine, new BodyModuleToEngineCommand()); TransitionDic.Add(FixState.Engine, FixState.BodyModule, new EngineToBodyModuleCommand()); TransitionDic.Add(FixState.Clinic, FixState.Engine, new ClinicToEngineCommand()); TransitionDic.Add(FixState.Engine, FixState.Clinic, new EngineToClinicCommand()); TransitionDic.Add(FixState.BodyModule, FixState.Eye, new BodyModuleToEyeCommand()); TransitionDic.Add(FixState.Eye, FixState.BodyModule, new EyeToBodyModuleCommand()); TransitionDic.Add(FixState.BodyModule, FixState.Memory, new BodyModuleToMemoryCommand()); TransitionDic.Add(FixState.Memory, FixState.BodyModule, new MemoryToBodyModuleCommand()); TransitionDic.Add(FixState.BodyModule, FixState.UF, new BodyModuleToUFCommand()); TransitionDic.Add(FixState.UF, FixState.BodyModule, new UFToBodyModuleCommand()); } /// /// 执行转场 /// /// 需要转换的状态 public ITransitionCommand TransToNextState(FixState nextState) { // 没存过的先打个日志报错 if (!TransitionDic.TryGetValue(curState, nextState, out var command)) { Debug.Log($"源为{curState.ToString()}, 目标为{nextState.ToString()}, 转场命令不存在"); return null; } curState = nextState; return command; } #endregion } }