// State control funcs void CStateModule::Switch_State( DC_ID StateID ) { if( StateID <= DC_INVALID_ID ) { Log(LOG_STATE, "Invalid State ID to Switch_State(): %d\n", StateID); return; } // Get the State obj CState* pNewState = Create_State( StateID ); if( !pNewState ) { Log(LOG_STATE, "Could not create State: %d\n", StateID); return; } DLog(LOG_STATE, "Switching to State: %d\n", StateID); // If we have a current State, stop it CState* pCurState = Get_Current_State(); if( pCurState ) { pCurState->Stop(); // Pop it from the stack m_StateStack.pop_back(); // Delete the State obj delete pCurState; } // Push the new State on top m_StateStack.push_back( pNewState ); // Start the new State pNewState->Start(); }
void CStateModule::Push_State( DC_ID StateID ) { if( StateID <= DC_INVALID_ID ) { Log(LOG_STATE, "Invalid State ID to Push_State(): %d\n", StateID); return; } // Get the State obj CState* pNewState = Create_State( StateID ); if( !pNewState ) { Log(LOG_STATE, "Could not create State: %d\n", StateID); return; } DLog(LOG_STATE, "Pushing State %d\n", StateID); // If we have a current State, pause it CState* pCurState = Get_Current_State(); if( pCurState ) { pCurState->Pause(); } // Push the new State on top m_StateStack.push_back( pNewState ); // Start the new State pNewState->Start(); }