diff --git a/Assets/Scripts/FixSystemNew/BodyModule/BodyModuleSystem.cs b/Assets/Scripts/FixSystemNew/BodyModule/BodyModuleSystem.cs index d1fa1a00c..8e752b7a9 100644 --- a/Assets/Scripts/FixSystemNew/BodyModule/BodyModuleSystem.cs +++ b/Assets/Scripts/FixSystemNew/BodyModule/BodyModuleSystem.cs @@ -30,6 +30,9 @@ namespace AibisDream.FixSystem public bool inHotErr; private int _heatValue; + /// 获取当前 BodyModule 分组(Body/Head)。 + public ModuleState GetCurrentModuleState() => _data.moduleState; + private int HeatValue { get => _heatValue; diff --git a/Assets/Scripts/FixSystemNew/FixStateMachine.cs b/Assets/Scripts/FixSystemNew/FixStateMachine.cs index 5b7d5357c..2f9ada0c5 100644 --- a/Assets/Scripts/FixSystemNew/FixStateMachine.cs +++ b/Assets/Scripts/FixSystemNew/FixStateMachine.cs @@ -10,12 +10,10 @@ namespace AibisDream.FixSystem { public class FixStateMachine { - public FixState CurState => _curState.GetState; - - private IState _curState; + public FixState CurState => _stateMachine.CurState; private StateMachine _stateMachine; - + private FixSystemData _data; public FixStateMachine(FixSystemData data) @@ -39,6 +37,24 @@ namespace AibisDream.FixSystem yield return _stateMachine.SwitchState(nextState, args); } + /// + /// 读档专用:跳过动画直接切换状态。不触发 Exit/Enter 动画,只执行 EnterImmediate。 + /// 通过 同步 _stateMachine 内部状态,避免与正常 SwitchState 分叉。 + /// + public IEnumerator SwitchStateImmediate(FixState nextState, string args = "") + { + if (_stateMachine.HasState && CurState.Equals(nextState)) yield break; + + _stateMachine.SetStateImmediate(nextState, args); + _data.curState = nextState; + _data.args = args; + + if (_stateMachine.CurrentStateObj is IFixState fixState) + yield return fixState.EnterImmediate(); + else + yield return _stateMachine.CurrentStateObj.Enter(); + } + public IEnumerator QuitState() { _data.curState = FixState.Default; @@ -93,7 +109,7 @@ namespace AibisDream.FixSystem BlockPuzzle = 17 } - public struct DefaultState : IState + public struct DefaultState : IFixState { public FixState GetState => FixState.Default; @@ -112,7 +128,7 @@ namespace AibisDream.FixSystem } } - public struct ClinicState : IState + public struct ClinicState : IFixState { public FixState GetState => FixState.Clinic; @@ -138,7 +154,7 @@ namespace AibisDream.FixSystem } } - public struct BodyModuleState : IState + public struct BodyModuleState : IFixState { private string _args; @@ -195,7 +211,7 @@ namespace AibisDream.FixSystem } } - public struct UfState : IState + public struct UfState : IFixState { public FixState GetState => FixState.UF; @@ -239,7 +255,7 @@ namespace AibisDream.FixSystem } } - public struct EyeState : IState + public struct EyeState : IFixState { public FixState GetState => FixState.Eye; @@ -292,7 +308,7 @@ namespace AibisDream.FixSystem } } - public struct MemoryState : IState + public struct MemoryState : IFixState { public FixState GetState => FixState.Memory; @@ -336,7 +352,7 @@ namespace AibisDream.FixSystem } } - public struct ExpressionState : IState + public struct ExpressionState : IFixState { public FixState GetState => FixState.Expression; @@ -388,7 +404,7 @@ namespace AibisDream.FixSystem } } - public struct EmoState : IState + public struct EmoState : IFixState { public FixState GetState => FixState.Emo; @@ -420,7 +436,7 @@ namespace AibisDream.FixSystem } } - public struct OpState : IState + public struct OpState : IFixState { public FixState GetState => FixState.Op; @@ -444,7 +460,7 @@ namespace AibisDream.FixSystem } } - public struct DreamState : IState + public struct DreamState : IFixState { public FixState GetState => FixState.Dream; @@ -471,7 +487,7 @@ namespace AibisDream.FixSystem } } - public struct EmoCutState : IState + public struct EmoCutState : IFixState { public FixState GetState => FixState.EmoCut; @@ -521,7 +537,7 @@ namespace AibisDream.FixSystem } } - public struct MemoryCutState : IState + public struct MemoryCutState : IFixState { public FixState GetState => FixState.MemoryCut; @@ -571,7 +587,7 @@ namespace AibisDream.FixSystem } } - public struct LogicCutState : IState + public struct LogicCutState : IFixState { public FixState GetState => FixState.LogicCut; @@ -619,7 +635,7 @@ namespace AibisDream.FixSystem } } - public struct AnalysisModeState : IState + public struct AnalysisModeState : IFixState { public FixState GetState => FixState.AnalysisMode; @@ -671,7 +687,7 @@ namespace AibisDream.FixSystem } } - public struct SalesState : IState + public struct SalesState : IFixState { private string _systemView; @@ -742,7 +758,7 @@ namespace AibisDream.FixSystem } } - public struct BlockPuzzleState : IState + public struct BlockPuzzleState : IFixState { private const string puzzleName = "Game2"; private const float blockPuzzleScale = 1.6f; diff --git a/Assets/Scripts/FixSystemNew/FixSystemCenter.cs b/Assets/Scripts/FixSystemNew/FixSystemCenter.cs index ea94a7961..9e165a2e3 100644 --- a/Assets/Scripts/FixSystemNew/FixSystemCenter.cs +++ b/Assets/Scripts/FixSystemNew/FixSystemCenter.cs @@ -3,6 +3,7 @@ using System.Collections; using AibisDream.Framework; using AibisDream.Kit; using AibisDream.SaveSystem; +using UnityEngine; namespace AibisDream.FixSystem { @@ -45,6 +46,45 @@ namespace AibisDream.FixSystem public static FixStateMachine StateMachine; #endregion + + #region 快照 + + /// 捕获 Fix 场景宏观快照。 + public FixSnapshotDto CaptureSnapshot() + { + var bodyModule = SystemDic.Get(); + var eyeSystem = SystemDic.Get(); + var repairManager = RepairSystemManager.Instance; + + return new FixSnapshotDto + { + state = StateMachine.CurState.ToString(), + args = _data.args, + moduleState = bodyModule?.GetCurrentModuleState().ToString(), + eyeColorState = eyeSystem?.GetCurrentColorState().ToString(), + isSystemOn = FixPanelSystem.Instance?.IsSystemOn ?? false, + currentRepairSystemType = repairManager?.GetCurrentSystemType()?.Name + }; + } + + /// 还原 Fix 场景宏观快照。调用 EnterImmediate 跳过动画。 + public IEnumerator RestoreSnapshot(FixSnapshotDto dto) + { + if (dto == null || string.IsNullOrEmpty(dto.state)) + { + yield break; + } + + if (!Enum.TryParse(dto.state, out var state)) + { + Debug.LogWarning($"[FixSystemCenter] 无法解析 FixState: {dto.state}"); + yield break; + } + + yield return StateMachine.SwitchStateImmediate(state, dto.args ?? ""); + } + + #endregion } [Serializable] diff --git a/Assets/Scripts/FixSystemNew/IFixState.cs b/Assets/Scripts/FixSystemNew/IFixState.cs new file mode 100644 index 000000000..80bad628b --- /dev/null +++ b/Assets/Scripts/FixSystemNew/IFixState.cs @@ -0,0 +1,18 @@ +using System.Collections; +using AibisDream.Framework; + +namespace AibisDream.FixSystem +{ + /// + /// Fix 场景专用状态接口,扩展 增加读档快速进入入口。 + /// + public interface IFixState : IState + { + /// 读档专用:跳过 camera/timeline/fade 等动画,直接到达终态。 + IEnumerator EnterImmediate() + { + // P1 占位默认实现:后续各 State 可覆盖为具体逻辑 + yield break; + } + } +} diff --git a/Assets/Scripts/FixSystemNew/IFixState.cs.meta b/Assets/Scripts/FixSystemNew/IFixState.cs.meta new file mode 100644 index 000000000..95f2621a6 --- /dev/null +++ b/Assets/Scripts/FixSystemNew/IFixState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7d5df9cd63e8db54da758ad165a5a6b5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Framework/StateMachineKit/StateMachineKit.cs b/Assets/Scripts/Framework/StateMachineKit/StateMachineKit.cs index b075a54b2..850f22338 100644 --- a/Assets/Scripts/Framework/StateMachineKit/StateMachineKit.cs +++ b/Assets/Scripts/Framework/StateMachineKit/StateMachineKit.cs @@ -6,11 +6,13 @@ namespace AibisDream.Framework public class StateMachine where T : Enum { public T CurState => _curState.GetState; + public bool HasState => _curState != null; + public IState CurrentStateObj => _curState; public event Action OnStateSwitch; private IState _curState; private readonly Func> _createState; - + public StateMachine(Func> createState) { _createState = createState; @@ -30,7 +32,16 @@ namespace AibisDream.Framework OnStateSwitch?.Invoke(nextState); yield return _curState.Enter(); } - + + /// + /// 强制设置内部状态对象,不触发 Exit / Enter / OnStateSwitch。 + /// 用于读档等需要绕过正常状态过渡的场景。 + /// + public void SetStateImmediate(T state, string args = "") + { + _curState = _createState.Invoke(state, args); + } + public IEnumerator QuitState() { yield return _curState?.Exit(); diff --git a/Assets/Scripts/MiniGame/Peipei/Eye/EyeSystem.cs b/Assets/Scripts/MiniGame/Peipei/Eye/EyeSystem.cs index 84a1bfc19..38d24228e 100644 --- a/Assets/Scripts/MiniGame/Peipei/Eye/EyeSystem.cs +++ b/Assets/Scripts/MiniGame/Peipei/Eye/EyeSystem.cs @@ -31,6 +31,10 @@ namespace AibisDream public ViewCameraManager cameraManager; private IEyeStateEffect eyeStateEffect; private EyeData _eyeData = new(); + + /// 获取当前 Eye 颜色阶段。 + public EyeData.EyeColorState GetCurrentColorState() => _eyeData.currentState; + private Tween hsvShiftTween; private MouseFollowAndZoom mouseFollowAndZoom;