//--------------------------------------------------------------------- void _releaseFsm() { while (mQueCurrentState.Count > 0) { EbState s = mQueCurrentState[mQueCurrentState.Count - 1]; s.exit(); mQueCurrentState.RemoveAt(mQueCurrentState.Count - 1); } }
//--------------------------------------------------------------------- void _exitChildState(EbState cur_state) { if (mQueCurrentState.Count == 0) { return; } EbState s = mQueCurrentState[mQueCurrentState.Count - 1]; if (s != cur_state) { s.exit(); mQueCurrentState.Remove(s); _exitChildState(cur_state); } }
//--------------------------------------------------------------------- void _rattleOn() { if (mbRattleOn) { return; } mbRattleOn = true; while (mQueEvent.Count > 0) { IEbEvent ev = mQueEvent.Dequeue(); for (int i = mQueCurrentState.Count - 1; i >= 0; i--) { var it = mQueCurrentState[i]; EbState state = it; if (!state._isBindEvent(ev.name)) { continue; } string next_state_name = state._onEvent(ev); EbState next_state = null; if (mMapState.ContainsKey(next_state_name)) { next_state = mMapState[next_state_name]; } if (null == next_state) { break; } while (mQueCurrentState.Count > 0) { EbState s = mQueCurrentState[mQueCurrentState.Count - 1]; if (next_state == s) { break; } else if (_isDirectLine(s, next_state)) { mQueTmpState.Clear(); EbState p = next_state; do { mQueTmpState.Add(p); p = p._getParentState(); } while (p != s); while (mQueTmpState.Count > 0) { EbState q = mQueTmpState[0]; q.enter(); mQueCurrentState.Add(q); mQueTmpState.RemoveAt(0); } } else { s.exit(); mQueCurrentState.RemoveAt(mQueCurrentState.Count - 1); } } break; } } mbRattleOn = false; }