//
// EditorUI::createSmartObjectsFromTemplate from 0x1003f16fc to 0x1003f1ea8 (1964 bytes)
//
// 2 xrefs:
// > SetupSmartBlockLayer::onCreate @ 0x10006fe04
// > SetupSmartBlockLayer::onPasteTemplate @ 0x100070070
//
// 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 __fastcall EditorUI::createSmartObjectsFromTemplate(
EditorUI *a1,
GJSmartTemplate *a2,
cocos2d::CCArray *a3,
bool a4,
bool a5,
bool a6,
bool a7)
{
_BOOL4 v7; // w20
_BOOL4 v9; // w28
int v13; // w0
unsigned int v14; // w23
GameObject *v15; // x0
SmartGameObject *v16; // x22
float32x2_t *v17; // x24
LevelEditorLayer *m_editorLayer; // x22
double v19; // d0
cocos2d::CCArray *v20; // x0
__int64 v21; // x22
unsigned int v22; // w24
__int64 v23; // x0
__int64 v24; // x25
unsigned int v25; // w23
__int64 v26; // x0
__int64 v27; // x24
float32x2_t *v28; // x22
EditorUI *v29; // x0
EditorUI *v30; // x0
SmartGameObject *v31; // x22
EditorUI *v32; // x0
SmartGameObject *v33; // x28
EditorUI *v34; // x0
SmartGameObject *v35; // x27
EditorUI *v36; // x0
SmartGameObject *v37; // x25
EditorUI *v38; // x0
SmartGameObject *v39; // x19
EditorUI *v40; // x0
SmartGameObject *v41; // x20
EditorUI *v42; // x0
SmartGameObject *v43; // x26
__int64 v44; // x0
cocos2d::CCArray *v45; // x0
cocos2d::CCArray *v46; // x26
__int64 *v47; // x0
int v48; // w19
cocos2d::CCDictElement *m_pElements; // x8
cocos2d::CCDictElement *next; // x20
cocos2d::CCObject *m_pObject; // x19
unsigned int v52; // w20
SmartGameObject *v53; // x0
EditorUI *v54; // x0
cocos2d::CCArray *v55; // x1
UndoObject *v56; // x0
unsigned int v57; // w20
GameObject *v58; // x0
UndoObject *v59; // x0
float v60; // s1
float v61; // s2
float v62; // s3
bool v63; // [xsp+10h] [xbp-190h]
_BOOL4 v64; // [xsp+14h] [xbp-18Ch]
cocos2d::CCArray *v65; // [xsp+18h] [xbp-188h]
cocos2d::CCArray *v66; // [xsp+20h] [xbp-180h]
cocos2d::CCObject *v67; // [xsp+28h] [xbp-178h]
_BOOL4 v69; // [xsp+34h] [xbp-16Ch]
EditorUI *v70; // [xsp+38h] [xbp-168h]
GJSmartTemplate *v71; // [xsp+40h] [xbp-160h]
SmartGameObject *SmartNeighbor; // [xsp+48h] [xbp-158h]
cocos2d::CCDictionary *v73; // [xsp+50h] [xbp-150h]
std::string __str; // [xsp+58h] [xbp-148h] BYREF
__int64 v75; // [xsp+70h] [xbp-130h] BYREF
__int64 v76; // [xsp+78h] [xbp-128h] BYREF
std::string __s; // [xsp+80h] [xbp-120h] BYREF
std::string __dst; // [xsp+A0h] [xbp-100h] BYREF
std::string __p; // [xsp+C0h] [xbp-E0h] BYREF
__int128 v80; // [xsp+E0h] [xbp-C0h] BYREF
char v81; // [xsp+FFh] [xbp-A1h]
std::string v82; // [xsp+100h] [xbp-A0h]
int v83; // [xsp+120h] [xbp-80h]
char v84; // [xsp+124h] [xbp-7Ch]
char v85; // [xsp+125h] [xbp-7Bh]
std::string v86; // [xsp+128h] [xbp-78h] BYREF
float32x2_t v87; // [xsp+140h] [xbp-60h] BYREF
cocos2d::CCRect v88; // 0:kr10_16.16
cocos2d::CCPoint v89; // 0:s0.4,4:s1.4
cocos2d::CCPoint v90; // 0:s0.4,4:s1.4
cocos2d::CCPoint v91; // 0:s0.4,4:s1.4
cocos2d::CCPoint v92; // 0:s0.4,4:s1.4
cocos2d::CCPoint v93; // 0:s0.4,4:s1.4
cocos2d::CCPoint v94; // 0:s0.4,4:s1.4
cocos2d::CCPoint v95; // 0:s0.4,4:s1.4
cocos2d::CCPoint v96; // 0:s0.4,4:s1.4
cocos2d::CCPoint v97; // 0:s0.4,4:s1.4
cocos2d::CCPoint v98; // 0:s0.4,4:s1.4
cocos2d::CCPoint v99; // 0:s1.4,4:s2.4
if ( a3 )
{
v7 = a6;
v9 = a4;
v13 = sub_10024A36C((__int64)a3);
if ( a2 )
{
if ( v13 )
{
v63 = a5;
v64 = v7;
v71 = a2;
GJSmartTemplate::resetScannedPrefabs(a2);
EditorUI::deselectAll(a1);
v65 = (cocos2d::CCArray *)sub_10024A15C();
v66 = (cocos2d::CCArray *)sub_10024A15C();
v67 = sub_10024A15C();
v73 = cocos2d::CCDictionary::create();
if ( (unsigned int)sub_10024A36C((__int64)a3) )
{
v14 = 0;
do
{
v15 = (GameObject *)sub_10024A388((__int64)a3, v14);
v16 = (SmartGameObject *)v15;
if ( (v15->m_objectID & 0xFFFFFFFE) == 0xB50 )
GameObject::determineSlopeDirection(v15);
if ( v9 )
{
v17 = (float32x2_t *)((__int64 (__fastcall *)(SmartGameObject *))v16->getPosition)(v16);
GJSmartTemplate::offsetForObject(v16);
sub_1000229DC(v17, (float32x2_t *)&v80, &v87);
sub_100022990((float *)&v80, v87.f32[0] + -37.5, v87.f32[1] + -37.5, 75.0, 75.0);
m_editorLayer = a1->m_editorLayer;
v19 = sub_100022B98(&v86, (__int64)&v80);
v88.origin.x = *(float *)&v19;
v88.origin.y = v60;
v88.size.width = v61;
v88.size.height = v62;
v20 = LevelEditorLayer::objectsInRect(m_editorLayer, v88, (bool)&v86);
if ( v20 )
{
v21 = (__int64)v20;
if ( (unsigned int)sub_10024A36C((__int64)v20) )
{
if ( (unsigned int)sub_10024A36C(v21) )
{
v22 = 0;
do
{
v23 = sub_10024A388(v21, v22);
if ( *(_DWORD *)(v23 + 1248) == 5 )
{
v24 = v23;
if ( (sub_10024A420((__int64)a3, v23) & 1) == 0 )
{
sub_10024A2D0((__int64)a3);
cocos2d::CCDictionary::setObject(v73, (cocos2d::CCObject *)v24, *(unsigned int *)(v24 + 916));
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v24 + 72LL))(
v24,
*(unsigned __int8 *)(v24 + 1347));
*(_BYTE *)(v24 + 1347) = 1;
}
}
++v22;
}
while ( v22 < (unsigned int)sub_10024A36C(v21) );
}
}
}
}
++v14;
}
while ( v14 < (unsigned int)sub_10024A36C((__int64)a3) );
}
if ( (unsigned int)sub_10024A36C((__int64)a3) )
{
v25 = 0;
v70 = a1;
v69 = v9;
while ( 1 )
{
v26 = sub_10024A388((__int64)a3, v25);
v27 = v26;
if ( (*(_BYTE *)(v26 + 1347) & 1) == 0 )
break;
if ( !cocos2d::CCDictionary::objectForKey(v73, *(unsigned int *)(v26 + 916)) )
sub_10024A2D0((__int64)v66);
LABEL_58:
if ( ++v25 >= (unsigned int)sub_10024A36C((__int64)a3) )
goto LABEL_59;
}
v28 = (float32x2_t *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v26 + 192LL))(v26);
GJSmartTemplate::offsetForObject((SmartGameObject *)v27);
sub_1000229DC(v28, (float32x2_t *)&v80, &v87);
v89.x = sub_1000229B8((__int64 *)&v80, (__int64 *)&v87);
SmartNeighbor = EditorUI::getSmartNeighbor(
v29,
(SmartGameObject *)v27,
v89,
(GJSmartDirection)&v80,
(cocos2d::CCArray *)1);
v90.x = sub_1000229B8((__int64 *)&v80, (__int64 *)&v87);
v31 = EditorUI::getSmartNeighbor(
v30,
(SmartGameObject *)v27,
v90,
(GJSmartDirection)&v80,
(cocos2d::CCArray *)2);
v91.x = sub_1000229B8((__int64 *)&v80, (__int64 *)&v87);
v33 = EditorUI::getSmartNeighbor(
v32,
(SmartGameObject *)v27,
v91,
(GJSmartDirection)&v80,
(cocos2d::CCArray *)3);
v92.x = sub_1000229B8((__int64 *)&v80, (__int64 *)&v87);
v35 = EditorUI::getSmartNeighbor(
v34,
(SmartGameObject *)v27,
v92,
(GJSmartDirection)&v80,
(cocos2d::CCArray *)4);
v93.x = sub_1000229B8((__int64 *)&v80, (__int64 *)&v87);
v37 = EditorUI::getSmartNeighbor(
v36,
(SmartGameObject *)v27,
v93,
(GJSmartDirection)&v80,
(cocos2d::CCArray *)5);
v94.x = sub_1000229B8((__int64 *)&v80, (__int64 *)&v87);
v39 = EditorUI::getSmartNeighbor(
v38,
(SmartGameObject *)v27,
v94,
(GJSmartDirection)&v80,
(cocos2d::CCArray *)6);
v95.x = sub_1000229B8((__int64 *)&v80, (__int64 *)&v87);
v41 = EditorUI::getSmartNeighbor(
v40,
(SmartGameObject *)v27,
v95,
(GJSmartDirection)&v80,
(cocos2d::CCArray *)7);
v96.x = sub_1000229B8((__int64 *)&v80, (__int64 *)&v87);
v43 = EditorUI::getSmartNeighbor(
v42,
(SmartGameObject *)v27,
v96,
(GJSmartDirection)&v80,
(cocos2d::CCArray *)8);
sub_1000229B8((__int64 *)&v80, (__int64 *)&v87);
GJSmartTemplate::keyFromNeighbors(
v44,
(SmartGameObject *)v27,
SmartNeighbor,
v31,
v33,
v35,
v37,
v39,
&v86,
v41,
v43);
if ( SHIBYTE(v86.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&__p, v86.__r_.__value_.__l.__data_, v86.__r_.__value_.__l.__size_);
else
__p = v86;
GJSmartTemplate::scanForPrefab(v71, (std::string::size_type)&__p, &v80);
a1 = v70;
v9 = v69;
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__p.__r_.__value_.__l.__data_);
if ( !(_QWORD)v80 )
{
sub_100009900(&__str, "");
std::string::operator=((std::string *)(v27 + 1352), &__str);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
goto LABEL_52;
}
sub_10024A2D0((__int64)v67);
if ( SHIBYTE(v82.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&__dst, v82.__r_.__value_.__l.__data_, v82.__r_.__value_.__l.__size_);
else
__dst = v82;
std::string::operator=((std::string *)(v27 + 1352), &__dst);
if ( SHIBYTE(__dst.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
if ( !a7 )
{
if ( *(char *)(v80 + 103) < 0 )
sub_1000097D0(&__s, *(void **)(v80 + 80), *(_QWORD *)(v80 + 88));
else
__s = *(std::string *)(v80 + 80);
v45 = EditorUI::pasteObjects((__int64)v70, &__s, 0, 1);
v46 = v45;
if ( (SHIBYTE(__s.__r_.__value_.__r.__words[2]) & 0x80000000) == 0 )
{
if ( !v45 )
goto LABEL_52;
LABEL_44:
if ( (unsigned int)sub_10024A36C((__int64)v46) )
{
v47 = (__int64 *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v27 + 192LL))(v27);
sub_1000229B8(&v76, v47);
v97.x = sub_1000229B8(&v75, &v76);
EditorUI::repositionObjectsToCenter(v70, v46, v97, (bool)&v75);
if ( v85 == 1 )
EditorUI::flipObjectsY(v70, v46);
if ( v84 == 1 )
EditorUI::flipObjectsX(v70, v46);
v48 = v83;
if ( v83 >= 1 )
{
sub_1000229B8(&v75, (__int64 *)&dword_10086E8B0);
EditorUI::rotateObjects(v70, v46, (float)-v48, v99);
}
v98.x = sub_1000229B8(&v75, &v76);
EditorUI::repositionObjectsToCenter(v70, v46, v98, (bool)&v75);
EditorUI::deleteSmartBlocksFromObjects(v70, v46);
sub_10024A360((__int64)v65, (__int64)v46);
sub_10024A2D0((__int64)v66);
}
goto LABEL_52;
}
operator delete(__s.__r_.__value_.__l.__data_);
if ( v46 )
goto LABEL_44;
}
LABEL_52:
if ( SHIBYTE(v82.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v82.__r_.__value_.__l.__data_);
if ( v81 < 0 )
operator delete(*((void **)&v80 + 1));
if ( SHIBYTE(v86.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v86.__r_.__value_.__l.__data_);
goto LABEL_58;
}
LABEL_59:
if ( v9 )
{
if ( v73 )
{
m_pElements = v73->m_pElements;
if ( m_pElements )
{
do
{
next = (cocos2d::CCDictElement *)m_pElements->hh.next;
m_pObject = m_pElements->m_pObject;
BYTE3(m_pObject[24].__vftable) = ((unsigned int (__fastcall *)(cocos2d::CCObject *))m_pObject->getTag)(m_pObject) != 0;
m_pElements = next;
}
while ( next );
}
}
}
EditorUI::deselectAll(a1);
if ( v64 )
{
if ( (unsigned int)sub_10024A36C((__int64)v67) )
{
v52 = 0;
do
{
v53 = (SmartGameObject *)sub_10024A388((__int64)v67, v52);
v53->m_referenceOnly = 1;
SmartGameObject::updateSmartFrame(v53);
++v52;
}
while ( v52 < (unsigned int)sub_10024A36C((__int64)v67) );
}
}
else if ( !v63 )
{
v56 = UndoObject::createWithArray(v66, DeleteMulti);
LevelEditorLayer::addToUndoList(a1->m_editorLayer, v56, 0);
if ( (unsigned int)sub_10024A36C((__int64)v66) )
{
v57 = 0;
do
{
v58 = (GameObject *)sub_10024A388((__int64)v66, v57);
EditorUI::deleteObject(a1, v58, 1);
++v57;
}
while ( v57 < (unsigned int)sub_10024A36C((__int64)v66) );
}
v54 = a1;
v55 = v65;
goto LABEL_74;
}
v54 = a1;
v55 = a3;
LABEL_74:
EditorUI::selectObjects(v54, v55, 1);
v59 = UndoObject::createWithArray(v65, Paste);
LevelEditorLayer::addToUndoList(a1->m_editorLayer, v59, 0);
EditorUI::updateButtons(a1);
EditorUI::updateObjectInfoLabel(a1);
((void (__fastcall *)(EditorUI *))a1->updateScaleControl)(a1);
}
}
}
}