//
// EditorUI::createSmartObjectsFromTemplate from 0x7cb0d4 to 0x7cbabc (2536 bytes)
//
// 3 xrefs:
// > SetupSmartBlockLayer::onCreate @ 0xb14298
// > SetupSmartBlockLayer::onPasteTemplate @ 0xb15df8
// > ??> @ 0x85120
//
// This function is hookable on this platform (idp: arm, 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 12:54:11 +0000
//
__int64 __fastcall EditorUI::createSmartObjectsFromTemplate(
EditorUI *this,
GJSmartTemplate *a2,
cocos2d::CCArray *a3,
unsigned __int8 a4,
unsigned __int8 a5,
unsigned __int8 a6,
unsigned __int8 a7)
{
unsigned int v10; // w20
cocos2d::CCArray *v11; // x0
GJSmartTemplate *v12; // x0
GJSmartTemplate *v13; // x19
unsigned int v14; // w24
cocos2d::CCArray ***v15; // x23
__int64 v16; // x0
__int64 *v17; // x20
__int64 v18; // x27
SmartGameObject *v19; // x1
_DWORD *v20; // x27
char *v21; // x1
size_t v22; // x2
char v23; // w1
__int64 v24; // x1
cocos2d::CCArray *v25; // x27
const cocos2d::CCPoint *v26; // x0
float v27; // s8
__int64 v28; // x0
__int64 i; // x20
_BYTE *v30; // x19
unsigned int v31; // w19
unsigned int v32; // w1
SmartGameObject *v33; // x0
UndoObject *v34; // x0
__int64 v36; // x28
SmartGameObject *v37; // x1
__int64 v38; // x19
cocos2d::CCArray *v39; // x0
cocos2d::CCArray *v40; // x28
unsigned int v41; // w19
__int64 v42; // x23
char *v43; // x1
size_t v44; // x2
unsigned int v45; // w19
UndoObject *v46; // x0
unsigned int v47; // w1
GameObject *v48; // x0
int v49; // [xsp+88h] [xbp+78h]
int v50; // [xsp+8Ch] [xbp+7Ch]
cocos2d::CCArray *v51; // [xsp+90h] [xbp+80h]
cocos2d::CCArray *v52; // [xsp+98h] [xbp+88h]
cocos2d::CCDictionary *v53; // [xsp+A8h] [xbp+98h]
int v54; // [xsp+B0h] [xbp+A0h]
int v55; // [xsp+B4h] [xbp+A4h]
cocos2d::CCDictionary *v56; // [xsp+B8h] [xbp+A8h]
_DWORD *SmartNeighbor; // [xsp+C8h] [xbp+B8h]
_DWORD *v59; // [xsp+D0h] [xbp+C0h]
_DWORD *v60; // [xsp+D8h] [xbp+C8h]
_DWORD *v61; // [xsp+E0h] [xbp+D0h]
_DWORD *v62; // [xsp+E8h] [xbp+D8h]
_DWORD *v63; // [xsp+F0h] [xbp+E0h]
cocos2d::CCPoint *v64; // [xsp+F8h] [xbp+E8h]
cocos2d::CCPoint *v65; // [xsp+F8h] [xbp+E8h]
__int64 v66; // [xsp+100h] [xbp+F0h] BYREF
_BYTE v67[16]; // [xsp+108h] [xbp+F8h] BYREF
float v68[4]; // [xsp+118h] [xbp+108h] BYREF
__int64 v69; // [xsp+128h] [xbp+118h] BYREF
size_t v70; // [xsp+130h] [xbp+120h]
void *v71; // [xsp+138h] [xbp+128h]
__int64 v72; // [xsp+140h] [xbp+130h] BYREF
size_t v73; // [xsp+148h] [xbp+138h]
void *v74; // [xsp+150h] [xbp+140h]
__int64 v75; // [xsp+158h] [xbp+148h] BYREF
size_t v76; // [xsp+160h] [xbp+150h]
void *v77; // [xsp+168h] [xbp+158h]
__int64 v78; // [xsp+170h] [xbp+160h] BYREF
__int64 v79; // [xsp+178h] [xbp+168h]
void *v80; // [xsp+180h] [xbp+170h]
__int64 v81; // [xsp+188h] [xbp+178h] BYREF
size_t v82; // [xsp+190h] [xbp+180h]
void *v83; // [xsp+198h] [xbp+188h]
__int64 v84; // [xsp+1A0h] [xbp+190h] BYREF
char v85; // [xsp+1A8h] [xbp+198h]
void *v86; // [xsp+1B8h] [xbp+1A8h]
__int64 v87; // [xsp+1C0h] [xbp+1B0h]
size_t v88; // [xsp+1C8h] [xbp+1B8h]
void *v89; // [xsp+1D0h] [xbp+1C0h]
int v90; // [xsp+1E0h] [xbp+1D0h]
char v91; // [xsp+1E4h] [xbp+1D4h]
char v92; // [xsp+1E5h] [xbp+1D5h]
v54 = a4;
v49 = a5;
v50 = a6;
v55 = a7;
if ( a3 && (unsigned int)cocos2d::CCArray::count(a3) && a2 )
{
if ( !v55 )
EditorBuildStats::noteAction((EditorBuildStats *)(*((_QWORD *)this + 180) + 14704LL));
v10 = 0;
GJSmartTemplate::resetScannedPrefabs(a2);
v11 = (cocos2d::CCArray *)EditorUI::deselectAll(this);
v51 = (cocos2d::CCArray *)cocos2d::CCArray::create(v11);
v52 = (cocos2d::CCArray *)cocos2d::CCArray::create(v51);
v53 = (cocos2d::CCDictionary *)cocos2d::CCArray::create(v52);
v56 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create(v53);
v64 = this;
if ( (unsigned int)cocos2d::CCArray::count(a3) )
{
do
{
v12 = (GJSmartTemplate *)cocos2d::CCArray::objectAtIndex(a3, v10);
v13 = v12;
if ( (unsigned int)(*((_DWORD *)v12 + 257) - 2896) <= 1 )
{
GameObject::determineSlopeDirection(v12);
if ( v54 )
{
LABEL_56:
v36 = (*(__int64 (__fastcall **)(GJSmartTemplate *))(*(_QWORD *)v13 + 192LL))(v13);
GJSmartTemplate::offsetForObject(v13, v37);
cocos2d::CCPoint::operator+(&v66, v36);
cocos2d::CCRect::CCRect(
(cocos2d::CCRect *)v67,
*(float *)&v66 - 37.5,
*((float *)&v66 + 1) - 37.5,
75.0,
75.0);
v38 = *((_QWORD *)v64 + 180);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v68, (const cocos2d::CCRect *)v67);
v39 = LevelEditorLayer::objectsInRect(v38, v68, 1u);
v40 = v39;
if ( v39 && (unsigned int)cocos2d::CCArray::count(v39) )
{
v41 = 0;
while ( v41 < (unsigned int)cocos2d::CCArray::count(v40) )
{
v42 = cocos2d::CCArray::objectAtIndex(v40, v41);
if ( *(_DWORD *)(v42 + 1248) != 5
|| (unsigned __int8)cocos2d::CCArray::containsObject(a3, (cocos2d::CCObject *)v42) )
{
++v41;
}
else
{
++v41;
cocos2d::CCArray::addObject(a3, (cocos2d::CCObject *)v42);
cocos2d::CCDictionary::setObject(v56, (cocos2d::CCObject *)v42, *(unsigned int *)(v42 + 916));
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v42 + 72LL))(
v42,
*(unsigned __int8 *)(v42 + 1347));
*(_BYTE *)(v42 + 1347) = 1;
}
}
}
}
}
else if ( v54 )
{
goto LABEL_56;
}
++v10;
}
while ( v10 < (unsigned int)cocos2d::CCArray::count(a3) );
}
v14 = 0;
v15 = (cocos2d::CCArray ***)v64;
while ( v14 < (unsigned int)cocos2d::CCArray::count(a3) )
{
v16 = cocos2d::CCArray::objectAtIndex(a3, v14);
v17 = (__int64 *)v16;
if ( *(_BYTE *)(v16 + 1347) )
{
if ( !cocos2d::CCDictionary::objectForKey(v56, *(unsigned int *)(v16 + 916)) )
{
++v14;
cocos2d::CCArray::addObject(v52, (cocos2d::CCObject *)v17);
continue;
}
goto LABEL_41;
}
v18 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v16 + 192LL))(v16);
GJSmartTemplate::offsetForObject((GJSmartTemplate *)v17, v19);
cocos2d::CCPoint::operator+(&v66, v18);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v68, (const cocos2d::CCPoint *)&v66);
SmartNeighbor = EditorUI::getSmartNeighbor((__int64)v15, (__int64)v17, (__int64)v68, 1u, a3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v68, (const cocos2d::CCPoint *)&v66);
v59 = EditorUI::getSmartNeighbor((__int64)v15, (__int64)v17, (__int64)v68, 2u, a3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v68, (const cocos2d::CCPoint *)&v66);
v20 = EditorUI::getSmartNeighbor((__int64)v15, (__int64)v17, (__int64)v68, 3u, a3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v68, (const cocos2d::CCPoint *)&v66);
v60 = EditorUI::getSmartNeighbor((__int64)v15, (__int64)v17, (__int64)v68, 4u, a3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v68, (const cocos2d::CCPoint *)&v66);
v61 = EditorUI::getSmartNeighbor((__int64)v15, (__int64)v17, (__int64)v68, 5u, a3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v68, (const cocos2d::CCPoint *)&v66);
v62 = EditorUI::getSmartNeighbor((__int64)v15, (__int64)v17, (__int64)v68, 6u, a3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v68, (const cocos2d::CCPoint *)&v66);
v63 = EditorUI::getSmartNeighbor((__int64)v15, (__int64)v17, (__int64)v68, 7u, a3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v68, (const cocos2d::CCPoint *)&v66);
v65 = (cocos2d::CCPoint *)EditorUI::getSmartNeighbor((__int64)v15, (__int64)v17, (__int64)v68, 8u, a3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v68, (const cocos2d::CCPoint *)&v66);
GJSmartTemplate::keyFromNeighbors(&v69, v68, v17, SmartNeighbor, v59, v20, v60, v61, v62, v63, v65);
v72 = 0;
v73 = 0;
v74 = nullptr;
if ( (v69 & 1) != 0 )
{
std::string::__init(&v72, v71, v70);
}
else
{
v74 = v71;
v72 = v69;
v73 = v70;
}
GJSmartTemplate::scanForPrefab(&v84, a2, &v72);
if ( (v72 & 1) != 0 )
{
operator delete(v74);
if ( v84 )
{
LABEL_16:
cocos2d::CCArray::addObject(v53, (cocos2d::CCObject *)v17);
v75 = 0;
v76 = 0;
v77 = nullptr;
if ( (v87 & 1) != 0 )
{
std::string::__init(&v75, v89, v88);
}
else
{
v77 = v89;
v75 = v87;
v76 = v88;
}
if ( v17 + 169 != &v75 )
{
if ( (v75 & 1) != 0 )
{
v21 = (char *)v77;
v22 = v76;
}
else
{
v22 = (unsigned __int8)v75 >> 1;
v21 = (char *)&v75 + 1;
}
std::string::assign(v17 + 169, v21, v22);
}
if ( (v75 & 1) != 0 )
operator delete(v77);
if ( !v55 )
{
v78 = 0;
v23 = *(_BYTE *)(v84 + 80);
v79 = 0;
v80 = nullptr;
if ( (v23 & 1) != 0 )
{
std::string::__init(&v78, *(void **)(v84 + 96), *(_QWORD *)(v84 + 88));
}
else
{
v80 = *(void **)(v84 + 96);
v24 = *(_QWORD *)(v84 + 88);
v78 = *(_QWORD *)(v84 + 80);
v79 = v24;
}
v25 = (cocos2d::CCArray *)EditorUI::pasteObjects((int)v15, (int)&v78);
if ( (v78 & 1) != 0 )
operator delete(v80);
if ( v25 && (unsigned int)cocos2d::CCArray::count(v25) )
{
v26 = (const cocos2d::CCPoint *)(*(__int64 (__fastcall **)(__int64 *))(*v17 + 192))(v17);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v67, v26);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v68, (const cocos2d::CCPoint *)v67);
EditorUI::repositionObjectsToCenter(v15, v25, v68, 0);
if ( v92 )
EditorUI::flipObjectsY((EditorUI *)v15, v25);
if ( v91 )
EditorUI::flipObjectsX((EditorUI *)v15, v25);
if ( v90 > 0 )
{
v27 = (float)-v90;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v68, (const cocos2d::CCPoint *)&dword_155C778);
EditorUI::rotateObjects(v15, v25, v68, 0, v27);
}
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v68, (const cocos2d::CCPoint *)v67);
EditorUI::repositionObjectsToCenter(v15, v25, v68, 0);
EditorUI::deleteSmartBlocksFromObjects((GJBaseGameLayer **)v15, v25);
cocos2d::CCArray::addObjectsFromArray(v51, v25);
cocos2d::CCArray::addObject(v52, (cocos2d::CCObject *)v17);
}
}
LABEL_38:
if ( (v87 & 1) != 0 )
goto LABEL_77;
goto LABEL_39;
}
}
else if ( v84 )
{
goto LABEL_16;
}
v81 = 0;
v82 = 0;
v83 = nullptr;
std::string::__init(&v81, &byte_11B8890, 0);
if ( v17 + 169 != &v81 )
{
if ( (v81 & 1) != 0 )
{
v43 = (char *)v83;
v44 = v82;
}
else
{
v44 = (unsigned __int8)v81 >> 1;
v43 = (char *)&v81 + 1;
}
std::string::assign(v17 + 169, v43, v44);
}
if ( (v81 & 1) == 0 )
goto LABEL_38;
operator delete(v83);
if ( (v87 & 1) != 0 )
{
LABEL_77:
operator delete(v89);
if ( (v85 & 1) == 0 )
goto LABEL_40;
goto LABEL_78;
}
LABEL_39:
if ( (v85 & 1) == 0 )
goto LABEL_40;
LABEL_78:
operator delete(v86);
LABEL_40:
if ( (v69 & 1) != 0 )
{
++v14;
operator delete(v71);
continue;
}
LABEL_41:
++v14;
}
if ( v56 )
{
if ( v54 )
{
v28 = *((_QWORD *)v56 + 7);
if ( v28 )
{
for ( i = *(_QWORD *)(v28 + 288); ; i = *(_QWORD *)(i + 288) )
{
v30 = *(_BYTE **)(v28 + 264);
v30[1347] = (*(unsigned int (__fastcall **)(_BYTE *))(*(_QWORD *)v30 + 64LL))(v30) != 0;
if ( !i )
break;
v28 = i;
}
}
}
}
EditorUI::deselectAll((EditorUI *)v15);
if ( v50 )
{
v31 = 0;
while ( v31 < (unsigned int)cocos2d::CCArray::count(v53) )
{
v32 = v31++;
v33 = (SmartGameObject *)cocos2d::CCArray::objectAtIndex(v53, v32);
*((_BYTE *)v33 + 1347) = 1;
SmartGameObject::updateSmartFrame(v33);
}
}
else if ( !v49 )
{
v45 = 0;
v46 = (UndoObject *)UndoObject::createWithArray(v52, 4);
LevelEditorLayer::addToUndoList(v15[180], v46, 0);
while ( v45 < (unsigned int)cocos2d::CCArray::count(v52) )
{
v47 = v45++;
v48 = (GameObject *)cocos2d::CCArray::objectAtIndex(v52, v47);
EditorUI::deleteObject((EditorUI *)v15, v48, 1);
}
EditorUI::selectObjects((EditorUI *)v15, v51, 1);
goto LABEL_54;
}
EditorUI::selectObjects((EditorUI *)v15, a3, 1);
LABEL_54:
v34 = (UndoObject *)UndoObject::createWithArray(v51, 3);
LevelEditorLayer::addToUndoList(v15[180], v34, 0);
EditorUI::updateSelectionUI((EditorUI *)v15);
}
return _stack_chk_guard;
}