//
// PlayerObject::toggleFlyMode from 0x43e950 to 0x43eb32 (482 bytes)
//
// 4 xrefs:
// > PlayerObject::switchedToMode @ 0x43e6de
// > PlayerObject::copyAttributes @ 0x43f938
// > MenuGameLayer::resetPlayer @ 0x492728
// > GJBaseGameLayer::switchToFlyMode @ 0x58ee0e
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:48:25 +0000
//
int __fastcall PlayerObject::toggleFlyMode(int this, int a2, int a3)
{
int v4; // r4
GameManager *v6; // r0
int v7; // r0
int v8; // r9
void (__fastcall *v9)(int, int *); // r10
int v10; // r9
float v11; // r2
void (__fastcall *v12)(int, int *); // r10
int v13; // r0
int v14; // r9
void (__fastcall *v15)(int, int *); // r10
int v16[2]; // [sp+4h] [bp-10h] BYREF
v4 = this;
if ( *(unsigned __int8 *)(this + 1953) != a2 )
{
*(_QWORD *)(this + 1592) = *(_QWORD *)(this + 2128);
*(_BYTE *)(this + 1953) = a2;
if ( a2 )
PlayerObject::switchedToMode((char *)this, 5);
PlayerObject::stopRotation((PlayerObject *)v4, 0, 7);
*(double *)(v4 + 1928) = *(double *)(v4 + 1928) * 0.5;
(*(void (__fastcall **)(int, _DWORD))(*(_DWORD *)v4 + 180))(v4, 0);
*(_BYTE *)(v4 + 2036) = 0;
*(_BYTE *)(v4 + 1961) = 0;
*(_BYTE *)(v4 + 1603) = 0;
PlayerObject::removePendingCheckpoint((PlayerObject *)v4);
if ( *(_BYTE *)(v4 + 1953) )
{
v6 = (GameManager *)PlayerObject::stopPlatformerJumpAnimation(v4);
if ( *(_BYTE *)(v4 + 2320) )
{
v13 = GameManager::sharedState(v6);
PlayerObject::updatePlayerJetpackFrame(
(PlayerObject *)v4,
(const char *)(*(_DWORD *)(v13 + 684) - *(_DWORD *)(v13 + 688)));
(*(void (__fastcall **)(_DWORD, int))(**(_DWORD **)(v4 + 1492) + 80))(*(_DWORD *)(v4 + 1492), 1058642330);
v14 = *(_DWORD *)(v4 + 1492);
v15 = *(void (__fastcall **)(int, int *))(*(_DWORD *)v14 + 92);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v16, 6.0, 4.0);
v15(v14, v16);
v10 = *(_DWORD *)(v4 + 1508);
v11 = 0.0;
}
else
{
v7 = GameManager::sharedState(v6);
PlayerObject::updatePlayerShipFrame(
(PlayerObject *)v4,
(const char *)(*(_DWORD *)(v7 + 528) - *(_DWORD *)(v7 + 532)));
(*(void (__fastcall **)(_DWORD, int))(**(_DWORD **)(v4 + 1492) + 80))(*(_DWORD *)(v4 + 1492), 1057803469);
v8 = *(_DWORD *)(v4 + 1492);
v9 = *(void (__fastcall **)(int, int *))(*(_DWORD *)v8 + 92);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v16, 0.0, 5.0);
v9(v8, v16);
v10 = *(_DWORD *)(v4 + 1508);
v11 = -5.0;
}
v12 = *(void (__fastcall **)(int, int *))(*(_DWORD *)v10 + 92);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v16, 0.0, v11);
v12(v10, v16);
(*(void (__fastcall **)(_DWORD, int))(**(_DWORD **)(v4 + 1508) + 172))(*(_DWORD *)(v4 + 1508), 1);
PlayerObject::updatePlayerGlow((PlayerObject *)v4);
if ( !*(_BYTE *)(v4 + 1483) )
{
cocos2d::CCParticleSystem::resetSystem(*(cocos2d::CCParticleSystem **)(v4 + 1748));
cocos2d::CCParticleSystem::resetSystem(*(cocos2d::CCParticleSystem **)(v4 + 1752));
}
cocos2d::CCParticleSystem::stopSystem(*(cocos2d::CCParticleSystem **)(v4 + 1752));
*(_BYTE *)(v4 + 1607) = 0;
PlayerObject::deactivateParticle(v4);
if ( !a3 )
{
LOWORD(v16[0]) = 255;
BYTE2(v16[0]) = -1;
PlayerObject::spawnPortalCircle(v4, v16[0], (CCCircleWave *)0x42480000);
}
PlayerObject::activateStreak((cocos2d::CCNode **)v4);
PlayerObject::updatePlayerScale((GJActionManager **)v4);
this = *(_DWORD *)(v4 + 1548);
if ( this && !*(_BYTE *)(v4 + 2320) && !*(_BYTE *)(v4 + 1483) )
this = (*(int (__fastcall **)(int, int))(*(_DWORD *)this + 172))(this, 1);
}
else
{
this = PlayerObject::resetPlayerIcon((PlayerObject *)v4);
}
if ( a2 )
return PlayerObject::modeDidChange((PlayerObject *)v4);
}
return this;
}