//
// PlayerObject::toggleBirdMode from 0x346ff4 to 0x3471d2 (478 bytes)
//
// 4 xrefs:
// > PlayerObject::switchedToMode @ 0x346b94
// > PlayerObject::copyAttributes @ 0x347768
// > MenuGameLayer::resetPlayer @ 0x3a9a5c
// > GJBaseGameLayer::switchToFlyMode @ 0x46ef66
//
// 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::toggleBirdMode(PlayerObject *a1, bool a2, bool a3)
{
_BOOL4 v4; // r10
_BOOL4 v5; // r11
GameManager *v6; // r0
cocos2d::CCSprite *m_iconSprite; // r7
void (__fastcall *setPosition)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r8
cocos2d::CCSprite *m_vehicleSprite; // r7
void (__fastcall *v10)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r8
int g; // r8
int r; // s16
int b; // r7
cocos2d::CCParticleSystemQuad *m_trailingParticles; // r0
void (__fastcall *setStartColor)(cocos2d::CCParticleSystem *__hidden, const cocos2d::ccColor4F *); // r3
cocos2d::ccColor3B v16; // [sp+0h] [bp-1Ch]
cocos2d::CCPoint v17[2]; // [sp+4h] [bp-18h] BYREF
v4 = a2;
v5 = a3;
if ( a1->m_isBird != a2 )
{
a1->m_gameModeChangedTime = a1->m_totalTime;
a1->m_isBird = a2;
if ( a2 )
PlayerObject::switchedToMode(a1, UfoPortal);
PlayerObject::stopRotation(a1, 0, 8);
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_isBird )
{
v6 = GameManager::sharedState();
PlayerObject::updatePlayerBirdFrame(a1, v6->m_playerBird.random - v6->m_playerBird.seed);
PlayerObject::stopPlatformerJumpAnimation(a1);
((void (__fastcall *)(cocos2d::CCSprite *, int))a1->m_iconSprite->setScale)(a1->m_iconSprite, 1057803469);
m_iconSprite = a1->m_iconSprite;
setPosition = m_iconSprite->setPosition;
cocos2d::CCPoint::CCPoint(v17, 0.0, 5.0);
setPosition(m_iconSprite, v17);
a1->m_vehicleSprite->setVisible(a1->m_vehicleSprite, 1);
m_vehicleSprite = a1->m_vehicleSprite;
v10 = m_vehicleSprite->setPosition;
cocos2d::CCPoint::CCPoint(v17, 0.0, -7.0);
v10(m_vehicleSprite, v17);
PlayerObject::updatePlayerGlow(a1);
g = a1->m_playerColor2.g;
r = a1->m_playerColor2.r;
b = a1->m_playerColor2.b;
memset(v17, 0, sizeof(v17));
m_trailingParticles = a1->m_trailingParticles;
v17[1].y = 1.0;
setStartColor = m_trailingParticles->setStartColor;
v17[0].x = (float)r / 255.0;
v17[0].y = (float)g / 255.0;
v17[1].x = (float)b / 255.0;
setStartColor(m_trailingParticles, (const cocos2d::ccColor4F *)v17);
a1->m_trailingParticles->setEndColor(a1->m_trailingParticles, (const cocos2d::ccColor4F *)v17);
if ( !a1->m_isHidden )
cocos2d::CCParticleSystem::resetSystem(a1->m_trailingParticles);
PlayerObject::deactivateParticle(a1);
if ( !v5 )
{
v16.b = 0;
*(_WORD *)&v16.r = -14081;
PlayerObject::spawnPortalCircle(a1, v16, 50.0);
}
PlayerObject::activateStreak(a1);
PlayerObject::updatePlayerScale(a1);
a1->m_birdVehicle->setVisible(a1->m_birdVehicle, 1);
}
else
{
PlayerObject::resetPlayerIcon(a1);
}
if ( v4 )
PlayerObject::modeDidChange(a1);
}
}