fixed
This commit is contained in:
parent
7157a9fa25
commit
908d3e41f2
@ -215,38 +215,42 @@ namespace AlicizaX.Fsm
|
|||||||
{
|
{
|
||||||
if (_disposed) return;
|
if (_disposed) return;
|
||||||
|
|
||||||
|
bool flag = false;
|
||||||
if (!Initialized)
|
if (!Initialized)
|
||||||
{
|
{
|
||||||
Reset(Current);
|
Reset(Current);
|
||||||
goto EDITOR_TRACK;
|
flag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeInState += deltaTime;
|
if (!flag)
|
||||||
|
{
|
||||||
|
TimeInState += deltaTime;
|
||||||
|
|
||||||
// 1) state internal update (may suggest next state)
|
// 1) state internal update (may suggest next state)
|
||||||
int suggested = _funcs[Current].OnUpdate(_bb);
|
int suggested = _funcs[Current].OnUpdate(_bb);
|
||||||
if (suggested >= 0 && suggested != Current)
|
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++)
|
|
||||||
{
|
{
|
||||||
ref readonly var tr = ref _trans[ti.Start + i];
|
ChangeState(suggested);
|
||||||
bool timeoutOk = (tr.Timeout > 0f && TimeInState >= tr.Timeout);
|
}
|
||||||
bool condOk = (!timeoutOk && tr.Cond != null && tr.Cond(_bb));
|
else
|
||||||
if (timeoutOk || condOk)
|
{
|
||||||
|
// 2) transitions (timeout first, then condition)
|
||||||
|
ref readonly TransitionIndex ti = ref _index[Current];
|
||||||
|
for (int i = 0; i < ti.Length; i++)
|
||||||
{
|
{
|
||||||
ChangeState(tr.To);
|
ref readonly var tr = ref _trans[ti.Start + i];
|
||||||
break;
|
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 UNITY_EDITOR
|
||||||
if (FSMDebugger.Enabled)
|
if (FSMDebugger.Enabled)
|
||||||
FSMDebugger.Track(this);
|
FSMDebugger.Track(this);
|
||||||
|
Loading…
Reference in New Issue
Block a user