//
// LevelEditorLayer::objectsAtPosition from 0x1000e1970 to 0x1000e1cbc (844 bytes)
//
// 4 xrefs:
// > EditorUI::onDelete @ 0x10002dc54
// > EditorUI::ccTouchBegan @ 0x10004f1c3
// > EditorUI::ccTouchEnded @ 0x10004fe7b
// > EditorUI::ccTouchEnded @ 0x10004ff52
//
// 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 *__fastcall LevelEditorLayer::objectsAtPosition(LevelEditorLayer *a1, cocos2d::CCPoint a2)
{
float *v2; // rsi
float v4; // xmm2_4
float v5; // xmm0_4
float v6; // xmm1_4
float m_sectionXFactor; // xmm1_4
int v8; // edx
float v9; // xmm1_4
float m_sectionYFactor; // xmm0_4
int v11; // ecx
unsigned int v12; // r9d
unsigned int v13; // eax
unsigned __int64 v14; // r10
std::__vector_base *, std::allocator *>> *, std::allocator *, std::allocator *>> *>>::pointer end; // rdx
std::__vector_base *, std::allocator *>> *, std::allocator *, std::allocator *>> *>>::pointer begin; // rsi
__int64 v17; // rdi
unsigned __int64 v18; // r8
unsigned int v19; // edi
__int64 v20; // r10
std::vector *, std::allocator *>> *v21; // rax
__int64 v22; // rdx
unsigned __int64 v23; // rax
__int64 v24; // rdx
__int64 v25; // r11
std::vector *v26; // rbx
__int64 v27; // r15
__int64 v28; // r12
std::__vector_base::pointer v29; // rsi
__int64 v30; // rdi
GameObject *v31; // r13
unsigned __int64 m_editorLayer; // rcx
int v33; // eax
__int16 m_currentLayer; // dx
bool v35; // si
bool v36; // di
bool v37; // r8
unsigned __int16 v38; // dx
__int64 v39; // rcx
bool m_nonSquareRotation; // al
_BYTE v42[16]; // [rsp+0h] [rbp-80h] BYREF
__int64 v43; // [rsp+10h] [rbp-70h]
__int64 v44; // [rsp+18h] [rbp-68h]
unsigned __int64 v45; // [rsp+20h] [rbp-60h]
__int64 v46; // [rsp+28h] [rbp-58h]
float *v47; // [rsp+30h] [rbp-50h]
cocos2d::CCArray *v48; // [rsp+38h] [rbp-48h]
int v49; // [rsp+44h] [rbp-3Ch]
__int64 v50; // [rsp+48h] [rbp-38h]
unsigned __int64 v51; // [rsp+50h] [rbp-30h]
cocos2d::CCRect ObjectRect; // 0:kr00_16.16
cocos2d::CCRect v53; // 0:xmm0_8.8,8:xmm1_8.8
v53.origin = (cocos2d::CCPoint)*(unsigned int *)v2;
v53.size = (cocos2d::CCSize)*((unsigned int *)v2 + 1);
sub_10028CC00(v42, *(double *)&v53.origin, *(double *)&v53.size, 1.0, 1.0);
GJBaseGameLayer::updateOBB2(a1, v53);
v48 = (cocos2d::CCArray *)sub_10071F9E0(a1, v42);
v47 = v2;
v4 = *v2;
v5 = 0.0;
v6 = 0.0;
if ( *v2 > 0.0 )
{
m_sectionXFactor = a1->m_sectionXFactor;
if ( v4 >= 10000000.0 )
v6 = m_sectionXFactor * 10000000.0;
else
v6 = m_sectionXFactor * v4;
}
v8 = (int)v6;
v9 = v47[1];
if ( v9 > 0.0 )
{
m_sectionYFactor = a1->m_sectionYFactor;
if ( v9 >= 10000000.0 )
v5 = m_sectionYFactor * 10000000.0;
else
v5 = m_sectionYFactor * v9;
}
v11 = (int)v5;
v12 = 1;
v13 = 1;
if ( v8 >= 2 )
v13 = v8;
v14 = v8 + 1;
end = a1->m_sections.__end_;
begin = a1->m_sections.__begin_;
v17 = end - begin;
v18 = v17 - 1;
v19 = v17 - 1;
if ( v18 < v14 )
v14 = v19;
v51 = v14;
if ( v11 >= 2 )
v12 = (int)v5;
if ( end != begin && (int)(v13 - 1) <= (int)v51 )
{
v45 = v11 + 1;
v49 = v12 - 1;
v46 = v12 - 1LL;
v20 = v13 - 1LL;
v51 = (unsigned int)(v51 + 1);
while ( 1 )
{
v21 = a1->m_sections.__begin_[v20];
if ( v21 )
{
v22 = v21->__end_ - v21->__begin_;
v23 = v22 - 1;
v24 = (unsigned int)(v22 - 1);
if ( v23 >= v45 )
v24 = (unsigned int)v45;
v50 = v24;
if ( v49 <= (int)v24 )
break;
}
LABEL_18:
if ( ++v20 == v51 )
return v48;
}
v50 = (unsigned int)(v50 + 1);
v25 = v46;
v44 = v20;
while ( 1 )
{
v26 = a1->m_sections.__begin_[v20]->__begin_[v25];
if ( v26 )
{
v27 = a1->m_sectionSizes.__begin_[v20]->__begin_[v25];
if ( v27 > 0 )
break;
}
LABEL_24:
if ( ++v25 == v50 )
goto LABEL_18;
}
v28 = 0;
v43 = v25;
while ( 1 )
{
v31 = v26->__begin_[v28];
m_editorLayer = (unsigned __int16)v31->m_editorLayer;
v33 = (unsigned __int16)*(_DWORD *)&v31->m_editorLayer2 == 0 ? -1 : *(_DWORD *)&v31->m_editorLayer2;
m_currentLayer = a1->m_currentLayer;
v35 = m_currentLayer == -1;
v36 = m_currentLayer == (__int16)m_editorLayer;
v37 = m_currentLayer == (__int16)((unsigned __int16)*(_DWORD *)&v31->m_editorLayer2 == 0 ? -1 : v31->m_editorLayer2);
v38 = v33;
if ( (__int16)((unsigned __int16)*(_DWORD *)&v31->m_editorLayer2 == 0 ? -1 : v31->m_editorLayer2) >= 9999 )
break;
if ( (v33 & 0x8000u) == 0 )
goto LABEL_32;
v38 = -1;
if ( v37 || v36 || v35 )
{
LABEL_36:
if ( (__int16)m_editorLayer >= 9999 )
m_editorLayer = 9999;
if ( (__int16)m_editorLayer <= 0 )
m_editorLayer = 0;
v29 = a1->m_lockedLayers.__begin_;
v30 = *(_QWORD *)&v29[((unsigned int)m_editorLayer >> 3) & 0x7F8];
if ( _bittest64(&v30, m_editorLayer) )
goto LABEL_29;
if ( (v33 & 0x8000u) == 0 )
{
v39 = *(_QWORD *)&v29[8 * ((unsigned __int64)v38 >> 6)];
if ( _bittest64(&v39, v38) )
goto LABEL_29;
}
ObjectRect = LevelEditorLayer::getObjectRect(
(LevelEditorLayer *)v42,
(GameObject *)a1,
(bool)v26->__begin_[v28],
0);
m_nonSquareRotation = a1->m_nonSquareRotation;
if ( m_nonSquareRotation )
{
LABEL_45:
if ( m_nonSquareRotation && OBB2D::overlaps(a1->m_currentOBB2D) )
goto LABEL_47;
}
else
{
if ( !(unsigned __int8)sub_10028D2D0(
v42,
v47,
COERCE_DOUBLE(ObjectRect.origin),
COERCE_DOUBLE(ObjectRect.size)) )
{
m_nonSquareRotation = a1->m_nonSquareRotation;
goto LABEL_45;
}
LABEL_47:
sub_10071FCD0(v48, v31);
}
v20 = v44;
v25 = v43;
}
LABEL_29:
if ( v27 == ++v28 )
goto LABEL_24;
}
v38 = 9999;
LABEL_32:
if ( v37 || v36 || v35 )
goto LABEL_36;
goto LABEL_29;
}
return v48;
}