@@ -30,36 +30,36 @@ class $modify(DementiaPlayerObject, PlayerObject) {
3030 };
3131
3232 bool pushButton (PlayerButton p0) {
33- if (m_gameLayer) {
34- auto f = m_fields.self ();
33+ if (!m_gameLayer) return PlayerObject::pushButton (p0);
3534
36- auto rnd = rng::fast ();
37- log::trace (" player teleport chance {}" , rnd);
35+ auto f = m_fields.self ();
3836
39- if ( auto fmod = FMODAudioEngine::sharedEngine ()) {
40- FMOD::Channel* musicChannel = nullptr ;
37+ auto rnd = rng::fast ();
38+ log::trace ( " player teleport chance {} " , rnd) ;
4139
42- auto bgchannel = fmod-> m_backgroundMusicChannel ;
43- auto channel = bgchannel-> getChannel ( 0 , &musicChannel) ;
40+ if ( auto fmod = FMODAudioEngine::sharedEngine ()) {
41+ FMOD::Channel* musicChannel = nullptr ;
4442
45- auto onGround = m_isOnGround || m_isOnGround2 || m_isOnGround3 || m_isOnGround4;
46- // dementia
47- if (rnd <= f->chance ) {
48- setPosition ({f->lastX , f->lastY });
49- log::trace (" player has dementia to ({}, {}), play time {}" , f->lastX , f->lastY , f->lastMusicTime );
43+ auto bgchannel = fmod->m_backgroundMusicChannel ;
44+ auto channel = bgchannel->getChannel (0 , &musicChannel);
5045
51- // set the music time back to the last recorded time
52- if (musicChannel) musicChannel->setPosition (f->lastMusicTime , FMOD_TIMEUNIT_MS);
46+ auto onGround = m_isOnGround || m_isOnGround2 || m_isOnGround3 || m_isOnGround4;
47+ // dementia
48+ if (rnd <= f->chance ) {
49+ setPosition ({f->lastX , f->lastY });
50+ log::trace (" player has dementia to ({}, {}), play time {}" , f->lastX , f->lastY , f->lastMusicTime );
5351
54- return PlayerObject::pushButton (p0);
55- } else if (onGround) { // save the position only if on ground
56- f->lastX = getPositionX ();
57- f->lastY = getPositionY ();
52+ // set the music time back to the last recorded time
53+ if (musicChannel) musicChannel->setPosition (f->lastMusicTime , FMOD_TIMEUNIT_MS);
5854
59- f->lastMusicTime = fmod->getMusicTimeMS (1 );
55+ return PlayerObject::pushButton (p0);
56+ } else if (onGround) { // save the position only if on ground
57+ f->lastX = getPositionX ();
58+ f->lastY = getPositionY ();
6059
61- log::trace (" position recorded to ({}, {}) and music time {}" , f->lastX , f->lastY , f->lastMusicTime );
62- };
60+ f->lastMusicTime = fmod->getMusicTimeMS (1 );
61+
62+ log::trace (" position recorded to ({}, {}) and music time {}" , f->lastX , f->lastY , f->lastMusicTime );
6363 };
6464 };
6565
0 commit comments