//
// PlayerObject::hitGround from 0x10040bbc0 to 0x10040c2de (1822 bytes)
//
// 16 xrefs:
// > GJBaseGameLayer::checkCollisions @ 0x100125a5d
// > GJBaseGameLayer::checkCollisions @ 0x100125ac0
// > GJBaseGameLayer::checkCollisions @ 0x100125ec0
// > GJBaseGameLayer::checkCollisions @ 0x100126094
// > PlayerObject::collidedWithSlopeInternal @ 0x100408139
// > PlayerObject::collidedWithObjectInternal @ 0x100409bce
// > PlayerObject::collidedWithObjectInternal @ 0x100409cdf
// > PlayerObject::collidedWithObjectInternal @ 0x100409eeb
// > PlayerObject::collidedWithObjectInternal @ 0x100409f22
// > PlayerObject::collidedWithObjectInternal @ 0x10040a134
// > PlayerObject::collidedWithObjectInternal @ 0x10040a16b
// > PlayerObject::collidedWithObjectInternal @ 0x10040a43b
// > PlayerObject::collidedWithObjectInternal @ 0x10040a5ef
// > PlayerObject::collidedWithObjectInternal @ 0x10040b22b
// > PlayerObject::hitGroundNoJump @ 0x10040d1fc
// > MenuGameLayer::update @ 0x1004fadb2
//
// 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::hitGround(PlayerObject *a1, GameObject *a2, bool a3)
{
int m_objectMaterial; // edx
__m128d v7; // xmm0
bool m_isUpsideDown; // al
GJBaseGameLayer *m_gameLayer; // rdi
int m_uniqueID; // ecx
GJGameEvent v11; // esi
__int64 v12; // rax
GJBaseGameLayer *v13; // rdi
int m_groundObjectMaterial; // edx
int v15; // ecx
GJGameEvent v16; // esi
GameManager *v17; // rax
cocos2d::CCParticleSystem *v18; // r12
double v19; // xmm0_8
float v20; // xmm0_4
float m_landParticleRelatedY; // xmm1_4
float v22; // xmm1_4
double v23; // xmm1_8
unsigned __int64 *v24; // rax
GameManager *v25; // rax
HardStreak *m_waveTrail; // r15
double *v27; // rax
bool v28; // cc
bool m_isBall; // al
GJRobotSprite *m_robotSprite; // r15
double *v31; // rax
double v32; // [rsp+8h] [rbp-68h] BYREF
__m128d v33; // [rsp+10h] [rbp-60h]
__m128d v34; // [rsp+20h] [rbp-50h] BYREF
void *__p; // [rsp+30h] [rbp-40h]
unsigned __int64 v36[6]; // [rsp+40h] [rbp-30h] BYREF
if ( a2 )
m_objectMaterial = a2->m_objectMaterial;
else
m_objectMaterial = 0;
a1->m_groundObjectMaterial = m_objectMaterial;
a1->m_isOnIce = 0;
v7 = (__m128d)*(unsigned __int64 *)&a1->m_yVelocity;
m_isUpsideDown = a1->m_isUpsideDown;
if ( m_isUpsideDown )
{
v33 = _mm_xor_pd((__m128d)xmmword_100816590, v7);
m_gameLayer = a1->m_gameLayer;
if ( !m_gameLayer )
goto LABEL_41;
LABEL_8:
if ( a1->m_isDart )
goto LABEL_41;
if ( m_isUpsideDown )
{
if ( v7.f64[0] <= 14.0 )
{
if ( v7.f64[0] <= 8.0 )
{
if ( v7.f64[0] <= 4.0 )
{
if ( v7.f64[0] <= 1.0 )
goto LABEL_22;
LABEL_34:
m_uniqueID = a1->m_uniqueID;
if ( a1->m_isOnGround2 )
v11 = TinyLanding;
else
v11 = FeatherLanding;
goto LABEL_21;
}
LABEL_20:
m_uniqueID = a1->m_uniqueID;
v11 = SoftLanding;
goto LABEL_21;
}
LABEL_18:
m_uniqueID = a1->m_uniqueID;
v11 = NormalLanding;
goto LABEL_21;
}
}
else if ( v7.f64[0] >= -14.0 )
{
if ( v7.f64[0] >= -8.0 )
{
if ( v7.f64[0] >= -4.0 )
{
if ( v7.f64[0] >= -1.0 )
{
LABEL_22:
*(_QWORD *)&v7.f64[0] = LODWORD(a1->m_fallStartY);
if ( *(float *)v7.f64 == 0.0 )
goto LABEL_41;
v12 = ((__int64 (__fastcall *)(PlayerObject *))a1->getPosition)(a1);
*(_QWORD *)&v7.f64[0] = LODWORD(a1->m_fallStartY);
*(float *)v7.f64 = *(float *)v7.f64 - *(float *)(v12 + 4);
if ( *(float *)v7.f64 == 0.0 )
goto LABEL_40;
*(_QWORD *)&v7.f64[0] &= 0x7FFFFFFF7FFFFFFFuLL;
if ( *(float *)v7.f64 <= 450.0 )
{
if ( *(float *)v7.f64 <= 300.0 )
{
if ( *(float *)v7.f64 <= 150.0 )
{
if ( *(float *)v7.f64 <= 7.5 )
goto LABEL_40;
v13 = a1->m_gameLayer;
if ( !v13 )
goto LABEL_40;
m_groundObjectMaterial = a1->m_groundObjectMaterial;
v15 = a1->m_uniqueID;
v16 = FallLow;
goto LABEL_39;
}
v13 = a1->m_gameLayer;
if ( v13 )
{
m_groundObjectMaterial = a1->m_groundObjectMaterial;
v15 = a1->m_uniqueID;
v16 = FallMed;
goto LABEL_39;
}
}
else
{
v13 = a1->m_gameLayer;
if ( v13 )
{
m_groundObjectMaterial = a1->m_groundObjectMaterial;
v15 = a1->m_uniqueID;
v16 = FallHigh;
goto LABEL_39;
}
}
}
else
{
v13 = a1->m_gameLayer;
if ( v13 )
{
m_groundObjectMaterial = a1->m_groundObjectMaterial;
v15 = a1->m_uniqueID;
v16 = FallVHigh;
LABEL_39:
GJBaseGameLayer::gameEventTriggered(v13, v16, m_groundObjectMaterial, v15);
}
}
LABEL_40:
a1->m_fallStartY = 0.0;
goto LABEL_41;
}
goto LABEL_34;
}
goto LABEL_20;
}
goto LABEL_18;
}
m_uniqueID = a1->m_uniqueID;
v11 = HardLanding;
LABEL_21:
GJBaseGameLayer::gameEventTriggered(m_gameLayer, v11, m_objectMaterial, m_uniqueID);
goto LABEL_22;
}
v33 = (__m128d)*(unsigned __int64 *)&a1->m_yVelocity;
m_gameLayer = a1->m_gameLayer;
if ( m_gameLayer )
goto LABEL_8;
LABEL_41:
a1->m_yVelocity = 0.0;
a1->m_isSliding = 0;
if ( !a3 && !a1->m_isOnGround2 )
{
if ( !a1->m_playEffects || (v17 = GameManager::sharedState(), !GJBaseGameLayer::isFlipping(v17->m_playLayer)) )
{
if ( !a1->m_isHidden )
{
v18 = *((cocos2d::CCParticleSystem **)&a1->m_landParticles0 + !a1->m_useLandParticles0);
a1->m_useLandParticles0 ^= 1u;
if ( ((unsigned int (__fastcall *)(cocos2d::CCParticleSystem *, double))v18->getParticleCount)(v18, v7.f64[0]) <= 2 )
{
*(_QWORD *)&v19 = LODWORD(a1->m_landParticlesAngle);
if ( a1->m_isUpsideDown )
*(_QWORD *)&v19 ^= 0x8000000080000000LL;
((void (__fastcall *)(cocos2d::CCParticleSystem *, double))v18->setAngle)(v18, v19);
v20 = *(float *)((__int64 (__fastcall *)(cocos2d::CCParticleSystemQuad *))a1->m_landParticles0->getGravity)(a1->m_landParticles0);
m_landParticleRelatedY = a1->m_landParticleRelatedY;
if ( a1->m_isUpsideDown )
m_landParticleRelatedY = -m_landParticleRelatedY;
sub_10028CBE0((float *)v36, v20, m_landParticleRelatedY);
((void (__fastcall *)(cocos2d::CCParticleSystem *, unsigned __int64 *))v18->setGravity)(v18, v36);
if ( a1->m_isUpsideDown )
v22 = 15.0;
else
v22 = -15.0;
sub_10028CBE0((float *)v36, 0.0, v22 * a1->m_vehicleSize);
v7.f64[0] = 0.0;
if ( a1->m_isSideways )
{
_mm_storel_ps((double *)v36, _mm_shuffle_ps((__m128)v36[0], (__m128)v36[0], 225));
*(_QWORD *)&v7.f64[0] = 1119092736;
}
((void (__fastcall *)(cocos2d::CCParticleSystem *, double))v18->setRotation)(v18, v7.f64[0]);
if ( a2 && ((unsigned int (__fastcall *)(GameObject *))a2->getType)(a2) == 25 )
{
if ( a1->m_isSideways )
v23 = 90.0;
else
v23 = 0.0;
v7.f64[0] = a1->m_slopeRotation * 57.29578018188477 + v23;
*(float *)v7.f64 = v7.f64[0];
((void (__fastcall *)(cocos2d::CCParticleSystem *, float))v18->setRotation)(v18, *(float *)v7.f64);
}
v24 = (unsigned __int64 *)((__int64 (__fastcall *)(PlayerObject *))a1->getPosition)(a1);
sub_10028CCE0(&v32, v24, v36);
((void (__fastcall *)(cocos2d::CCParticleSystem *, double *))v18->setPosition)(v18, &v32);
cocos2d::CCParticleSystem::resetSystem(v18);
}
}
}
}
if ( !a1->m_justPlacedStreak )
{
if ( !a1->m_maybeReducedEffects && a1->m_isDart && !a1->m_isLocked && a1->m_fadeOutStreak )
{
if ( !a1->m_playEffects || (v25 = GameManager::sharedState(), !GJBaseGameLayer::isFlipping(v25->m_playLayer)) )
{
m_waveTrail = a1->m_waveTrail;
v27 = (double *)((__int64 (__fastcall *)(PlayerObject *, double))a1->getPosition)(a1, v7.f64[0]);
v7.f64[0] = sub_10028CC60(v36, v27);
HardStreak::addPoint(m_waveTrail, *(cocos2d::CCPoint *)&v7.f64[0]);
}
}
a1->m_justPlacedStreak = 1;
}
if ( !a1->m_isOnGround2 && !a1->m_isDashing )
{
if ( a1->m_isRobot )
{
m_robotSprite = a1->m_robotSprite;
if ( (a1->m_currentRobotAnimation.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(
&v34,
a1->m_currentRobotAnimation.m_data.m_long.longStorage,
a1->m_currentRobotAnimation.m_data.m_long.size,
v7.f64[0]);
}
else
{
__p = a1->m_currentRobotAnimation.m_data.m_long.longStorage;
v7 = *(__m128d *)&a1->m_currentRobotAnimation.m_data.m_short.sizex2;
v34 = v7;
}
CCAnimatedSprite::runAnimation((__int64)m_robotSprite, (__int128 *)&v34, v7.f64[0]);
if ( (LOBYTE(v34.f64[0]) & 1) != 0 )
operator delete(__p);
}
else if ( a1->m_isSpider )
{
PlayerObject::playDynamicSpiderRun(a1);
}
}
v28 = v33.f64[0] <= 5.0;
a1->m_isOnGround2 = 1;
a1->m_unkA29 = !a3;
if ( v28 )
{
a1->m_isOnGround = 1;
a1->m_lastLandTime = a1->m_totalTime;
}
a1->m_isOnGround3 = 1;
a1->m_stateOnGround = 2;
m_isBall = a1->m_isBall;
if ( m_isBall )
{
if ( a1->m_isBallRotating && !a1->m_isOnSlope )
{
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
}
if ( a1->m_isBallRotating2 )
{
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
LABEL_88:
PlayerObject::runRotateAction(a1, 0, m_objectMaterial);
m_isBall = a1->m_isBall;
goto LABEL_89;
}
if ( !a1->m_isRotating )
goto LABEL_88;
}
else if ( a1->m_isRotating || a1->m_wasOnSlope )
{
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
}
LABEL_89:
if ( !m_isBall
&& !a1->m_isShip
&& !a1->m_isBird
&& !a1->m_isDart
&& !a1->m_isSwing
&& !a1->m_isOnSlope
&& !a1->m_wasOnSlope
&& __ROR4__(-1527099483 * (int)((float (__fastcall *)(PlayerObject *))a1->getRotation)(a1) + 47721858, 1) >= 0x2D82D83u )
{
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
}
v31 = (double *)((__int64 (__fastcall *)(PlayerObject *))a1->getPosition)(a1);
sub_10028CC90(&a1->m_lastGroundedPos, v31);
if ( !a1->m_isShip && !a1->m_isBird && !a1->m_isDart && !a1->m_isSwing && a1->m_shouldTryPlacingCheckpoint )
{
PlayerObject::deactivateStreak(a1, 0);
a1->m_canPlaceCheckpoint = 1;
}
a1->m_shouldTryPlacingCheckpoint = 0;
}