From 908d3e41f2a6838bdf7be50181def1c550b27353 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=80=9D=E6=B5=B7?= <1464576565@qq.com> Date: Wed, 10 Sep 2025 16:06:07 +0800 Subject: [PATCH] fixed --- Runtime/FSM/HighPerfFSM.cs | 44 +++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/Runtime/FSM/HighPerfFSM.cs b/Runtime/FSM/HighPerfFSM.cs index 7ad8876..5806ace 100644 --- a/Runtime/FSM/HighPerfFSM.cs +++ b/Runtime/FSM/HighPerfFSM.cs @@ -215,38 +215,42 @@ namespace AlicizaX.Fsm { if (_disposed) return; + bool flag = false; if (!Initialized) { Reset(Current); - goto EDITOR_TRACK; + flag = true; } - TimeInState += deltaTime; + if (!flag) + { + TimeInState += deltaTime; - // 1) state internal update (may suggest next state) - int suggested = _funcs[Current].OnUpdate(_bb); - if (suggested >= 0 && suggested != Current) - { - ChangeState(suggested); - } - else - { - // 2) transitions (timeout first, then condition) - ref readonly TransitionIndex ti = ref _index[Current]; - for (int i = 0; i < ti.Length; i++) + // 1) state internal update (may suggest next state) + int suggested = _funcs[Current].OnUpdate(_bb); + if (suggested >= 0 && suggested != Current) { - ref readonly var tr = ref _trans[ti.Start + i]; - bool timeoutOk = (tr.Timeout > 0f && TimeInState >= tr.Timeout); - bool condOk = (!timeoutOk && tr.Cond != null && tr.Cond(_bb)); - if (timeoutOk || condOk) + ChangeState(suggested); + } + else + { + // 2) transitions (timeout first, then condition) + ref readonly TransitionIndex ti = ref _index[Current]; + for (int i = 0; i < ti.Length; i++) { - ChangeState(tr.To); - break; + ref readonly var tr = ref _trans[ti.Start + i]; + bool timeoutOk = (tr.Timeout > 0f && TimeInState >= tr.Timeout); + bool condOk = (!timeoutOk && tr.Cond != null && tr.Cond(_bb)); + if (timeoutOk || condOk) + { + ChangeState(tr.To); + break; + } } } } - EDITOR_TRACK: + #if UNITY_EDITOR if (FSMDebugger.Enabled) FSMDebugger.Track(this);