//
// EditorUI::createSmartObjectsFromTemplate from 0x487ca0 to 0x4881fe (1374 bytes)
//
// 2 xrefs:
// > SetupSmartBlockLayer::onCreate @ 0x6726fc
// > SetupSmartBlockLayer::onPasteTemplate @ 0x673af4
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 11:49:27 +0000
//
cocos2d::CCArray ***__fastcall EditorUI::createSmartObjectsFromTemplate(
cocos2d::CCArray ***this,
GJSmartTemplate *a2,
cocos2d::CCArray *a3,
int a4,
bool a5,
bool a6,
bool a7)
{
cocos2d::CCArray ***v7; // r5
cocos2d::CCArray *v9; // r0
unsigned int v10; // r4
SmartGameObject *v11; // r0
SmartGameObject *v12; // r8
int v13; // r9
int v14; // r9
cocos2d::CCArray *v15; // r0
cocos2d::CCArray *v16; // r9
unsigned int i; // r8
int v18; // r11
unsigned int j; // r10
int v20; // r0
unsigned __int8 *v21; // r6
int v22; // r9
_DWORD *SmartNeighbor; // r9
cocos2d::CCArray *v24; // r8
unsigned int k; // r4
int v26; // r3
int v27; // r4
_BYTE *v28; // r6
int v29; // r2
SmartGameObject *v30; // r0
EditorUI *v31; // r0
cocos2d::CCArray *v32; // r1
UndoObject *v33; // r0
unsigned int m; // r7
GameObject *v35; // r0
UndoObject *v36; // r0
const cocos2d::CCPoint *v37; // r0
float v38; // s16
cocos2d::CCArray *v39; // [sp+24h] [bp-E0h]
cocos2d::CCDictionary *v40; // [sp+28h] [bp-DCh]
cocos2d::CCArray *v41; // [sp+2Ch] [bp-D8h]
cocos2d::CCDictionary *v42; // [sp+30h] [bp-D4h]
_DWORD *v45; // [sp+44h] [bp-C0h]
_DWORD *v46; // [sp+48h] [bp-BCh]
_DWORD *v47; // [sp+4Ch] [bp-B8h]
_DWORD *v48; // [sp+50h] [bp-B4h]
_DWORD *v49; // [sp+54h] [bp-B0h]
_DWORD *v50; // [sp+58h] [bp-ACh]
_DWORD *v51; // [sp+64h] [bp-A0h]
float v52[2]; // [sp+6Ch] [bp-98h] BYREF
_BYTE v53[12]; // [sp+74h] [bp-90h] BYREF
int v54[3]; // [sp+80h] [bp-84h] BYREF
int v55[3]; // [sp+8Ch] [bp-78h] BYREF
int v56[3]; // [sp+98h] [bp-6Ch] BYREF
int v57[3]; // [sp+A4h] [bp-60h] BYREF
_BYTE v58[16]; // [sp+B0h] [bp-54h] BYREF
float v59[4]; // [sp+C0h] [bp-44h] BYREF
int v60; // [sp+D0h] [bp-34h] BYREF
_BYTE v61[12]; // [sp+D4h] [bp-30h] BYREF
_BYTE v62[20]; // [sp+E0h] [bp-24h] BYREF
int v63; // [sp+F4h] [bp-10h]
char v64; // [sp+F8h] [bp-Ch]
char v65; // [sp+F9h] [bp-Bh]
v7 = this;
if ( a3 )
{
this = (cocos2d::CCArray ***)cocos2d::CCArray::count(a3);
if ( this )
{
if ( a2 )
{
if ( !a7 )
EditorBuildStats::noteAction((EditorBuildStats *)(v7[236] + 3026));
GJSmartTemplate::resetScannedPrefabs(a2);
v9 = (cocos2d::CCArray *)EditorUI::deselectAll((EditorUI *)v7);
v10 = 0;
v41 = (cocos2d::CCArray *)cocos2d::CCArray::create(v9);
v39 = (cocos2d::CCArray *)cocos2d::CCArray::create(v41);
v42 = (cocos2d::CCDictionary *)cocos2d::CCArray::create(v39);
v40 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create(v42);
while ( v10 < cocos2d::CCArray::count(a3) )
{
v11 = (SmartGameObject *)cocos2d::CCArray::objectAtIndex(a3, v10);
v12 = v11;
if ( (unsigned int)(*((_DWORD *)v11 + 223) - 2896) <= 1 )
GameObject::determineSlopeDirection(v11);
if ( a4 )
{
v13 = (*(int (__fastcall **)(SmartGameObject *))(*(_DWORD *)v12 + 96))(v12);
GJSmartTemplate::offsetForObject((GJSmartTemplate *)v59, v12);
cocos2d::CCPoint::operator+(v52, v13, v59);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v58, v52[0] - 37.5, v52[1] - 37.5, 75.0, 75.0);
v14 = (int)v7[236];
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v59, (const cocos2d::CCRect *)v58);
v15 = LevelEditorLayer::objectsInRect(v14, v59, 1);
v16 = v15;
if ( v15 )
{
if ( cocos2d::CCArray::count(v15) )
{
for ( i = 0; i < cocos2d::CCArray::count(v16); ++i )
{
v18 = cocos2d::CCArray::objectAtIndex(v16, i);
if ( *(_DWORD *)(v18 + 1084) == 5 && !cocos2d::CCArray::containsObject(a3, (cocos2d::CCObject *)v18) )
{
cocos2d::CCArray::addObject(a3, (cocos2d::CCObject *)v18);
cocos2d::CCDictionary::setObject(v40, (cocos2d::CCObject *)v18, *(_DWORD *)(v18 + 780));
(*(void (__fastcall **)(int, _DWORD))(*(_DWORD *)v18 + 36))(v18, *(unsigned __int8 *)(v18 + 1167));
*(_BYTE *)(v18 + 1167) = 1;
}
}
}
}
}
++v10;
}
for ( j = 0; j < cocos2d::CCArray::count(a3); ++j )
{
v20 = cocos2d::CCArray::objectAtIndex(a3, j);
v21 = (unsigned __int8 *)v20;
if ( *(_BYTE *)(v20 + 1167) )
{
if ( !cocos2d::CCDictionary::objectForKey(v40, *(_DWORD *)(v20 + 780)) )
cocos2d::CCArray::addObject(v39, (cocos2d::CCObject *)v21);
}
else
{
v22 = (*(int (__fastcall **)(int))(*(_DWORD *)v20 + 96))(v20);
GJSmartTemplate::offsetForObject((GJSmartTemplate *)v59, (SmartGameObject *)v21);
cocos2d::CCPoint::operator+(v52, v22, v59);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v59, (const cocos2d::CCPoint *)v52);
SmartNeighbor = EditorUI::getSmartNeighbor((int)v7, (int)v21, (int)v59, 1, a3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v59, (const cocos2d::CCPoint *)v52);
v45 = EditorUI::getSmartNeighbor((int)v7, (int)v21, (int)v59, 2, a3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v59, (const cocos2d::CCPoint *)v52);
v46 = EditorUI::getSmartNeighbor((int)v7, (int)v21, (int)v59, 3, a3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v59, (const cocos2d::CCPoint *)v52);
v47 = EditorUI::getSmartNeighbor((int)v7, (int)v21, (int)v59, 4, a3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v59, (const cocos2d::CCPoint *)v52);
v48 = EditorUI::getSmartNeighbor((int)v7, (int)v21, (int)v59, 5, a3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v59, (const cocos2d::CCPoint *)v52);
v49 = EditorUI::getSmartNeighbor((int)v7, (int)v21, (int)v59, 6, a3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v59, (const cocos2d::CCPoint *)v52);
v50 = EditorUI::getSmartNeighbor((int)v7, (int)v21, (int)v59, 7, a3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v59, (const cocos2d::CCPoint *)v52);
v51 = EditorUI::getSmartNeighbor((int)v7, (int)v21, (int)v59, 8, a3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v59, (const cocos2d::CCPoint *)v52);
GJSmartTemplate::keyFromNeighbors(v53, v59, v21, SmartNeighbor, v45, v46, v47, v48, v49, v50, v51);
std::string::basic_string(v54, (int)v53);
GJSmartTemplate::scanForPrefab(&v60, a2, v54);
std::string::~string((int)v54);
if ( v60 )
{
cocos2d::CCArray::addObject(v42, (cocos2d::CCObject *)v21);
std::string::basic_string(v55, (int)v62);
std::string::operator=(v21 + 1168, (unsigned __int8 *)v55);
std::string::~string((int)v55);
if ( !a7 )
{
std::string::basic_string(v56, v60 + 64);
v24 = (cocos2d::CCArray *)EditorUI::pasteObjects((int)v7, (int)v56);
std::string::~string((int)v56);
if ( v24 )
{
if ( cocos2d::CCArray::count(v24) )
{
v37 = (const cocos2d::CCPoint *)(*(int (__fastcall **)(unsigned __int8 *))(*(_DWORD *)v21 + 96))(v21);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v58, v37);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v59, (const cocos2d::CCPoint *)v58);
EditorUI::repositionObjectsToCenter(v7, v24, v59, 0);
if ( v65 )
EditorUI::flipObjectsY((EditorUI *)v7, v24);
if ( v64 )
EditorUI::flipObjectsX((EditorUI *)v7, v24);
if ( v63 > 0 )
{
v38 = (float)-v63;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v59, (const cocos2d::CCPoint *)&flt_D2B938);
EditorUI::rotateObjects(v7, v24, LODWORD(v38), v59, 0);
}
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v59, (const cocos2d::CCPoint *)v58);
EditorUI::repositionObjectsToCenter(v7, v24, v59, 0);
EditorUI::deleteSmartBlocksFromObjects((GJBaseGameLayer **)v7, v24);
cocos2d::CCArray::addObjectsFromArray(v41, v24);
cocos2d::CCArray::addObject(v39, (cocos2d::CCObject *)v21);
}
}
}
}
else
{
memset(v57, 0, sizeof(v57));
std::string::__init(v57, &unk_B6B226, 0);
std::string::operator=(v21 + 1168, (unsigned __int8 *)v57);
std::string::~string((int)v57);
}
std::string::~string((int)v62);
std::string::~string((int)v61);
std::string::~string((int)v53);
}
}
if ( a4 && v40 )
{
v26 = *((_DWORD *)v40 + 13);
if ( v26 )
v27 = *(_DWORD *)(v26 + 272);
else
v27 = 0;
while ( v26 )
{
v28 = *(_BYTE **)(v26 + 260);
v28[1167] = (*(int (__fastcall **)(_BYTE *))(*(_DWORD *)v28 + 32))(v28) != 0;
if ( v27 )
v29 = *(_DWORD *)(v27 + 272);
else
v29 = 0;
v26 = v27;
v27 = v29;
}
}
EditorUI::deselectAll((EditorUI *)v7);
if ( a6 )
{
for ( k = 0; k < cocos2d::CCArray::count(v42); ++k )
{
v30 = (SmartGameObject *)cocos2d::CCArray::objectAtIndex(v42, k);
*((_BYTE *)v30 + 1167) = 1;
SmartGameObject::updateSmartFrame(v30);
}
}
else if ( !a5 )
{
v33 = UndoObject::createWithArray(v39, 4);
LevelEditorLayer::addToUndoList(v7[236], v33, 0);
for ( m = 0; m < cocos2d::CCArray::count(v39); ++m )
{
v35 = (GameObject *)cocos2d::CCArray::objectAtIndex(v39, m);
EditorUI::deleteObject((EditorUI *)v7, v35, 1);
}
v32 = v41;
v31 = (EditorUI *)v7;
goto LABEL_54;
}
v31 = (EditorUI *)v7;
v32 = a3;
LABEL_54:
EditorUI::selectObjects(v31, v32, 1);
v36 = UndoObject::createWithArray(v41, 3);
LevelEditorLayer::addToUndoList(v7[236], v36, 0);
return (cocos2d::CCArray ***)EditorUI::updateSelectionUI((EditorUI *)v7);
}
}
}
return this;
}