//
// PlayerObject::flipGravity from 0x14039a1d0 to 0x14039a42f (607 bytes)
//
// 24 xrefs:
// > GJBaseGameLayer::teleportPlayer @ 0x140210099
// > GJBaseGameLayer::setupLevelStart @ 0x14021224c
// > GJBaseGameLayer::setupLevelStart @ 0x1402122eb
// > GJBaseGameLayer::flipGravity @ 0x140212b3a
// > GJBaseGameLayer::flipGravity @ 0x140212bf8
// > GJBaseGameLayer::playerWillSwitchMode @ 0x140213117
// > GJBaseGameLayer::toggleDualMode @ 0x140216a1d
// > GJBaseGameLayer::toggleDualMode @ 0x140216a34
// > GJBaseGameLayer::checkRepellPlayer @ 0x140239a25
// > MenuGameLayer::resetPlayer @ 0x140332981
// > PlayerObject::updateJump @ 0x14038be79
// > PlayerObject::updateJump @ 0x14038c926
// > PlayerObject::didHitHead @ 0x140393c4f
// > PlayerObject::spiderTestJumpInternal @ 0x140395030
// > PlayerObject::resetObject @ 0x140397351
// > PlayerObject::ringJump @ 0x140399035
// > PlayerObject::ringJump @ 0x1403991aa
// > PlayerObject::ringJump @ 0x1403994ea
// > PlayerObject::ringJump @ 0x140399748
// > PlayerObject::rotateGameplay @ 0x140399de4
// > PlayerObject::bumpPlayer @ 0x14039f728
// > PlayerObject::copyAttributes @ 0x1403a053a
// > PlayerObject::loadFromCheckpoint @ 0x1403a2a3e
// > ??> @ 0x1406d656c
//
// 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
//
// Hidden C++ exception states: #wind=3
void PlayerObject::flipGravity(PlayerObject *a1, bool a2, bool a3)
{
GJBaseGameLayer *m_gameLayer; // rcx
GJGameEvent v7; // edx
__int64 v8; // rax
__int64 v9; // rcx
void *v10; // [rsp+30h] [rbp+8h] BYREF
__int16 v11; // [rsp+38h] [rbp+10h]
if ( a1->m_isUpsideDown != a2 )
{
PlayerObject::placeStreakPoint(a1);
a1->m_isUpsideDown = a2;
m_gameLayer = a1->m_gameLayer;
if ( m_gameLayer )
{
v7 = GravityInverted;
if ( !a2 )
v7 = GravityRestored;
GJBaseGameLayer::gameEventTriggered(m_gameLayer, v7, 0, a1->m_uniqueID);
}
a1->m_lastFlipTime = a1->m_totalTime;
a1->m_collidedBottomMaxY = 0.0;
a1->m_collidedTopMinY = 0.0;
a1->m_unkA29 = 0;
if ( a1->m_wasOnSlope || a1->m_isOnSlope )
a1->m_slopeFlipGravityRelated = !a1->m_slopeFlipGravityRelated;
cocos2d::CCDictionary::removeAllObjects(a1->m_collisionLogTop);
cocos2d::CCDictionary::removeAllObjects(a1->m_collisionLogBottom);
cocos2d::CCDictionary::removeAllObjects(a1->m_collisionLogLeft);
cocos2d::CCDictionary::removeAllObjects(a1->m_collisionLogRight);
*(_QWORD *)&a1->m_unk50C = -1;
*(_QWORD *)&a1->m_lastCollisionBottom = -1;
*(_QWORD *)&a1->m_lastCollisionLeft = -1;
if ( !a1->m_maybeReducedEffects )
{
a1->m_yVelocity = a1->m_yVelocity * 0.5;
if ( !a3 )
{
if ( a2 )
{
v11 = -14081;
BYTE2(v10) = 0;
}
else
{
v11 = -27136;
BYTE2(v10) = -1;
}
LOWORD(v10) = v11;
PlayerObject::spawnPortalCircle(a1, (cocos2d::ccColor3B *)&v10, 45.0);
}
}
PlayerObject::updatePlayerScale(a1);
PlayerObject::updatePlayerArt(a1);
if ( !a1->m_isBall )
{
v8 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v10 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v10);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v8 = qword_1406C2ED8;
}
v9 = *(_QWORD *)(v8 + 520);
if ( v9 && !*(_BYTE *)(v9 + 12849) && !a1->m_isDart && !a1->m_maybeReducedEffects )
{
a1->m_shouldTryPlacingCheckpoint = 1;
PlayerObject::activateStreak(a1);
}
}
cocos2d::CCPoint::operator=(&a1->m_lastGroundedPos, &a1->m_lastPortalPos);
a1->m_isOnGround = 0;
if ( a1->m_isBall )
{
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
PlayerObject::runBallRotation2(a1);
}
else if ( a1->m_isSwing )
{
PlayerObject::updateSwingFire(a1);
}
}
}