//
// PlayerObject::hitGround from 0x62cfd0 to 0x62d650 (1664 bytes)
//
// 13 xrefs:
// > PlayerObject::hitGroundNoJump @ 0x62d694
// > PlayerObject::collidedWithObjectInternal @ 0x62f528
// > PlayerObject::collidedWithObjectInternal @ 0x62f774
// > PlayerObject::collidedWithObjectInternal @ 0x630060
// > PlayerObject::collidedWithObjectInternal @ 0x6301a8
// > PlayerObject::collidedWithObjectInternal @ 0x630318
// > PlayerObject::collidedWithSlopeInternal @ 0x638430
// > MenuGameLayer::update @ 0x6c9ad4
// > GJBaseGameLayer::checkCollisions @ 0x8950cc
// > GJBaseGameLayer::checkCollisions @ 0x895134
// > GJBaseGameLayer::checkCollisions @ 0x895794
// > GJBaseGameLayer::checkCollisions @ 0x895848
// > ??> @ 0x6cee8
//
// 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::hitGround(PlayerObject *a1, GameObject *a2, bool a3)
{
_BOOL4 v5; // w21
int m_objectMaterial; // w0
double m_yVelocity; // d8
double v8; // d8
double m_totalTime; // x1
_BOOL4 m_isBall; // w0
float v11; // s0
float v12; // s1
float v13; // s0
_BOOL4 m_useLandParticles0; // w0
cocos2d::CCParticleSystemQuad *m_landParticles0; // x1
cocos2d::CCParticleSystemQuad *m_landParticles1; // x22
float m_landParticlesAngle; // s9
void (__fastcall *setAngle)(cocos2d::CCParticleSystem *__hidden, float); // x26
int v19; // w0
void (__fastcall *setGravity)(cocos2d::CCParticleSystem *__hidden, const cocos2d::CCPoint *); // x26
const cocos2d::CCPoint *v21; // x0
float m_landParticleRelatedY; // s9
int v23; // w0
int v24; // w0
cocos2d::CCParticleSystemQuad_vtbl *v25; // x1
void (__fastcall *setRotation)(cocos2d::CCParticleSystem *__hidden, float); // x1
float v27; // w3
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x23
const cocos2d::CCPoint *v29; // x0
GJRobotSprite *m_robotSprite; // x23
void *v31; // x0
unsigned int *v32; // x2
int v33; // w1
double v34; // d2
float v35; // s0
int m_groundObjectMaterial; // w2
float x; // [xsp+60h] [xbp+60h]
cocos2d::CCPoint v38; // [xsp+78h] [xbp+78h] BYREF
cocos2d::CCPoint v39; // [xsp+80h] [xbp+80h] BYREF
v5 = a3;
if ( a2 )
m_objectMaterial = a2->m_objectMaterial;
else
m_objectMaterial = 0;
m_yVelocity = a1->m_yVelocity;
a1->m_groundObjectMaterial = m_objectMaterial;
a1->m_isOnIce = 0;
v8 = m_yVelocity * (double)PlayerObject::flipMod(a1);
if ( a1->m_gameLayer && !a1->m_isDart )
{
if ( PlayerObject::playerIsFalling(a1, -14.0) )
{
PlayerObject::gameEventTriggered(a1, 5, a1->m_groundObjectMaterial);
}
else if ( PlayerObject::playerIsFalling(a1, -8.0) )
{
PlayerObject::gameEventTriggered(a1, 4, a1->m_groundObjectMaterial);
}
else if ( PlayerObject::playerIsFalling(a1, -4.0) )
{
PlayerObject::gameEventTriggered(a1, 3, a1->m_groundObjectMaterial);
}
else if ( PlayerObject::playerIsFalling(a1, -1.0) )
{
m_groundObjectMaterial = a1->m_groundObjectMaterial;
if ( a1->m_isOnGround2 )
PlayerObject::gameEventTriggered(a1, 1, m_groundObjectMaterial);
else
PlayerObject::gameEventTriggered(a1, 2, m_groundObjectMaterial);
}
if ( a1->m_fallStartY != 0.0 )
{
v13 = vabds_f32(a1->m_fallStartY, a1->getPosition(a1)->y);
if ( v13 > 0.0 )
{
if ( v13 > 450.0 )
{
PlayerObject::gameEventTriggered(a1, 68, a1->m_groundObjectMaterial);
}
else if ( v13 > 300.0 )
{
PlayerObject::gameEventTriggered(a1, 67, a1->m_groundObjectMaterial);
}
else if ( v13 > 150.0 )
{
PlayerObject::gameEventTriggered(a1, 66, a1->m_groundObjectMaterial);
}
else if ( v13 > 7.5 )
{
PlayerObject::gameEventTriggered(a1, 65, a1->m_groundObjectMaterial);
}
}
a1->m_fallStartY = 0.0;
}
}
PlayerObject::setYVelocity(a1, 0.0, 43);
a1->m_isSliding = 0;
if ( !v5 && !a1->m_isOnGround2 && !PlayerObject::levelFlipping(a1) && !a1->m_isHidden )
{
m_useLandParticles0 = a1->m_useLandParticles0;
m_landParticles0 = a1->m_landParticles0;
m_landParticles1 = a1->m_landParticles1;
a1->m_useLandParticles0 = !m_useLandParticles0;
if ( m_useLandParticles0 )
m_landParticles1 = m_landParticles0;
if ( m_landParticles1->getParticleCount(m_landParticles1) <= 2 )
{
m_landParticlesAngle = a1->m_landParticlesAngle;
setAngle = m_landParticles1->setAngle;
v19 = PlayerObject::flipMod(a1);
setAngle(m_landParticles1, m_landParticlesAngle * (float)v19);
setGravity = m_landParticles1->setGravity;
v21 = a1->m_landParticles0->getGravity(a1->m_landParticles0);
m_landParticleRelatedY = a1->m_landParticleRelatedY;
x = v21->x;
v23 = PlayerObject::flipMod(a1);
cocos2d::CCPoint::CCPoint(&v39, x, m_landParticleRelatedY * (float)v23);
setGravity(m_landParticles1, &v39);
v24 = PlayerObject::flipMod(a1);
cocos2d::CCPoint::CCPoint(&v38, 0.0, (float)(-15 * v24) * a1->m_vehicleSize);
v25 = m_landParticles1->cocos2d::CCParticleSystem::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
if ( a1->m_isSideways )
{
setRotation = v25->setRotation;
v27 = v38.x;
v38.x = v38.y;
v38.y = v27;
setRotation(m_landParticles1, 90.0);
}
else
{
v25->setRotation(m_landParticles1, 0.0);
}
if ( a2 && a2->getType(a2) == Slope )
{
if ( a1->m_isSideways )
v34 = 90.0;
else
v34 = 0.0;
v35 = v34 + a1->m_slopeRotation * 57.2957802;
m_landParticles1->setRotation(m_landParticles1, v35);
}
setPosition = m_landParticles1->setPosition;
v29 = a1->getPosition(a1);
cocos2d::CCPoint::operator+(&v39, v29, &v38);
setPosition(m_landParticles1, &v39);
cocos2d::CCParticleSystem::resetSystem(m_landParticles1);
}
}
if ( !a1->m_justPlacedStreak )
{
PlayerObject::placeStreakPoint(a1);
a1->m_justPlacedStreak = 1;
}
if ( !a1->m_isOnGround2 && !a1->m_isDashing )
{
if ( a1->m_isRobot )
{
m_robotSprite = a1->m_robotSprite;
sub_D18D28(&v39, &a1->m_currentRobotAnimation);
CCAnimatedSprite::runAnimation((__int64)m_robotSprite, (__int64)&v39);
v31 = (void *)(*(_QWORD *)&v39 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v39 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v32 = (unsigned int *)(*(_QWORD *)&v39 - 8LL);
do
v33 = __ldaxr(v32);
while ( __stlxr(v33 - 1, v32) );
}
else
{
v33 = *(_DWORD *)(*(_QWORD *)&v39 - 8LL);
*(_DWORD *)(*(_QWORD *)&v39 - 8LL) = v33 - 1;
}
if ( v33 <= 0 )
operator delete(v31);
}
}
else if ( a1->m_isSpider )
{
PlayerObject::playDynamicSpiderRun(a1);
}
}
a1->m_isOnGround2 = 1;
a1->m_unkA29 = !v5;
if ( v8 <= 5.0 )
{
m_totalTime = a1->m_totalTime;
a1->m_isOnGround = 1;
a1->m_lastLandTime = m_totalTime;
}
m_isBall = a1->m_isBall;
a1->m_isOnGround3 = 1;
a1->m_stateOnGround = 2;
if ( !m_isBall )
{
if ( !a1->m_isRotating && !a1->m_wasOnSlope )
goto LABEL_25;
PlayerObject::stopRotation(a1, 1, 17);
if ( !a1->m_isBall )
goto LABEL_25;
}
if ( a1->m_isBallRotating && !a1->m_isOnSlope )
{
PlayerObject::stopRotation(a1, 1, 16);
if ( !a1->m_isBall )
goto LABEL_25;
}
if ( !a1->m_isBallRotating2 )
{
if ( a1->m_isRotating )
goto LABEL_18;
goto LABEL_56;
}
PlayerObject::stopRotation(a1, 0, 18);
if ( a1->m_isBall )
{
if ( a1->m_isRotating )
goto LABEL_18;
LABEL_56:
PlayerObject::runRotateAction(a1, 0, 6);
if ( a1->m_isBall )
goto LABEL_18;
}
LABEL_25:
if ( !PlayerObject::isFlying(a1) && !a1->m_isOnSlope && !a1->m_wasOnSlope && (int)a1->getRotation(a1) % 90 )
PlayerObject::stopRotation(a1, 1, 19);
LABEL_18:
v11 = ((float (__fastcall *)(PlayerObject *))a1->getPosition)(a1);
cocos2d::CCPoint::operator=(&a1->m_lastGroundedPos, v11, v12);
if ( !PlayerObject::isFlying(a1) && a1->m_shouldTryPlacingCheckpoint )
{
PlayerObject::deactivateStreak(a1, 0);
a1->m_canPlaceCheckpoint = 1;
}
a1->m_shouldTryPlacingCheckpoint = 0;
}