//
// PlayerObject::toggleFlyMode from 0x100229678 to 0x10022990c (660 bytes)
//
// 4 xrefs:
// > GJBaseGameLayer::switchToFlyMode @ 0x1001e658c
// > PlayerObject::switchedToMode @ 0x1002270c4
// > PlayerObject::copyAttributes @ 0x10022d2ec
// > MenuGameLayer::resetPlayer @ 0x10039b028
//
// 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 __fastcall PlayerObject::toggleFlyMode(PlayerObject *a1, bool a2, bool a3)
{
__int64 v3; // x29
__int64 v4; // x30
_BOOL4 v6; // w20
bool m_isPlatformer; // w22
GameManager *v9; // x0
__n128 v10; // q0
cocos2d::CCSprite *m_iconSprite; // x22
__n128 v12; // q1
cocos2d::CCSprite *m_vehicleSprite; // x22
__n128 v14; // q0
__n128 v15; // q1
__n128 v16; // q0
cocos2d::CCSprite *v17; // x22
__n128 v18; // q1
cocos2d::CCMotionStreak *m_shipStreak; // x0
int v20; // [xsp+8h] [xbp-38h] BYREF
__int64 v21; // [xsp+30h] [xbp-10h]
__int64 v22; // [xsp+38h] [xbp-8h]
if ( a1->m_isShip != a2 )
{
v21 = v3;
v22 = v4;
v6 = 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 *, float))a1->setRotation)(a1, 0.0);
a1->m_isOnGround2 = 0;
a1->m_isOnGround = 0;
a1->m_shouldTryPlacingCheckpoint = 0;
PlayerObject::removePendingCheckpoint(a1);
if ( a1->m_isShip )
{
PlayerObject::stopPlatformerJumpAnimation(a1);
m_isPlatformer = a1->m_isPlatformer;
v9 = GameManager::sharedState();
if ( m_isPlatformer )
{
PlayerObject::updatePlayerJetpackFrame(a1, v9->m_playerJetpack.random - v9->m_playerJetpack.seed);
v10 = ((__n128 (__fastcall *)(cocos2d::CCSprite *, float))a1->m_iconSprite->setScale)(a1->m_iconSprite, 0.6);
m_iconSprite = a1->m_iconSprite;
v10.n128_u32[0] = 6.0;
v12.n128_u32[0] = 4.0;
sub_100022980(v10, v12, &v20);
((void (__fastcall *)(cocos2d::CCSprite *, int *))m_iconSprite->setPosition)(m_iconSprite, &v20);
m_vehicleSprite = a1->m_vehicleSprite;
v14.n128_u32[0] = 0;
v15.n128_u32[0] = 0;
}
else
{
PlayerObject::updatePlayerShipFrame(a1, v9->m_playerShip.random - v9->m_playerShip.seed);
v16 = ((__n128 (__fastcall *)(cocos2d::CCSprite *, float))a1->m_iconSprite->setScale)(a1->m_iconSprite, 0.55);
v17 = a1->m_iconSprite;
v16.n128_u32[0] = 0;
v18.n128_u32[0] = 5.0;
sub_100022980(v16, v18, &v20);
((void (__fastcall *)(cocos2d::CCSprite *, int *))v17->setPosition)(v17, &v20);
m_vehicleSprite = a1->m_vehicleSprite;
v14.n128_u32[0] = 0;
v15.n128_u32[0] = -5.0;
}
sub_100022980(v14, v15, &v20);
((void (__fastcall *)(cocos2d::CCSprite *, int *))m_vehicleSprite->setPosition)(m_vehicleSprite, &v20);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))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;
if ( a1->m_hasGroundParticles )
cocos2d::CCParticleSystem::stopSystem(a1->m_playerGroundParticles);
a1->m_hasGroundParticles = 0;
if ( !a3 )
PlayerObject::spawnPortalCircle(a1, (cocos2d::ccColor3B)-65281, 50.0);
PlayerObject::activateStreak(a1);
GJActionManager::stopInternalAction(a1->m_actionManager, 6);
((void (__fastcall *)(PlayerObject *, float))a1->setScaleX)(a1, a1->m_vehicleSize);
((void (__fastcall *)(PlayerObject *, float))a1->setScaleY)(a1, a1->m_vehicleSize);
m_shipStreak = a1->m_shipStreak;
if ( m_shipStreak && !a1->m_isPlatformer && !a1->m_isHidden )
((void (__fastcall *)(cocos2d::CCMotionStreak *, __int64))m_shipStreak->setVisible)(m_shipStreak, 1);
}
else
{
PlayerObject::resetPlayerIcon(a1);
}
if ( v6 )
{
PlayerObject::updatePlayerArt(a1);
PlayerObject::updateDashArt(a1);
}
}
}