//
// PlayerObject::hitGround from 0x100223730 to 0x100223d20 (1520 bytes)
//
// 13 xrefs:
// > GJBaseGameLayer::checkCollisions @ 0x1001e754c
// > GJBaseGameLayer::checkCollisions @ 0x1001e76a8
// > GJBaseGameLayer::checkCollisions @ 0x1001e7758
// > GJBaseGameLayer::checkCollisions @ 0x1001e788c
// > PlayerObject::collidedWithSlopeInternal @ 0x100221320
// > PlayerObject::collidedWithObjectInternal @ 0x10022216c
// > PlayerObject::collidedWithObjectInternal @ 0x100222370
// > PlayerObject::collidedWithObjectInternal @ 0x100222c2c
// > PlayerObject::collidedWithObjectInternal @ 0x100222dac
// > PlayerObject::collidedWithObjectInternal @ 0x100222e94
// > PlayerObject::collidedWithObjectInternal @ 0x100222f88
// > PlayerObject::collidedWithObjectInternal @ 0x1002230a8
// > MenuGameLayer::update @ 0x10039b4f4
//
// 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; // w2
double m_yVelocity; // d0
_BOOL4 m_isUpsideDown; // w8
double v9; // d9
GJBaseGameLayer *m_gameLayer; // x0
int m_uniqueID; // w3
GJGameEvent v12; // w1
float v13; // s0
float m_fallStartY; // s1
float v15; // s0
GJBaseGameLayer *v16; // x0
int m_groundObjectMaterial; // w2
int v18; // w3
GJGameEvent v19; // w1
GameManager *v20; // x0
__int64 v21; // x9
cocos2d::CCParticleSystem *v22; // x22
__n128 v23; // q0
__n128 v24; // q0
__n128 v25; // q1
__n128 v26; // q1
__n128 v27; // q0
float v28; // s8
double v29; // d1
float v30; // s0
float32x2_t *v31; // x0
double v32; // d0
GJRobotSprite *m_robotSprite; // x21
bool m_isBall; // w8
unsigned __int64 v35; // t2
double *v36; // x0
void *__p[2]; // [xsp+0h] [xbp-60h] BYREF
char *longStorage; // [xsp+10h] [xbp-50h]
float32x2_t v39; // [xsp+20h] [xbp-40h] BYREF
int32x2_t v40; // [xsp+28h] [xbp-38h] BYREF
if ( a2 )
m_objectMaterial = a2->m_objectMaterial;
else
m_objectMaterial = 0;
a1->m_groundObjectMaterial = m_objectMaterial;
a1->m_isOnIce = 0;
m_yVelocity = a1->m_yVelocity;
m_isUpsideDown = a1->m_isUpsideDown;
if ( a1->m_isUpsideDown )
v9 = -m_yVelocity;
else
v9 = a1->m_yVelocity;
m_gameLayer = a1->m_gameLayer;
if ( !m_gameLayer || a1->m_isDart )
goto LABEL_41;
if ( m_isUpsideDown )
{
if ( m_yVelocity <= 14.0 )
{
if ( m_yVelocity <= 8.0 )
{
if ( m_yVelocity <= 4.0 )
{
if ( m_yVelocity <= 1.0 )
goto LABEL_22;
goto LABEL_34;
}
goto LABEL_20;
}
goto LABEL_18;
}
LABEL_16:
m_uniqueID = a1->m_uniqueID;
v12 = HardLanding;
LABEL_21:
GJBaseGameLayer::gameEventTriggered(m_gameLayer, v12, m_objectMaterial, m_uniqueID);
goto LABEL_22;
}
if ( m_yVelocity < -14.0 )
goto LABEL_16;
if ( m_yVelocity < -8.0 )
{
LABEL_18:
m_uniqueID = a1->m_uniqueID;
v12 = NormalLanding;
goto LABEL_21;
}
if ( m_yVelocity < -4.0 )
{
LABEL_20:
m_uniqueID = a1->m_uniqueID;
v12 = SoftLanding;
goto LABEL_21;
}
if ( m_yVelocity < -1.0 )
{
LABEL_34:
m_uniqueID = a1->m_uniqueID;
if ( a1->m_isOnGround2 )
v12 = TinyLanding;
else
v12 = FeatherLanding;
goto LABEL_21;
}
LABEL_22:
if ( a1->m_fallStartY == 0.0 )
goto LABEL_41;
v13 = *(float *)(((__int64 (__fastcall *)(PlayerObject *))a1->getPosition)(a1) + 4);
m_fallStartY = a1->m_fallStartY;
if ( (float)(m_fallStartY - v13) != 0.0 )
{
v15 = vabds_f32(m_fallStartY, v13);
if ( v15 <= 450.0 )
{
if ( v15 <= 300.0 )
{
if ( v15 <= 150.0 )
{
if ( v15 <= 7.5 )
goto LABEL_40;
v16 = a1->m_gameLayer;
if ( !v16 )
goto LABEL_40;
m_groundObjectMaterial = a1->m_groundObjectMaterial;
v18 = a1->m_uniqueID;
v19 = FallLow;
goto LABEL_39;
}
v16 = a1->m_gameLayer;
if ( v16 )
{
m_groundObjectMaterial = a1->m_groundObjectMaterial;
v18 = a1->m_uniqueID;
v19 = FallMed;
goto LABEL_39;
}
}
else
{
v16 = a1->m_gameLayer;
if ( v16 )
{
m_groundObjectMaterial = a1->m_groundObjectMaterial;
v18 = a1->m_uniqueID;
v19 = FallHigh;
goto LABEL_39;
}
}
}
else
{
v16 = a1->m_gameLayer;
if ( v16 )
{
m_groundObjectMaterial = a1->m_groundObjectMaterial;
v18 = a1->m_uniqueID;
v19 = FallVHigh;
LABEL_39:
GJBaseGameLayer::gameEventTriggered(v16, v19, m_groundObjectMaterial, v18);
}
}
}
LABEL_40:
a1->m_fallStartY = 0.0;
LABEL_41:
a1->m_yVelocity = 0.0;
a1->m_isSliding = 0;
if ( !a1->m_isOnGround2 && !a3 )
{
if ( !a1->m_playEffects || (v20 = GameManager::sharedState(), !GJBaseGameLayer::isFlipping(v20->m_playLayer)) )
{
if ( !a1->m_isHidden )
{
v21 = 2248;
if ( a1->m_useLandParticles0 )
v21 = 2240;
v22 = *(cocos2d::CCParticleSystem **)((char *)&a1->GameObject::CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable
+ v21);
a1->m_useLandParticles0 ^= 1u;
if ( ((unsigned int (__fastcall *)(cocos2d::CCParticleSystem *))v22->getParticleCount)(v22) <= 2 )
{
v23.n128_u32[0] = LODWORD(a1->m_landParticlesAngle);
if ( a1->m_isUpsideDown )
v23.n128_f32[0] = -v23.n128_f32[0];
((void (__fastcall *)(cocos2d::CCParticleSystem *, __n128))v22->setAngle)(v22, v23);
v24.n128_u32[0] = *(_DWORD *)((__int64 (__fastcall *)(cocos2d::CCParticleSystemQuad *))a1->m_landParticles0->getGravity)(a1->m_landParticles0);
v25.n128_u32[0] = LODWORD(a1->m_landParticleRelatedY);
if ( a1->m_isUpsideDown )
v25.n128_f32[0] = -v25.n128_f32[0];
sub_100022980(v24, v25, &v40);
((void (__fastcall *)(cocos2d::CCParticleSystem *, int32x2_t *))v22->setGravity)(v22, &v40);
v27.n128_u32[0] = -15.0;
if ( a1->m_isUpsideDown )
v27.n128_f32[0] = 15.0;
v26.n128_f32[0] = a1->m_vehicleSize * v27.n128_f32[0];
v28 = 0.0;
v27.n128_u32[0] = 0;
sub_100022980(v27, v26, &v40);
if ( a1->m_isSideways )
{
v40 = vrev64_s32(v40);
v28 = 90.0;
}
((void (__fastcall *)(cocos2d::CCParticleSystem *, float))v22->setRotation)(v22, v28);
if ( a2 && ((unsigned int (__fastcall *)(GameObject *))a2->getType)(a2) == 25 )
{
v29 = 90.0;
if ( !a1->m_isSideways )
v29 = 0.0;
v30 = v29 + a1->m_slopeRotation * 57.2957802;
((void (__fastcall *)(cocos2d::CCParticleSystem *, float))v22->setRotation)(v22, v30);
}
v31 = (float32x2_t *)((__int64 (__fastcall *)(PlayerObject *))a1->getPosition)(a1);
*(float32x2_t *)&v32 = sub_1000229DC(v31, (float32x2_t *)&v40, &v39);
((void (__fastcall *)(cocos2d::CCParticleSystem *, float32x2_t *, double))v22->setPosition)(v22, &v39, v32);
cocos2d::CCParticleSystem::resetSystem(v22);
}
}
}
}
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;
if ( a1->m_currentRobotAnimation.m_data.m_short.shortStorage.__elems_[22] < 0 )
{
sub_1000097D0(
__p,
(void *)a1->m_currentRobotAnimation.m_data.m_long.capacitym1,
a1->m_currentRobotAnimation.m_data.m_long.size);
}
else
{
*(_OWORD *)__p = *(_OWORD *)&a1->m_currentRobotAnimation.m_data.m_short.sizex2;
longStorage = a1->m_currentRobotAnimation.m_data.m_long.longStorage;
}
CCAnimatedSprite::runAnimation(m_robotSprite, __p);
if ( SHIBYTE(longStorage) < 0 )
operator delete(__p[0]);
}
else if ( a1->m_isSpider )
{
PlayerObject::playDynamicSpiderRun(a1);
}
}
a1->m_isOnGround2 = 1;
a1->m_unkA29 = !a3;
if ( v9 <= 5.0 )
{
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;
}
else if ( a1->m_isRotating )
{
goto LABEL_88;
}
PlayerObject::runRotateAction(a1, 0, m_objectMaterial);
m_isBall = a1->m_isBall;
LABEL_88:
if ( m_isBall )
goto LABEL_97;
goto LABEL_89;
}
if ( !a1->m_isRotating && !a1->m_wasOnSlope )
goto LABEL_88;
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
LABEL_89:
if ( !a1->m_isShip && !a1->m_isBird && !a1->m_isDart && !a1->m_isSwing && !a1->m_isOnSlope && !a1->m_wasOnSlope )
{
HIDWORD(v35) = -1527099483 * (int)((float (__fastcall *)(PlayerObject *))a1->getRotation)(a1) + 47721858;
LODWORD(v35) = HIDWORD(v35);
if ( (unsigned int)(v35 >> 1) >= 0x2D82D83 )
{
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
}
}
LABEL_97:
v36 = (double *)((__int64 (__fastcall *)(PlayerObject *))a1->getPosition)(a1);
sub_1000229D0(&a1->m_lastGroundedPos, v36);
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;
}