//
// LevelEditorLayer::objectsAtPosition from 0x1402d5410 to 0x1402d57f9 (1001 bytes)
//
// 7 xrefs:
// > EditorUI::onDelete @ 0x1400e5e3a
// > EditorUI::ccTouchBegan @ 0x140123b91
// > EditorUI::ccTouchEnded @ 0x140124de6
// > EditorUI::ccTouchEnded @ 0x14012503a
// > ??> @ 0x14068e150
// > ??> @ 0x14068e160
// > ??> @ 0x1406d2ff0
//
// 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
//
cocos2d::CCArray *LevelEditorLayer::objectsAtPosition(LevelEditorLayer *a1, cocos2d::CCPoint a2)
{
double v4; // xmm0_8
__int64 v5; // rax
__int64 v6; // rbx
float v7; // xmm6_4
__int64 v8; // rcx
cocos2d::CCArray *result; // rax
float v10; // xmm1_4
cocos2d::CCArray *v11; // r12
float v12; // xmm0_4
float m_sectionXFactor; // xmm0_4
float v14; // xmm1_4
int v15; // r8d
float m_sectionYFactor; // xmm0_4
std::_Vector_val *, std::allocator *>> *>>::pointer Mylast; // r11
std::_Vector_val *, std::allocator *>> *>>::pointer Myfirst; // rbx
int v19; // r9d
int v20; // r10d
__int64 v21; // rdx
int v22; // r8d
int v23; // ecx
int v24; // r10d
__int64 v25; // r13
__int64 v26; // r8
std::_Simple_types *, std::allocator *>> *>::value_type v27; // rcx
__int64 v28; // rdx
int v29; // edx
__int64 v30; // r14
std::_Simple_types *>::value_type v31; // r15
__int64 v32; // rsi
__int64 v33; // rbp
const struct cocos2d::CCPoint *v34; // r13
int m_currentLayer; // ecx
std::_Simple_types::value_type v36; // rbx
int m_editorLayer2; // eax
int m_editorLayer; // r8d
bool v39; // dl
int v40; // ecx
int v41; // r8d
std::_Vector_val>::pointer v42; // r9
std::_Simple_types::value_type v43; // eax
std::_Simple_types::value_type v44; // eax
OBB2D *v45; // r8
bool X; // [rsp+20h] [rbp-88h]
__int64 v47; // [rsp+30h] [rbp-78h]
__int64 v48; // [rsp+38h] [rbp-70h]
cocos2d::CCRect v49; // [rsp+40h] [rbp-68h] BYREF
int v50; // [rsp+B0h] [rbp+8h] BYREF
cocos2d::CCPoint v51; // [rsp+B8h] [rbp+10h]
__int64 v52; // [rsp+C0h] [rbp+18h]
__int64 v53; // [rsp+C8h] [rbp+20h]
v51 = a2;
v4 = cocos2d::CCRect::CCRect(&v49, **(float **)&a2, *(float *)(*(_QWORD *)&a2 + 4LL), 1.0, 1.0);
v6 = v5;
cocos2d::CCPoint::CCPoint(*(float *)&v4, *(float *)(v5 + 8) * 0.5);
cocos2d::CCPoint::operator+(v6, &v50);
v7 = 0.0;
OBB2D::calculateWithCenter(a1->m_obb2, (cocos2d::CCPoint)&v50, *(float *)(v6 + 8), *(float *)(v6 + 12), 0.0);
result = (cocos2d::CCArray *)cocos2d::CCArray::create(v8);
v10 = **(float **)&a2;
v11 = result;
if ( **(float **)&a2 > 0.0 )
{
m_sectionXFactor = a1->m_sectionXFactor;
if ( v10 < 10000000.0 )
v12 = v10 * m_sectionXFactor;
else
v12 = m_sectionXFactor * 10000000.0;
}
else
{
v12 = 0.0;
}
v14 = *(float *)(*(_QWORD *)&a2 + 4LL);
v15 = (int)v12;
if ( v14 > 0.0 )
{
m_sectionYFactor = a1->m_sectionYFactor;
if ( v14 < 10000000.0 )
v7 = v14 * m_sectionYFactor;
else
v7 = m_sectionYFactor * 10000000.0;
}
Mylast = a1->m_sections._Mypair._Myval2._Mylast;
Myfirst = a1->m_sections._Mypair._Myval2._Myfirst;
v19 = 0;
v20 = (int)v7;
if ( v15 - 1 >= 0 )
v19 = v15 - 1;
v21 = a1->m_sections._Mypair._Myval2._Mylast - Myfirst;
v22 = v15 + 1;
if ( v22 >= (unsigned __int64)(v21 - 1) )
v22 = v21 - 1;
v23 = 0;
if ( v20 - 1 >= 0 )
v23 = v20 - 1;
v24 = v20 + 1;
v50 = v24;
if ( Myfirst != Mylast )
{
v25 = v19;
v52 = v19;
v48 = v22;
if ( v19 <= (__int64)v22 )
{
v26 = v23;
v47 = v23;
while ( 1 )
{
v27 = a1->m_sections._Mypair._Myval2._Myfirst[v25];
if ( v27 )
{
v28 = v27->_Mypair._Myval2._Mylast - v27->_Mypair._Myval2._Myfirst;
v29 = v24 >= (unsigned __int64)(v28 - 1) ? v28 - 1 : v24;
}
else
{
v29 = -1;
}
v30 = v26;
v53 = v29;
if ( v26 <= v29 )
break;
LABEL_57:
v52 = ++v25;
if ( v25 > v48 )
return v11;
}
while ( 1 )
{
v31 = a1->m_sections._Mypair._Myval2._Myfirst[v25]->_Mypair._Myval2._Myfirst[v30];
if ( v31 )
{
v32 = 0;
v33 = a1->m_sectionSizes._Mypair._Myval2._Myfirst[v25]->_Mypair._Myval2._Myfirst[v30];
if ( v33 > 0 )
break;
}
LABEL_55:
if ( ++v30 > v53 )
{
v26 = v47;
v24 = v50;
goto LABEL_57;
}
}
v34 = (const struct cocos2d::CCPoint *)v51;
while ( 1 )
{
m_currentLayer = a1->m_currentLayer;
v36 = v31->_Mypair._Myval2._Myfirst[v32];
m_editorLayer2 = v36->m_editorLayer2;
m_editorLayer = v36->m_editorLayer;
if ( !v36->m_editorLayer2 )
m_editorLayer2 = -1;
v39 = (_WORD)m_currentLayer == 0xFFFF || m_currentLayer == m_editorLayer || m_currentLayer == m_editorLayer2;
v40 = 9999;
if ( m_editorLayer < 9999 )
v40 = v36->m_editorLayer;
v41 = 9999;
if ( v40 < 0 )
v40 = 0;
if ( m_editorLayer2 < 9999 )
v41 = m_editorLayer2;
if ( v41 < -1 )
v41 = -1;
if ( !v39 )
goto LABEL_53;
v42 = a1->m_lockedLayers._Myvec._Mypair._Myval2._Myfirst;
v43 = v42[(unsigned __int64)(unsigned int)v40 >> 5];
if ( _bittest((const int *)&v43, v40 & 0x1F) )
goto LABEL_53;
if ( v41 != -1 )
{
v44 = v42[(unsigned __int64)v41 >> 5];
if ( _bittest((const int *)&v44, v41 & 0x1F) )
goto LABEL_53;
}
LevelEditorLayer::getObjectRect(
(cocos2d::CCRect *)a1,
(LevelEditorLayer *)&v49,
v31->_Mypair._Myval2._Myfirst[v32],
(bool)v42,
X);
if ( a1->m_nonSquareRotation )
break;
if ( cocos2d::CCRect::containsPoint(&v49, v34) )
goto LABEL_52;
if ( a1->m_nonSquareRotation )
break;
LABEL_53:
if ( ++v32 >= v33 )
{
v25 = v52;
goto LABEL_55;
}
}
if ( !OBB2D::overlaps1Way(a1->m_currentOBB2D) || !OBB2D::overlaps1Way(v45) )
goto LABEL_53;
LABEL_52:
cocos2d::CCArray::addObject(v11, v36);
goto LABEL_53;
}
return v11;
}
return result;
}