//
// GJBaseGameLayer::playerWillSwitchMode from 0x491638 to 0x491772 (314 bytes)
//
// 9 xrefs:
// > GJBaseGameLayer::toggleDualMode @ 0x491814
// > GJBaseGameLayer::collisionCheckObjects @ 0x492768
// > GJBaseGameLayer::collisionCheckObjects @ 0x4927b0
// > GJBaseGameLayer::collisionCheckObjects @ 0x4927cc
// > GJBaseGameLayer::collisionCheckObjects @ 0x492812
// > GJBaseGameLayer::collisionCheckObjects @ 0x492858
// > GJBaseGameLayer::collisionCheckObjects @ 0x49287e
// > GJBaseGameLayer::collisionCheckObjects @ 0x492c3e
// > GJBaseGameLayer::collisionCheckObjects @ 0x492c4c
//
// 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 GJBaseGameLayer::playerWillSwitchMode(GJBaseGameLayer *a1, PlayerObject *a2, GameObject *a3)
{
GameObjectClassType m_classType; // r3
GameObjectType v7; // r0
GameObjectType v8; // r0
GJGameEvent v9; // r0
GameObjectType v10; // r0
LevelSettingsObject *m_levelSettings; // r3
_BOOL4 m_twoPlayerMode; // r4
PlayerObject *OtherPlayer; // r6
GameObjectType v14; // r0
int m_isBird; // r0
if ( a3 )
{
m_classType = a3->m_classType;
a1->m_gameState.m_lastActivatedPortal1 = a3;
if ( m_classType == Effect )
GJBaseGameLayer::updateCameraMode(a1, (EffectGameObject *)a3, 0);
v7 = a3->getType(a3);
GJBaseGameLayer::updateDualGround(a1, a2, v7, 0, 0.0);
v8 = a3->getType(a3);
v9 = GJBaseGameLayer::objectTypeToGameEvent(a1, v8);
GJBaseGameLayer::gameEventTriggered(a1, v9, 0, 0);
v10 = a3->getType(a3);
if ( v10 != ShipPortal && v10 != UfoPortal && v10 != WavePortal && v10 != SwingPortal )
a1->toggleGlitter(a1, 0);
if ( a1->m_gameState.m_isDualMode )
{
m_levelSettings = a1->m_levelSettings;
m_twoPlayerMode = m_levelSettings->m_twoPlayerMode;
if ( !m_levelSettings->m_twoPlayerMode )
{
OtherPlayer = GJBaseGameLayer::getOtherPlayer(a1, a2);
v14 = a3->getType(a3);
if ( v14 == UfoPortal )
{
m_isBird = OtherPlayer->m_isBird;
goto LABEL_17;
}
if ( (unsigned int)v14 <= UfoPortal )
{
switch ( v14 )
{
case CubePortal:
m_isBird = PlayerObject::isFlying(OtherPlayer);
if ( m_isBird )
{
m_isBird = m_twoPlayerMode;
}
else if ( !OtherPlayer->m_isBall )
{
if ( OtherPlayer->m_isRobot )
m_isBird = OtherPlayer->m_isBall;
else
m_isBird = !OtherPlayer->m_isSpider;
}
goto LABEL_17;
case BallPortal:
m_isBird = OtherPlayer->m_isBall;
goto LABEL_17;
case ShipPortal:
m_isBird = OtherPlayer->m_isShip;
goto LABEL_17;
}
goto LABEL_28;
}
switch ( v14 )
{
case SpiderPortal:
m_isBird = OtherPlayer->m_isSpider;
break;
case SwingPortal:
m_isBird = OtherPlayer->m_isSwing;
break;
case RobotPortal:
m_isBird = OtherPlayer->m_isRobot;
break;
default:
LABEL_28:
m_isBird = 0;
break;
}
LABEL_17:
if ( !a1->m_gameState.m_unkBool31 )
{
if ( m_isBird )
PlayerObject::flipGravity(a2, !OtherPlayer->m_isUpsideDown, 1);
}
}
}
}
}