//
// PlayerObject::toggleFlyMode from 0x346df4 to 0x346fd6 (482 bytes)
//
// 4 xrefs:
// > PlayerObject::switchedToMode @ 0x346ba2
// > PlayerObject::copyAttributes @ 0x34775c
// > MenuGameLayer::resetPlayer @ 0x3a9964
// > GJBaseGameLayer::switchToFlyMode @ 0x46ef4e
//
// 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
//
void PlayerObject::toggleFlyMode(PlayerObject *a1, bool a2, bool a3)
{
_BOOL4 v3; // r8
_BOOL4 v5; // r7
GameManager *v6; // r0
cocos2d::CCSprite *v7; // r9
void (__fastcall *v8)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r10
cocos2d::CCSprite *m_vehicleSprite; // r9
float v10; // r2
void (__fastcall *v11)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r10
GameManager *v12; // r0
cocos2d::CCSprite *m_iconSprite; // r9
void (__fastcall *setPosition)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r10
cocos2d::CCMotionStreak *m_shipStreak; // r0
cocos2d::CCPoint v16; // [sp+4h] [bp-10h] BYREF
v3 = a3;
v5 = a2;
if ( a1->m_isShip != a2 )
{
a1->m_gameModeChangedTime = a1->m_totalTime;
a1->m_isShip = a2;
if ( a2 )
PlayerObject::switchedToMode(a1, ShipPortal);
PlayerObject::stopRotation(a1, 0, 7);
a1->m_yVelocity = a1->m_yVelocity * 0.5;
((void (__fastcall *)(PlayerObject *, _DWORD))a1->setRotation)(a1, 0);
a1->m_isOnGround2 = 0;
a1->m_isOnGround = 0;
a1->m_shouldTryPlacingCheckpoint = 0;
PlayerObject::removePendingCheckpoint(a1);
if ( a1->m_isShip )
{
PlayerObject::stopPlatformerJumpAnimation(a1);
if ( a1->m_isPlatformer )
{
v12 = GameManager::sharedState();
PlayerObject::updatePlayerJetpackFrame(a1, v12->m_playerJetpack.random - v12->m_playerJetpack.seed);
((void (__fastcall *)(cocos2d::CCSprite *, int))a1->m_iconSprite->setScale)(a1->m_iconSprite, 1058642330);
m_iconSprite = a1->m_iconSprite;
setPosition = m_iconSprite->setPosition;
cocos2d::CCPoint::CCPoint(&v16, 6.0, 4.0);
setPosition(m_iconSprite, &v16);
m_vehicleSprite = a1->m_vehicleSprite;
v10 = 0.0;
}
else
{
v6 = GameManager::sharedState();
PlayerObject::updatePlayerShipFrame(a1, v6->m_playerShip.random - v6->m_playerShip.seed);
((void (__fastcall *)(cocos2d::CCSprite *, int))a1->m_iconSprite->setScale)(a1->m_iconSprite, 1057803469);
v7 = a1->m_iconSprite;
v8 = v7->setPosition;
cocos2d::CCPoint::CCPoint(&v16, 0.0, 5.0);
v8(v7, &v16);
m_vehicleSprite = a1->m_vehicleSprite;
v10 = -5.0;
}
v11 = m_vehicleSprite->setPosition;
cocos2d::CCPoint::CCPoint(&v16, 0.0, v10);
v11(m_vehicleSprite, &v16);
a1->m_vehicleSprite->setVisible(a1->m_vehicleSprite, 1);
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;
PlayerObject::deactivateParticle(a1);
if ( !v3 )
{
LOWORD(v16.x) = 255;
BYTE2(v16.x) = -1;
PlayerObject::spawnPortalCircle(a1, *(cocos2d::ccColor3B *)&v16.x, 50.0);
}
PlayerObject::activateStreak(a1);
PlayerObject::updatePlayerScale(a1);
m_shipStreak = a1->m_shipStreak;
if ( m_shipStreak && !a1->m_isPlatformer && !a1->m_isHidden )
m_shipStreak->setVisible(m_shipStreak, 1);
}
else
{
PlayerObject::resetPlayerIcon(a1);
}
if ( v5 )
PlayerObject::modeDidChange(a1);
}
}