//
// PlayerObject::toggleFlyMode from 0x14039a4f0 to 0x14039a818 (808 bytes)
//
// 23 xrefs:
// > GJBaseGameLayer::setupLevelStart @ 0x1402123ad
// > GJBaseGameLayer::setupLevelStart @ 0x140212410
// > GJBaseGameLayer::setupLevelStart @ 0x140212437
// > GJBaseGameLayer::setupLevelStart @ 0x1402124d0
// > GJBaseGameLayer::setupLevelStart @ 0x1402127c3
// > GJBaseGameLayer::setupLevelStart @ 0x14021285c
// > GJBaseGameLayer::setupLevelStart @ 0x140212906
// > GJBaseGameLayer::setupLevelStart @ 0x14021299f
// > GJBaseGameLayer::switchToRobotMode @ 0x140212c40
// > GJBaseGameLayer::switchToSpiderMode @ 0x140212d30
// > GJBaseGameLayer::switchToRollMode @ 0x140212e20
// > GJBaseGameLayer::collisionCheckObjects @ 0x140214ee2
// > GJBaseGameLayer::collisionCheckObjects @ 0x140215001
// > GJBaseGameLayer::collisionCheckObjects @ 0x1402151c2
// > GJBaseGameLayer::collisionCheckObjects @ 0x140215381
// > GJBaseGameLayer::collisionCheckObjects @ 0x14021547b
// > MenuGameLayer::resetPlayer @ 0x1403329ea
// > MenuGameLayer::resetPlayer @ 0x1403330da
// > PlayerObject::resetObject @ 0x14039735e
// > PlayerObject::switchedToMode @ 0x14039be49
// > PlayerObject::copyAttributes @ 0x1403a055b
// > PlayerObject::loadFromCheckpoint @ 0x1403a2c7e
// > ??> @ 0x1406d6578
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
// Hidden C++ exception states: #wind=3
void PlayerObject::toggleFlyMode(PlayerObject *a1, bool a2, bool a3)
{
_DWORD *v6; // rax
float v7; // xmm0_4
cocos2d::CCSprite_vtbl *v8; // rbx
double v9; // xmm0_8
const cocos2d::CCPoint *v10; // rax
float v11; // xmm0_4
cocos2d::CCSprite_vtbl *v12; // rbx
const cocos2d::CCPoint *v13; // rax
cocos2d::CCSprite_vtbl *v14; // rbx
const cocos2d::CCPoint *v15; // rax
_BOOL8 v16; // rdx
_BOOL8 v17; // rdx
cocos2d::CCMotionStreak *m_shipStreak; // rcx
void *v19; // [rsp+40h] [rbp+8h] BYREF
__int16 v20; // [rsp+48h] [rbp+10h]
if ( a1->m_isShip != a2 )
{
a1->m_gameModeChangedTime = a1->m_totalTime;
a1->m_isShip = a2;
if ( a2 )
PlayerObject::switchedToMode(a1, ShipPortal);
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
a1->m_yVelocity = a1->m_yVelocity * 0.5;
((void (__fastcall *)(PlayerObject *))a1->setRotation)(a1);
a1->m_isOnGround2 = 0;
a1->m_isOnGround = 0;
a1->m_shouldTryPlacingCheckpoint = 0;
PlayerObject::removePendingCheckpoint(a1);
if ( a1->m_isShip )
{
PlayerObject::stopPlatformerJumpAnimation(a1);
v6 = (_DWORD *)qword_1406C2ED8;
if ( a1->m_isPlatformer )
{
if ( !qword_1406C2ED8 )
{
v19 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v19);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v6 = (_DWORD *)qword_1406C2ED8;
}
PlayerObject::updatePlayerJetpackFrame(a1, v6[219] - v6[220]);
v11 = ((float (__fastcall *)(cocos2d::CCSprite *))a1->m_iconSprite->setScale_0)(a1->m_iconSprite);
v12 = a1->m_iconSprite->__vftable;
v9 = cocos2d::CCPoint::CCPoint(v11, 6.0);
v12->setPosition_0(a1->m_iconSprite, v13);
}
else
{
if ( !qword_1406C2ED8 )
{
v19 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v19);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v6 = (_DWORD *)qword_1406C2ED8;
}
PlayerObject::updatePlayerShipFrame(a1, v6[180] - v6[181]);
v7 = ((float (__fastcall *)(cocos2d::CCSprite *))a1->m_iconSprite->setScale_0)(a1->m_iconSprite);
v8 = a1->m_iconSprite->__vftable;
v9 = cocos2d::CCPoint::CCPoint(v7, 0.0);
v8->setPosition_0(a1->m_iconSprite, v10);
}
v14 = a1->m_vehicleSprite->__vftable;
cocos2d::CCPoint::CCPoint(*(float *)&v9, 0.0);
v14->setPosition_0(a1->m_vehicleSprite, v15);
LOBYTE(v16) = 1;
a1->m_vehicleSprite->setVisible(a1->m_vehicleSprite, v16);
PlayerObject::updatePlayerGlow(a1);
if ( !a1->m_isHidden )
{
cocos2d::CCParticleSystem::resetSystem(a1->m_trailingParticles);
cocos2d::CCParticleSystem::resetSystem(a1->m_shipClickParticles);
}
cocos2d::CCParticleSystem::stopSystem(a1->m_shipClickParticles);
a1->m_hasShipParticles = 0;
if ( a1->m_hasGroundParticles )
cocos2d::CCParticleSystem::stopSystem(a1->m_playerGroundParticles);
a1->m_hasGroundParticles = 0;
if ( !a3 )
{
v20 = 255;
LOWORD(v19) = 255;
BYTE2(v19) = -1;
PlayerObject::spawnPortalCircle(a1, (cocos2d::ccColor3B *)&v19, 50.0);
}
PlayerObject::activateStreak(a1);
PlayerObject::updatePlayerScale(a1);
m_shipStreak = a1->m_shipStreak;
if ( m_shipStreak && !a1->m_isPlatformer && !a1->m_isHidden )
{
LOBYTE(v17) = 1;
m_shipStreak->setVisible(m_shipStreak, v17);
}
}
else
{
PlayerObject::resetPlayerIcon(a1);
}
if ( a2 )
{
PlayerObject::updatePlayerArt(a1);
PlayerObject::updateDashArt(a1);
}
}
}