public void SwitchToState(int id, IMessage param) { if (m_CurState != null && m_CurState.Id != id) { m_CurState.OnExit(); } m_CurState = GetState(id); m_CurState.OnEnter(param); }
public virtual void OnUpdate() { if (m_CurState == null) { m_CurState = m_DefaultState; m_CurState.OnEnter(); } if (m_CurState != null) { int targetId = m_CurState.OnUpdate(); if (targetId != m_CurState.Id) { SwitchToState(targetId, null); } } }