//
// EditorUI::createSmartObjectsFromType from 0x140117f10 to 0x140118428 (1304 bytes)
//
// 4 xrefs:
// > SetupSmartBlockLayer::onCreate @ 0x1404587e3
// > ??> @ 0x14066f948
// > ??> @ 0x14066f9b8
// > ??> @ 0x1406c9324
//
// 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 EditorUI::createSmartObjectsFromType(EditorUI *a1, int a2, cocos2d::CCArray *a3, bool a4, bool a5)
{
__int64 v8; // rcx
unsigned int v9; // r15d
cocos2d::CCArray *v10; // r12
int v11; // r13d
unsigned int v12; // ebx
int m_uIndexInArray_high; // ecx
ObjectToolbox *v14; // rcx
__int64 v15; // rcx
unsigned int v16; // ebp
cocos2d::CCArray *v17; // r12
struct cocos2d::CCObject *v18; // r13
int i; // ebx
struct cocos2d::CCObject *v20; // rdi
float v21; // xmm2_4
cocos2d::CCPoint *v22; // rcx
float v23; // xmm1_4
__int64 v24; // rax
cocos2d::CCArray *v25; // rdi
__int64 v26; // rcx
cocos2d::CCArray *v27; // rbx
__int64 v28; // rcx
cocos2d::CCArray *v29; // rbp
unsigned int v30; // ebx
__int16 v31; // r13
struct cocos2d::CCObject *v32; // rax
struct cocos2d::CCArray *RockEdges; // rax
struct cocos2d::CCArray *RockBases; // rax
struct cocos2d::CCArray *Outlines; // rax
__int64 v36; // rcx
__int64 v37; // rcx
unsigned int v38; // ebx
cocos2d::CCArray *j; // rdi
GameObject *v40; // rax
int m_objectID; // edx
GameObject *v42; // rax
GameObject *v43; // rdi
_BOOL8 v44; // rdx
LevelEditorLayer *m_editorLayer; // rbx
GJRotationControl *m_rotationControl; // rcx
cocos2d::CCPoint v47; // [rsp+30h] [rbp-98h] BYREF
struct cocos2d::CCArray *v48; // [rsp+38h] [rbp-90h]
char v49; // [rsp+40h] [rbp-88h] BYREF
__int64 v50; // [rsp+48h] [rbp-80h]
char v51; // [rsp+50h] [rbp-78h] BYREF
char v52; // [rsp+58h] [rbp-70h] BYREF
char v53; // [rsp+60h] [rbp-68h] BYREF
char v54; // [rsp+68h] [rbp-60h] BYREF
__int16 v56; // [rsp+E0h] [rbp+18h]
if ( a3 && cocos2d::CCArray::count(a3) )
{
EditorUI::deselectAll(a1);
v9 = 0;
v48 = a3;
v50 = cocos2d::CCArray::create(v8);
v10 = (cocos2d::CCArray *)v50;
v56 = 0;
v11 = 0;
v12 = 0;
if ( cocos2d::CCArray::count(a3) )
{
do
{
m_uIndexInArray_high = SHIWORD(cocos2d::CCArray::objectAtIndex(a3, v12)[21].m_uIndexInArray);
if ( m_uIndexInArray_high <= v11 )
m_uIndexInArray_high = v11;
++v12;
v11 = m_uIndexInArray_high;
}
while ( v12 < cocos2d::CCArray::count(a3) );
v56 = v11;
}
ObjectToolbox::sharedState();
if ( ObjectToolbox::gridNodeSizeForKey(v14, a2) == 15.0 )
{
v48 = (struct cocos2d::CCArray *)cocos2d::CCArray::create(v15);
v16 = 0;
if ( cocos2d::CCArray::count(a3) )
{
v17 = v48;
while ( 1 )
{
v18 = cocos2d::CCArray::objectAtIndex(a3, v16);
for ( i = 0; i < 4; ++i )
{
v20 = (struct cocos2d::CCObject *)cocos2d::CCNode::create();
cocos2d::CCPoint::CCPoint(&v47, (const struct cocos2d::CCPoint *)&dword_1406C1AA8);
switch ( i )
{
case 0:
v21 = 7.5;
v22 = (cocos2d::CCPoint *)&v54;
goto LABEL_20;
case 1:
v21 = 7.5;
v22 = (cocos2d::CCPoint *)&v53;
v23 = 7.5;
break;
case 2:
v21 = -7.5;
v22 = (cocos2d::CCPoint *)&v52;
LABEL_20:
v23 = -7.5;
break;
case 3:
v21 = -7.5;
v22 = (cocos2d::CCPoint *)&v51;
v23 = 7.5;
break;
default:
goto LABEL_22;
}
cocos2d::CCPoint::CCPoint(v22, v23, v21);
cocos2d::CCPoint::operator=(&v47, v24);
LABEL_22:
v18->__vftable[2].getTag(v18);
cocos2d::CCPoint::operator+(&v47, &v49);
v20->__vftable[2].encodeWithCoder(v20, (DS_Dictionary *)&v49);
cocos2d::CCArray::addObject(v17, v20);
}
if ( ++v16 >= cocos2d::CCArray::count(a3) )
{
v10 = (cocos2d::CCArray *)v50;
LOWORD(v11) = v56;
break;
}
}
}
}
v25 = (cocos2d::CCArray *)cocos2d::CCArray::create(v15);
cocos2d::CCArray::addObjectsFromArray(v25, v48);
v27 = (cocos2d::CCArray *)cocos2d::CCArray::create(v26);
v29 = (cocos2d::CCArray *)cocos2d::CCArray::create(v28);
EditorUI::processSmartObjectsFromType(a1, a2, v48, v25, v27, v29);
v30 = 0;
if ( cocos2d::CCArray::count(v29) )
{
v31 = v11 + 1;
do
{
v32 = cocos2d::CCArray::objectAtIndex(v29, v30++);
LOWORD(v32[21].m_uUnknown) = v31;
}
while ( v30 < cocos2d::CCArray::count(v29) );
}
cocos2d::CCArray::addObjectsFromArray(v10, v29);
if ( cocos2d::CCArray::count(v10) )
{
RockEdges = EditorUI::createRockEdges(a1, v10);
if ( RockEdges )
cocos2d::CCArray::addObjectsFromArray(v10, RockEdges);
RockBases = EditorUI::createRockBases(a1, v10);
if ( RockBases )
cocos2d::CCArray::addObjectsFromArray(v10, RockBases);
Outlines = EditorUI::createOutlines(a1, v10);
if ( Outlines )
cocos2d::CCArray::addObjectsFromArray(v10, Outlines);
if ( a4 && (unsigned int)(a2 - 2703) <= 1 && v10 && cocos2d::CCArray::count(v10) )
{
cocos2d::CCArray::create(v36);
v38 = 0;
for ( j = (cocos2d::CCArray *)cocos2d::CCArray::create(v37); v38 < cocos2d::CCArray::count(v10); ++v38 )
{
v40 = (GameObject *)cocos2d::CCArray::objectAtIndex(v10, v38);
m_objectID = v40->m_objectID;
if ( m_objectID >= 2808 && m_objectID <= 2837 )
EditorUI::createExtrasForObject(a1, m_objectID, v40, j);
}
if ( j )
cocos2d::CCArray::addObjectsFromArray(v10, j);
}
EditorUI::deselectAll(a1);
if ( a5 )
{
v10 = a3;
}
else if ( cocos2d::CCArray::count(a3) )
{
do
{
v42 = (GameObject *)cocos2d::CCArray::objectAtIndex(a3, v9);
v43 = v42;
if ( v42 )
{
v42->m_wasSelected = v42->m_isSelected;
EditorUI::deselectObject(a1, v42);
LOBYTE(v44) = 1;
m_editorLayer = a1->m_editorLayer;
v43->deactivateObject(v43, v44);
GJBaseGameLayer::removeObjectFromSection(m_editorLayer, v43);
LevelEditorLayer::removeSpecial(m_editorLayer, v43);
m_editorLayer->m_unk3b22 = 1;
m_rotationControl = a1->m_rotationControl;
a1->m_rotationTouchID = -1;
if ( m_rotationControl->isVisible(m_rotationControl) )
{
a1->m_rotationControl->setVisible(a1->m_rotationControl, 0);
GJRotationControl::finishTouch(a1->m_rotationControl);
}
EditorUI::deactivateScaleControl(a1);
EditorUI::deactivateTransformControl(a1);
}
++v9;
}
while ( v9 < cocos2d::CCArray::count(a3) );
}
EditorUI::selectObjects(a1, v10, 1);
EditorUI::updateButtons(a1);
EditorUI::updateObjectInfoLabel(a1);
a1->updateScaleControl(&a1->GJScaleControlDelegate);
}
}
}