public void ChangeState(string sName) { if (m_currentState != null && m_currentState.GetStateName() == sName) { // You can't switch from yourself to yourself. return; } F3_BaseState nextState = FindState(sName); if (nextState != null) { if (m_currentState != null && m_currentState.m_onExit != null) { m_currentState.m_onExit(); } if (nextState.m_onEnter != null) { nextState.m_onEnter(); } m_currentState = nextState; } }
public bool CreateState(string sName, OnEnterState enterFunc, OnUpdateState updateFunc, OnExitState exitFunc) { if (FindState(sName) != null) { // We don't want any duplicate. return false; } F3_BaseState newState = new F3_BaseState(sName, enterFunc, updateFunc, exitFunc); if (newState == null) { // Failed to Create. return false; } m_states.Add(newState); return true; }