//
// LevelEditorLayer::objectAtPosition from 0x1403f11f0 to 0x1403f159e (942 bytes)
//
// 5 xrefs:
// > EditorUI::clickOnPosition @ 0x1401adac6
// > EditorUI::clickOnPosition @ 0x1401adb17
// > ??> @ 0x1408c5a10
// > ??> @ 0x1408c5a34
// > ??> @ 0x140925358
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:31:47 +0000
//
__int64 __fastcall LevelEditorLayer::objectAtPosition(__int64 a1, float *a2)
{
__int64 v4; // rax
__int64 v5; // rbx
__int64 v6; // rax
float v7; // xmm6_4
__int64 v8; // r8
__int64 v9; // r9
float v10; // xmm1_4
float v11; // xmm0_4
float v12; // xmm0_4
float v13; // xmm3_4
float v14; // xmm1_4
float v15; // xmm1_4
__int64 v16; // r8
__int64 v17; // r9
int v18; // edx
int v19; // r10d
int v20; // ecx
int v21; // eax
__int64 v22; // r8
__int64 v23; // r13
_QWORD *v24; // rdx
__int64 v25; // r14
_QWORD *v26; // r15
__int64 v27; // rbx
__int64 v28; // rbp
__int64 v29; // rsi
int v30; // eax
int v31; // ecx
int v32; // r8d
bool v33; // dl
int v34; // r9d
int v35; // r8d
__int64 v36; // r10
int v37; // eax
int v38; // eax
__int64 v39; // r8
float *v40; // r9
_BYTE v42[16]; // [rsp+30h] [rbp-68h] BYREF
int v43; // [rsp+A0h] [rbp+8h] BYREF
__int64 v44; // [rsp+A8h] [rbp+10h] BYREF
__int64 v45; // [rsp+B0h] [rbp+18h]
__int64 v46; // [rsp+B8h] [rbp+20h]
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v42, *a2, a2[1], 1.0, 1.0);
v5 = v4;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v44, *(float *)(v4 + 8) * 0.5, *(float *)(v4 + 12) * 0.5);
cocos2d::CCPoint::operator+(v5, &v43, v6);
v7 = 0.0;
OBB2D::calculateWithCenter(*(_QWORD *)(a1 + 2312), (__int64)&v43, v8, v9, 0.0);
v10 = *a2;
if ( *a2 > 0.0 )
{
v12 = *(float *)(a1 + 14240);
if ( v10 < 10000000.0 )
v11 = v12 * v10;
else
v11 = v12 * 10000000.0;
}
else
{
v11 = 0.0;
}
v13 = a2[1];
if ( v13 > 0.0 )
{
v14 = *(float *)(a1 + 14244);
if ( v13 < 10000000.0 )
v15 = v14 * v13;
else
v15 = v14 * 10000000.0;
v7 = v15;
}
v16 = *(_QWORD *)(a1 + 13984);
v17 = *(_QWORD *)(a1 + 13976);
v18 = (int)v11 + 1;
if ( v18 >= (unsigned __int64)(((v16 - v17) >> 3) - 1) )
v18 = ((v16 - v17) >> 3) - 1;
v19 = 0;
if ( (int)v7 - 1 >= 0 )
v19 = (int)v7 - 1;
v20 = (int)v7 + 1;
v43 = v20;
if ( v17 == v16 )
return 0;
v21 = 0;
if ( (int)v11 - 1 >= 0 )
v21 = (int)v11 - 1;
if ( v21 > v18 )
return 0;
v22 = v19;
v23 = v21;
v46 = v18;
v45 = v19;
while ( 1 )
{
v24 = *(_QWORD **)(*(_QWORD *)(a1 + 13976) + 8 * v23);
if ( v24 )
{
if ( v20 >= (unsigned __int64)(((__int64)(v24[1] - *v24) >> 3) - 1) )
v20 = ((__int64)(v24[1] - *v24) >> 3) - 1;
}
else
{
v20 = -1;
}
v25 = v22;
v44 = v20;
if ( v22 <= v20 )
break;
LABEL_55:
if ( ++v23 > v46 )
return 0;
v20 = v43;
}
while ( 1 )
{
v26 = *(_QWORD **)(**(_QWORD **)(*(_QWORD *)(a1 + 13976) + 8 * v23) + 8 * v25);
if ( v26 )
{
v27 = 0;
v28 = *(int *)(**(_QWORD **)(*(_QWORD *)(a1 + 14144) + 8 * v23) + 4 * v25);
if ( v28 > 0 )
break;
}
LABEL_53:
if ( ++v25 > v44 )
{
v22 = v45;
goto LABEL_55;
}
}
while ( 1 )
{
v29 = *(_QWORD *)(*v26 + 8 * v27);
v30 = *(__int16 *)(a1 + 14866);
v31 = *(__int16 *)(v29 + 1212);
v32 = *(__int16 *)(v29 + 1210);
if ( !*(_WORD *)(v29 + 1212) )
v31 = -1;
v33 = (_WORD)v30 == 0xFFFF || (_WORD)v30 == (_WORD)v32 || v30 == v31;
v34 = 9999;
if ( v32 < 9999 )
v34 = *(__int16 *)(v29 + 1210);
v35 = 9999;
if ( v34 < 0 )
v34 = 0;
if ( v31 < 9999 )
v35 = v31;
if ( v35 < -1 )
v35 = -1;
if ( v33 )
{
v36 = *(_QWORD *)(a1 + 15208);
v37 = *(_DWORD *)(v36 + 4 * ((unsigned __int64)(unsigned int)v34 >> 5));
if ( !_bittest(&v37, v34 & 0x1F) )
{
if ( v35 == -1 || (v38 = *(_DWORD *)(v36 + 4 * ((unsigned __int64)v35 >> 5)), !_bittest(&v38, v35 & 0x1F)) )
{
LevelEditorLayer::getObjectRect(a1, v42, *(_QWORD *)(*v26 + 8 * v27));
if ( *(_BYTE *)(a1 + 14901) )
goto LABEL_61;
if ( cocos2d::CCRect::containsPoint((cocos2d::CCRect *)v42, (const struct cocos2d::CCPoint *)a2) )
return v29;
if ( *(_BYTE *)(a1 + 14901) )
{
LABEL_61:
if ( OBB2D::overlaps1Way(*(_QWORD *)(a1 + 14872), *(float **)(a1 + 2312)) && OBB2D::overlaps1Way(v39, v40) )
return v29;
}
}
}
}
if ( ++v27 >= v28 )
goto LABEL_53;
}
}