//
// PlayerObject::updateCollide from 0x10040c300 to 0x10040c647 (839 bytes)
//
// 4 xrefs:
// > GJBaseGameLayer::checkCollisions @ 0x100125a69
// > GJBaseGameLayer::checkCollisions @ 0x100125acf
// > GJBaseGameLayer::checkCollisions @ 0x100125ee7
// > GJBaseGameLayer::checkCollisions @ 0x1001260be
//
// 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::updateCollide(PlayerObject *a1, PlayerCollisionDirection a2, GameObject *a3)
{
float v5; // xmm0_4
__int64 v6; // rax
bool m_isUpsideDown; // cl
float v8; // xmm0_4
float v9; // xmm0_4
int v10; // eax
float v11; // xmm1_4
int v12; // eax
float v13; // xmm0_4
bool v14; // cl
float v15; // xmm1_4
float v16; // xmm2_4
int m_uniqueID; // eax
float v18; // xmm0_4
__m128d v19; // xmm1
double v20; // xmm3_8
cocos2d::CCDictionary *m_collisionLogLeft; // rdi
__m128d v22; // xmm0
double v23; // xmm3_8
cocos2d::CCDictionary *m_collisionLogRight; // rdi
double m_collidedTopMinY; // xmm1_8
double v26; // xmm0_8
cocos2d::CCDictionary *m_collisionLogTop; // rdi
double m_collidedBottomMaxY; // xmm1_8
double v29; // xmm0_8
float v30; // [rsp+0h] [rbp-1Ch]
v30 = *(float *)(((__int64 (__fastcall *)(PlayerObject *))a1->getObjectRect)(a1) + 12) * 0.5;
v5 = 0.5 * *(float *)(((__int64 (__fastcall *)(PlayerObject *))a1->getObjectRect)(a1) + 8);
switch ( a2 )
{
case 0:
v6 = ((__int64 (__fastcall *)(PlayerObject *, float))a1->getPosition)(a1, v5);
m_isUpsideDown = a1->m_isUpsideDown;
if ( m_isUpsideDown )
v8 = -1.0;
else
v8 = 1.0;
v16 = (float)(v30 * v8) + *(float *)(v6 + 4);
if ( a3 )
m_uniqueID = a3->m_uniqueID;
else
m_uniqueID = 0;
m_collidedTopMinY = a1->m_collidedTopMinY;
v26 = v16;
if ( m_collidedTopMinY == 0.0 )
goto LABEL_32;
if ( m_isUpsideDown )
{
v26 = fmax(v26, m_collidedTopMinY);
LABEL_32:
a1->m_collidedTopMinY = v26;
if ( !m_uniqueID )
return;
}
else
{
a1->m_collidedTopMinY = fmin(v26, m_collidedTopMinY);
if ( !m_uniqueID )
return;
}
if ( a1->m_lastCollisionTop != m_uniqueID )
{
a1->m_lastCollisionTop = m_uniqueID;
m_collisionLogTop = a1->m_collisionLogTop;
if ( m_collisionLogTop )
goto LABEL_43;
}
break;
case 1:
v13 = *(float *)(((__int64 (__fastcall *)(PlayerObject *, float))a1->getPosition)(a1, v5) + 4);
v14 = a1->m_isUpsideDown;
if ( v14 )
v15 = -1.0;
else
v15 = 1.0;
v18 = v13 - (float)(v30 * v15);
if ( a3 )
m_uniqueID = a3->m_uniqueID;
else
m_uniqueID = 0;
m_collidedBottomMaxY = a1->m_collidedBottomMaxY;
v29 = v18;
if ( m_collidedBottomMaxY == 0.0 )
goto LABEL_40;
if ( v14 )
{
v29 = fmin(v29, m_collidedBottomMaxY);
LABEL_40:
a1->m_collidedBottomMaxY = v29;
if ( !m_uniqueID )
return;
}
else
{
a1->m_collidedBottomMaxY = fmax(v29, m_collidedBottomMaxY);
if ( !m_uniqueID )
return;
}
if ( a1->m_lastCollisionBottom != m_uniqueID )
{
a1->m_lastCollisionBottom = m_uniqueID;
m_collisionLogTop = a1->m_collisionLogBottom;
if ( m_collisionLogTop )
LABEL_43:
cocos2d::CCDictionary::setObject(m_collisionLogTop, a1->m_maybeLastGroundObject, m_uniqueID);
}
break;
case 2:
v9 = *(float *)((__int64 (__fastcall *)(PlayerObject *))a1->getPosition)(a1) - v5;
if ( a3 )
v10 = a3->m_uniqueID;
else
v10 = 0;
v19.f64[0] = a1->m_collidedLeftMaxX;
v20 = _mm_cmpeq_sd((__m128d)0LL, v19).f64[0];
*(_QWORD *)&a1->m_collidedLeftMaxX = *(_QWORD *)&v20 & COERCE_UNSIGNED_INT64(v9)
| ~*(_QWORD *)&v20 & COERCE_UNSIGNED_INT64(fmax(v9, v19.f64[0]));
if ( v10 )
{
if ( a1->m_lastCollisionLeft != v10 )
{
a1->m_lastCollisionLeft = v10;
m_collisionLogLeft = a1->m_collisionLogLeft;
if ( m_collisionLogLeft )
cocos2d::CCDictionary::setObject(m_collisionLogLeft, a1->m_maybeLastGroundObject, v10);
}
a1->m_collidingWithLeft = a3;
a1->m_collidingWithRight = nullptr;
}
return;
case 3:
v11 = v5 + *(float *)((__int64 (__fastcall *)(PlayerObject *))a1->getPosition)(a1);
if ( a3 )
v12 = a3->m_uniqueID;
else
v12 = 0;
v22.f64[0] = a1->m_collidedRightMinX;
v23 = _mm_cmpeq_sd((__m128d)0LL, v22).f64[0];
*(_QWORD *)&a1->m_collidedRightMinX = *(_QWORD *)&v23 & COERCE_UNSIGNED_INT64(v11)
| ~*(_QWORD *)&v23 & COERCE_UNSIGNED_INT64(fmin(v11, v22.f64[0]));
if ( v12 )
{
if ( a1->m_lastCollisionRight != v12 )
{
a1->m_lastCollisionRight = v12;
m_collisionLogRight = a1->m_collisionLogRight;
if ( m_collisionLogRight )
cocos2d::CCDictionary::setObject(m_collisionLogRight, a1->m_maybeLastGroundObject, v12);
}
a1->m_collidingWithRight = a3;
a1->m_collidingWithLeft = nullptr;
}
return;
default:
return;
}
}