//
// PlayerObject::toggleFlyMode from 0x100416250 to 0x1004166a0 (1104 bytes)
//
// 12 xrefs:
// > GJBaseGameLayer::setupLevelStart @ 0x100123d35
// > GJBaseGameLayer::setupLevelStart @ 0x100123f22
// > GJBaseGameLayer::switchToFlyMode @ 0x100124431
// > PlayerObject::switchedToMode @ 0x100412c51
// > PlayerObject::toggleBirdMode @ 0x100416d9e
// > PlayerObject::toggleSwingMode @ 0x100417498
// > PlayerObject::toggleDartMode @ 0x100417eab
// > PlayerObject::toggleRollMode @ 0x100418557
// > PlayerObject::toggleRobotMode @ 0x10041894a
// > PlayerObject::toggleSpiderMode @ 0x100418dba
// > PlayerObject::copyAttributes @ 0x10041b624
// > MenuGameLayer::resetPlayer @ 0x1004fa6a2
//
// 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; // rax
int m_maybeSavedPlayerFrame; // esi
__int64 v8; // xmm0_8
CheckpointObject *m_pendingCheckpoint; // rdi
GameObject *Object; // r12
bool m_isPlatformer; // r12
cocos2d::CCSprite *m_iconSprite; // r12
cocos2d::CCSprite *m_iconGlow; // r12
GameManager *v14; // rax
cocos2d::CCSprite *v15; // r12
cocos2d::CCSprite *m_vehicleSprite; // r12
float v17; // xmm1_4
cocos2d::CCSprite *v18; // r12
cocos2d::CCMotionStreak *m_shipStreak; // rdi
float v20[12]; // [rsp+0h] [rbp-30h] BYREF
*(_QWORD *)v20 = v3;
if ( a1->m_isShip != a2 )
{
a1->m_gameModeChangedTime = a1->m_totalTime;
a1->m_isShip = a2;
if ( a2 )
{
PlayerObject::toggleBirdMode(a1, 0, 0);
if ( a1->m_isBall )
{
a1->m_gameModeChangedTime = a1->m_totalTime;
a1->m_isBall = 0;
if ( a1->m_vehicleSize == 1.0 || (m_maybeSavedPlayerFrame = 0, !a1->m_defaultMiniIcon) )
m_maybeSavedPlayerFrame = a1->m_maybeSavedPlayerFrame;
PlayerObject::updatePlayerFrame(a1, m_maybeSavedPlayerFrame);
if ( a1->m_isUpsideDown )
v8 = 1127481344;
else
v8 = 0;
((void (__fastcall *)(PlayerObject *, double))a1->setRotation)(a1, *(double *)&v8);
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
}
PlayerObject::toggleDartMode(a1, 0, 0);
PlayerObject::toggleRobotMode(a1, 0, 0);
PlayerObject::toggleSpiderMode(a1, 0, 0);
PlayerObject::toggleSwingMode(a1, 0, 0);
}
*(_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 *, double))a1->setRotation)(a1, 0.0);
a1->m_isOnGround2 = 0;
a1->m_isOnGround = 0;
a1->m_shouldTryPlacingCheckpoint = 0;
m_pendingCheckpoint = a1->m_pendingCheckpoint;
if ( m_pendingCheckpoint )
{
Object = CheckpointObject::getObject(m_pendingCheckpoint);
GameObject::removeGlow(Object);
((void (__fastcall *)(GameObject *))Object->removeMeAndCleanup)(Object);
cocos2d::CCObject::release(a1->m_pendingCheckpoint);
a1->m_pendingCheckpoint = nullptr;
}
if ( a1->m_isShip )
{
m_isPlatformer = a1->m_isPlatformer;
if ( m_isPlatformer )
{
m_iconSprite = a1->m_iconSprite;
cocos2d::CCNode::stopActionByTag(m_iconSprite, 13);
cocos2d::CCNode::stopActionByTag(m_iconSprite, 14);
((void (__fastcall *)(cocos2d::CCSprite *, float))m_iconSprite->setScale)(m_iconSprite, 1.0);
m_iconGlow = a1->m_iconGlow;
cocos2d::CCNode::stopActionByTag(m_iconGlow, 13);
cocos2d::CCNode::stopActionByTag(m_iconGlow, 14);
((void (__fastcall *)(cocos2d::CCSprite *, float))m_iconGlow->setScale)(m_iconGlow, 1.0);
m_isPlatformer = a1->m_isPlatformer;
}
v14 = GameManager::sharedState();
if ( m_isPlatformer )
{
PlayerObject::updatePlayerJetpackFrame(a1, v14->m_playerJetpack.random - v14->m_playerJetpack.seed);
((void (__fastcall *)(cocos2d::CCSprite *, float))a1->m_iconSprite->setScale)(a1->m_iconSprite, 0.60000002);
v15 = a1->m_iconSprite;
sub_10028CBE0(v20, 6.0, 4.0);
((void (__fastcall *)(cocos2d::CCSprite *, float *))v15->setPosition)(v15, v20);
m_vehicleSprite = a1->m_vehicleSprite;
v17 = 0.0;
}
else
{
PlayerObject::updatePlayerShipFrame(a1, v14->m_playerShip.random - v14->m_playerShip.seed);
((void (__fastcall *)(cocos2d::CCSprite *, float))a1->m_iconSprite->setScale)(a1->m_iconSprite, 0.55000001);
v18 = a1->m_iconSprite;
sub_10028CBE0(v20, 0.0, 5.0);
((void (__fastcall *)(cocos2d::CCSprite *, float *))v18->setPosition)(v18, v20);
m_vehicleSprite = a1->m_vehicleSprite;
v17 = -5.0;
}
sub_10028CBE0(v20, 0.0, v17);
((void (__fastcall *)(cocos2d::CCSprite *, float *))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 ( a2 )
{
PlayerObject::updatePlayerArt(a1);
PlayerObject::updateDashArt(a1);
}
}
}