Extract updatePauseState from Game::run (#13893)

This commit is contained in:
JosiahWI 2023-10-18 13:17:30 -05:00 committed by GitHub
parent 6026003508
commit 62eb6cfed0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -788,6 +788,7 @@ protected:
void updateCameraDirection(CameraOrientation *cam, float dtime);
void updateCameraOrientation(CameraOrientation *cam, float dtime);
void updatePlayerControl(const CameraOrientation &cam);
void updatePauseState();
void step(f32 dtime);
void processClientEvents(CameraOrientation *cam);
void updateCamera(f32 dtime);
@ -1238,23 +1239,12 @@ void Game::run()
cam_view.camera_pitch) * m_cache_cam_smoothing;
updatePlayerControl(cam_view);
{
bool was_paused = m_is_paused;
m_is_paused = simple_singleplayer_mode && g_menumgr.pausesGame();
if (m_is_paused)
dtime = 0.0f;
if (!was_paused && m_is_paused) {
pauseAnimation();
sound_manager->pauseAll();
} else if (was_paused && !m_is_paused) {
resumeAnimation();
sound_manager->resumeAll();
}
}
if (!m_is_paused)
updatePauseState();
if (m_is_paused)
dtime = 0.0f;
else
step(dtime);
processClientEvents(&cam_view_target);
updateDebugState();
updateCamera(dtime);
@ -2696,6 +2686,20 @@ void Game::updatePlayerControl(const CameraOrientation &cam)
//tt.stop();
}
void Game::updatePauseState()
{
bool was_paused = this->m_is_paused;
this->m_is_paused = this->simple_singleplayer_mode && g_menumgr.pausesGame();
if (!was_paused && this->m_is_paused) {
this->pauseAnimation();
this->sound_manager->pauseAll();
} else if (was_paused && !this->m_is_paused) {
this->resumeAnimation();
this->sound_manager->resumeAll();
}
}
inline void Game::step(f32 dtime)
{