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);