//
// LevelEditorLayer::typeExistsAtPosition from 0x3665d8 to 0x3668a8 (720 bytes)
//
// 1 xrefs:
// > EditorUI::onCreateObject @ 0x3a3c82
//
// 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
//
bool LevelEditorLayer::typeExistsAtPosition(
LevelEditorLayer *a1,
int a2,
cocos2d::CCPoint a3,
bool a4,
bool a5,
float a6)
{
float x; // r11
cocos2d::CCRect *v8; // r6
cocos2d::CCPoint v9; // r2
float v10; // s15
float m_sectionXFactor; // s14
float v12; // s14
int v13; // r2
float v14; // s15
float v15; // s14
float *p_m_sectionYFactor; // r3
int v17; // r3
std::vector *, std::allocator *>> *, std::allocator *, std::allocator *>> *>> *p_m_sections; // r8
std::vector *, std::allocator *>> **m_finish; // r1
std::vector *, std::allocator *>> **m_start; // r0
int v21; // r4
int v22; // r2
int v23; // r0
cocos2d::CCRect *v24; // r7
std::vector *, std::allocator *>> *v25; // r2
unsigned int v26; // r3
int v27; // r10
int v28; // r9
GameObject *v29; // r4
float width; // s17
int v31; // r0
float height; // s16
float v33; // s15
float v34; // r0
float *v35; // r0
float v36; // s16
int v37; // r0
const cocos2d::CCPoint *v38; // r0
cocos2d::CCPoint v39; // r2
signed int i; // [sp+Ch] [bp-78h]
int v42; // [sp+10h] [bp-74h]
int v43; // [sp+14h] [bp-70h]
signed int v44; // [sp+18h] [bp-6Ch]
_DWORD *v45; // [sp+1Ch] [bp-68h]
unsigned int v46; // [sp+20h] [bp-64h]
int v47; // [sp+24h] [bp-60h]
int v48; // [sp+28h] [bp-5Ch]
float y; // [sp+30h] [bp-54h]
cocos2d::CCPoint v51; // [sp+4Ch] [bp-38h] BYREF
cocos2d::CCSize v52; // [sp+54h] [bp-30h] BYREF
cocos2d::CCPoint v53; // [sp+5Ch] [bp-28h] BYREF
cocos2d::CCPoint v54; // [sp+64h] [bp-20h] BYREF
cocos2d::CCRect v55; // [sp+6Ch] [bp-18h] BYREF
x = a3.x;
v8 = &v55;
y = a3.y;
cocos2d::CCPoint::CCPoint(&v55.origin, (const cocos2d::CCPoint *)LODWORD(a3.x));
LODWORD(v9.x) = &v55;
LevelEditorLayer::getGridPos(&v51, a1, v9);
v10 = *(float *)LODWORD(x);
if ( *(float *)LODWORD(x) <= 0.0 )
{
v13 = 0;
}
else
{
m_sectionXFactor = a1->m_sectionXFactor;
if ( v10 < 10000000.0 )
v12 = v10 * m_sectionXFactor;
else
v12 = m_sectionXFactor * 10000000.0;
v13 = (int)v12;
}
v14 = *(float *)(LODWORD(x) + 4);
if ( v14 <= 0.0 )
{
v17 = 0;
}
else
{
v15 = 10000000.0;
p_m_sectionYFactor = &a1->m_sectionYFactor;
if ( v14 < 10000000.0 )
v15 = *p_m_sectionYFactor;
else
v14 = *p_m_sectionYFactor;
v17 = (int)(float)(v14 * v15);
}
p_m_sections = &a1->m_sections;
if ( v13 > 1 )
v8 = (cocos2d::CCRect *)(v13 - 1);
m_finish = a1->m_sections.m_finish;
m_start = a1->m_sections.m_start;
if ( v13 <= 1 )
v8 = nullptr;
v21 = v13 + 1;
if ( v13 + 1 >= (unsigned int)(m_finish - m_start - 1) )
v21 = m_finish - m_start - 1;
if ( v17 <= 1 )
v22 = 0;
else
v22 = v17 - 1;
v42 = v21;
v43 = v22;
v46 = v17 + 1;
if ( m_start != m_finish )
{
v24 = (cocos2d::CCRect *)(4 * (_DWORD)v8);
v48 = 4 * v22;
while ( (int)v8 <= v42 )
{
v25 = *(std::vector *, std::allocator *>> **)((char *)p_m_sections->m_start + (unsigned int)v24);
if ( v25 )
{
v26 = v25->m_finish - v25->m_start - 1;
if ( v26 >= v46 )
v26 = v46;
}
else
{
v26 = -1;
}
v44 = v26;
v27 = v48;
for ( i = v43; i <= v44; ++i )
{
v45 = *(_DWORD **)(**(_DWORD **)((char *)p_m_sections->m_start + (unsigned int)v24) + v27);
if ( v45 )
{
v28 = 0;
v47 = *(_DWORD *)(**(_DWORD **)((char *)a1->m_sectionSizes.m_start + (unsigned int)v24) + v27);
while ( v28 < v47 )
{
v29 = *(GameObject **)(*v45 + 4 * v28);
if ( LevelEditorLayer::validGroup(a1, v29, 0)
&& a2 == v29->m_objectID
&& v29->getRotation(v29) == *(float *)&a5
&& ((int (__fastcall *)(GameObject *))v29->isFlipX)(v29) == LODWORD(y)
&& ((int (__fastcall *)(GameObject *))v29->isFlipY)(v29) == a4 )
{
width = v29->m_obRect.size.width;
*(float *)&v31 = COERCE_FLOAT(((int (__fastcall *)(GameObject *))v29->getRScaleX)(v29));
height = v29->m_obRect.size.height;
v33 = *(float *)&v31;
v34 = v29->getRScaleY(v29);
cocos2d::CCSize::CCSize(&v52, width * v33, height * v34);
v35 = (float *)v29->getPosition(v29);
v36 = *v35 - (float)(v52.width * 0.5);
v37 = (int)v29->getPosition(v29);
cocos2d::CCRect::CCRect(&v55, v36, *(float *)(v37 + 4) - (float)(v52.height * 0.5), v52.width, v52.height);
v38 = v29->getPosition(v29);
cocos2d::CCPoint::CCPoint(&v54, v38);
LODWORD(v39.x) = &v54;
LevelEditorLayer::getGridPos(&v53, a1, v39);
v23 = cocos2d::CCRect::containsPoint(&v55, (const cocos2d::CCPoint *)LODWORD(x));
if ( v23 )
{
if ( v51.x == v53.x && v51.y == v53.y )
return v23;
}
}
++v28;
}
}
v27 += 4;
}
v8 = (cocos2d::CCRect *)((char *)v8 + 1);
v24 = (cocos2d::CCRect *)((char *)v24 + 4);
}
}
LOBYTE(v23) = 0;
return v23;
}