//
// EditorUI::addObjectsToSmartTemplate from 0x140115c30 to 0x140116e14 (4580 bytes)
//
// 2 xrefs:
// > SetupSmartBlockLayer::onCreateTemplate @ 0x140458999
// > ??> @ 0x1406c92d0
//
// 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
//
// Hidden C++ exception states: #wind=8
void EditorUI::addObjectsToSmartTemplate(EditorUI *a1, GJSmartTemplate *a2, cocos2d::CCArray *a3)
{
cocos2d::CCArray *v3; // rsi
GJSmartTemplate *v4; // r15
cocos2d::CCDictionary *v5; // r14
unsigned int v6; // edi
struct cocos2d::CCObject *v7; // rax
GameObject *v8; // rbx
cocos2d::CCObjectType m_eObjType; // eax
unsigned int v10; // ebx
SmartGameObject *v11; // r14
cocos2d::CCArray *v12; // r15
cocos2d::CCPoint v13; // rax
__int64 v14; // rax
__int64 v15; // rax
int v16; // eax
const struct cocos2d::CCPoint *v17; // rdx
cocos2d::CCPoint v18; // rax
EditorUI *v19; // rcx
SmartGameObject *SmartNeighbor; // rbx
cocos2d::CCPoint v21; // rax
EditorUI *v22; // rcx
cocos2d::CCPoint v23; // rax
EditorUI *v24; // rcx
cocos2d::CCPoint v25; // rax
EditorUI *v26; // rcx
cocos2d::CCPoint v27; // rax
EditorUI *v28; // rcx
cocos2d::CCPoint v29; // rax
EditorUI *v30; // rcx
cocos2d::CCPoint v31; // rax
EditorUI *v32; // rcx
cocos2d::CCPoint v33; // rax
EditorUI *v34; // rcx
bool v35; // r14
bool v36; // di
int v37; // r8d
bool v38; // bl
bool v39; // si
bool v40; // r12
bool v41; // r13
int v42; // eax
SmartGameObject *v43; // rcx
SmartGameObject *v44; // r11
float height; // xmm0_4
float width; // xmm1_4
cocos2d::CCRect *v47; // rax
struct cocos2d::CCArray *v48; // rax
int v49; // eax
int v50; // eax
__int64 v51; // rbx
void *v52; // rcx
__m128i v53; // xmm1
EditorUI *v54; // r13
cocos2d::CCArray *v55; // rax
cocos2d::CCArray *v56; // rsi
unsigned int v57; // ebx
struct cocos2d::CCObject *v58; // rdi
unsigned int v59; // edi
struct cocos2d::CCObject *v60; // rax
struct cocos2d::CCObject *v61; // rbx
const struct cocos2d::CCPoint *v62; // rax
const struct cocos2d::CCPoint *v63; // r8
const struct cocos2d::CCPoint *v64; // r8
float v65; // xmm0_4
float v66; // xmm6_4
int m_unknown2; // eax
int v68; // eax
float v69; // xmm8_4
ObjectToolbox *v70; // rcx
const struct cocos2d::CCPoint *v71; // r8
float v72; // xmm8_4
ObjectToolbox *v73; // rcx
const struct cocos2d::CCPoint *v74; // r8
float v75; // xmm8_4
ObjectToolbox *v76; // rcx
const struct cocos2d::CCPoint *v77; // r8
float v78; // xmm8_4
ObjectToolbox *v79; // rcx
const struct cocos2d::CCPoint *v80; // r8
float v81; // xmm8_4
ObjectToolbox *v82; // rcx
const struct cocos2d::CCPoint *v83; // r8
float v84; // xmm8_4
ObjectToolbox *v85; // rcx
const struct cocos2d::CCPoint *v86; // r8
float v87; // xmm8_4
ObjectToolbox *v88; // rcx
const struct cocos2d::CCPoint *v89; // r8
float v90; // xmm8_4
ObjectToolbox *v91; // rcx
const struct cocos2d::CCPoint *v92; // r8
cocos2d::CCPoint v93; // rax
GameObject *Object; // rsi
GameObject_vtbl *v95; // rbx
GameObject_vtbl *v96; // rbx
bool v97; // al
GameObject_vtbl *v98; // rbx
bool v99; // al
EditorUI *v100; // rcx
size_t v101; // r14
unsigned __int64 v102; // r12
cocos2d::ccArray *data; // rdi
__int64 num; // rax
cocos2d::CCObject **arr; // rdi
cocos2d::CCObject **v106; // r15
cocos2d::CCObject *v107; // rbx
const struct cocos2d::CCPoint *v108; // rax
__int64 v109; // rax
void **v110; // rdx
LevelEditorLayer *m_editorLayer; // rbx
_BOOL8 v112; // rdx
__int64 v113; // rdx
__int64 v114; // rcx
__int64 v115; // r8
__int64 v116; // r9
void **v117; // rdi
unsigned __int64 v118; // rbx
std::string *v119; // rsi
__int64 v120; // rcx
cocos2d::CCArray *v121; // rdi
unsigned int v122; // ebx
struct cocos2d::CCObject *v123; // rax
GJSmartPrefab *v124; // rbx
__int128 *v125; // rdx
std::string *m_bigStorage; // rdx
__int64 v127; // rax
bool v128; // [rsp+60h] [rbp-A0h]
bool v129; // [rsp+61h] [rbp-9Fh]
bool v130; // [rsp+62h] [rbp-9Eh]
bool v131; // [rsp+63h] [rbp-9Dh]
bool v132; // [rsp+64h] [rbp-9Ch]
bool v133; // [rsp+65h] [rbp-9Bh]
char v134; // [rsp+66h] [rbp-9Ah]
char v135; // [rsp+67h] [rbp-99h]
char v136; // [rsp+68h] [rbp-98h]
cocos2d::CCPoint v137; // [rsp+70h] [rbp-90h] BYREF
char v138[8]; // [rsp+78h] [rbp-88h] BYREF
cocos2d::CCPoint v139; // [rsp+80h] [rbp-80h] BYREF
int v140; // [rsp+88h] [rbp-78h]
int v141; // [rsp+8Ch] [rbp-74h]
cocos2d::CCRect v142; // [rsp+90h] [rbp-70h] BYREF
int v143; // [rsp+A0h] [rbp-60h]
int v144; // [rsp+A4h] [rbp-5Ch]
int v145; // [rsp+A8h] [rbp-58h]
unsigned int i; // [rsp+ACh] [rbp-54h]
SmartGameObject *v147; // [rsp+B0h] [rbp-50h]
EditorUI *v148; // [rsp+B8h] [rbp-48h]
unsigned __int64 v149; // [rsp+C0h] [rbp-40h]
SmartGameObject *p_Buf2; // [rsp+C8h] [rbp-38h]
float v151[2]; // [rsp+D0h] [rbp-30h] BYREF
__int128 Buf2; // [rsp+D8h] [rbp-28h] BYREF
size_t Size; // [rsp+E8h] [rbp-18h]
unsigned __int64 v154; // [rsp+F0h] [rbp-10h]
GJSmartTemplate *v155; // [rsp+F8h] [rbp-8h]
SmartGameObject *v156; // [rsp+100h] [rbp+0h]
SmartGameObject *v157; // [rsp+108h] [rbp+8h]
SmartGameObject *v158; // [rsp+110h] [rbp+10h]
cocos2d::CCPoint v159; // [rsp+118h] [rbp+18h] BYREF
SmartGameObject *v160; // [rsp+120h] [rbp+20h]
SmartGameObject *v161; // [rsp+128h] [rbp+28h]
SmartGameObject *v162; // [rsp+130h] [rbp+30h]
SmartGameObject *v163; // [rsp+138h] [rbp+38h]
cocos2d::CCDictionary *v164; // [rsp+140h] [rbp+40h]
cocos2d::CCArray *v165; // [rsp+148h] [rbp+48h]
cocos2d::CCDictionary *v166; // [rsp+150h] [rbp+50h]
cocos2d::CCPoint v167; // [rsp+158h] [rbp+58h] BYREF
struct cocos2d::CCPoint v168; // [rsp+160h] [rbp+60h] BYREF
cocos2d::CCPoint v169; // [rsp+168h] [rbp+68h] BYREF
struct cocos2d::CCPoint v170; // [rsp+170h] [rbp+70h] BYREF
cocos2d::CCPoint v171; // [rsp+178h] [rbp+78h] BYREF
struct cocos2d::CCPoint v172; // [rsp+180h] [rbp+80h] BYREF
cocos2d::CCPoint v173; // [rsp+188h] [rbp+88h] BYREF
struct cocos2d::CCPoint v174; // [rsp+190h] [rbp+90h] BYREF
cocos2d::CCPoint v175; // [rsp+198h] [rbp+98h] BYREF
struct cocos2d::CCPoint v176; // [rsp+1A0h] [rbp+A0h] BYREF
cocos2d::CCPoint v177; // [rsp+1A8h] [rbp+A8h] BYREF
struct cocos2d::CCPoint v178; // [rsp+1B0h] [rbp+B0h] BYREF
cocos2d::CCPoint v179; // [rsp+1B8h] [rbp+B8h] BYREF
struct cocos2d::CCPoint v180; // [rsp+1C0h] [rbp+C0h] BYREF
cocos2d::CCPoint v181; // [rsp+1C8h] [rbp+C8h] BYREF
struct cocos2d::CCPoint v182; // [rsp+1D0h] [rbp+D0h] BYREF
cocos2d::CCArray v183; // [rsp+1D8h] [rbp+D8h] BYREF
cocos2d::CCPoint v184; // [rsp+218h] [rbp+118h] BYREF
cocos2d::CCPoint v185; // [rsp+220h] [rbp+120h] BYREF
cocos2d::CCPoint v186; // [rsp+228h] [rbp+128h] BYREF
cocos2d::CCPoint v187; // [rsp+230h] [rbp+130h] BYREF
cocos2d::CCPoint v188; // [rsp+238h] [rbp+138h] BYREF
char v189[8]; // [rsp+240h] [rbp+140h] BYREF
cocos2d::CCPoint v190; // [rsp+248h] [rbp+148h] BYREF
cocos2d::CCPoint v191; // [rsp+250h] [rbp+150h] BYREF
cocos2d::CCRect v192; // [rsp+258h] [rbp+158h] BYREF
void *Src[2]; // [rsp+268h] [rbp+168h] BYREF
size_t v194; // [rsp+278h] [rbp+178h]
__int64 v195; // [rsp+280h] [rbp+180h]
__int128 v196; // [rsp+288h] [rbp+188h] BYREF
__m128i v197; // [rsp+298h] [rbp+198h]
void *v198[4]; // [rsp+2A8h] [rbp+1A8h] BYREF
_BYTE v199[32]; // [rsp+2C8h] [rbp+1C8h] BYREF
if ( a2 )
{
v3 = a3;
v165 = a3;
v4 = a2;
v155 = a2;
v148 = a1;
v140 = 0;
v164 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create();
v5 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create();
v166 = v5;
v6 = 0;
while ( v6 < cocos2d::CCArray::count(v3) )
{
v7 = cocos2d::CCArray::objectAtIndex(v3, v6);
v8 = (GameObject *)v7;
if ( v7[22].m_uAutoReleaseCount == 5 )
{
m_eObjType = v7[18].m_eObjType;
if ( m_eObjType == 2896 || m_eObjType == 2897 )
GameObject::determineSlopeDirection(v8);
if ( v8->m_linkedGroup > 0 )
cocos2d::CCDictionary::setObject(v5, v8, v8->m_linkedGroup);
++v6;
}
else
{
cocos2d::CCArray::removeObjectAtIndex(v3, v6, 1);
}
}
v10 = 0;
for ( i = 0; v10 < cocos2d::CCArray::count(v3); i = v10 )
{
v11 = (SmartGameObject *)cocos2d::CCArray::objectAtIndex(v3, v10);
p_Buf2 = v11;
if ( !v11->m_referenceOnly )
{
v12 = nullptr;
cocos2d::CCPoint::CCPoint(&v190, (const struct cocos2d::CCPoint *)&dword_1406C1AA8);
GJSmartTemplate::smartObjectToType(v11, v13);
GJSmartTemplate::offsetForType((SmartBlockType)v151);
v14 = (__int64)v11->getPosition_0(v11);
cocos2d::CCPoint::operator+(v14, v138);
cocos2d::CCPoint::CCPoint(&v159);
v145 = 1;
if ( v151[0] == *(float *)&dword_1406C1AA8 && v151[1] == *(float *)&dword_1406C1AAC )
{
v136 = 0;
}
else
{
v136 = 1;
v145 = 2;
cocos2d::CCPoint::operator-(v151, &v183.m_uAutoReleaseCount);
v15 = (__int64)v11->getPosition_0(v11);
cocos2d::CCPoint::operator+(v15, &v183.m_uIndexInArray);
cocos2d::CCPoint::operator=(&v159, &v183.m_uIndexInArray);
}
v196 = 0;
v197.m128i_i64[0] = 0;
v149 = 15;
v197.m128i_i64[1] = 15;
LOBYTE(v196) = 0;
v16 = 0;
v141 = 0;
do
{
v17 = (const struct cocos2d::CCPoint *)v138;
if ( v16 )
v17 = &v159;
cocos2d::CCPoint::CCPoint(&v137, v17);
cocos2d::CCPoint::CCPoint(&v191, &v137);
SmartNeighbor = EditorUI::getSmartNeighbor(v19, v11, v18, (GJSmartDirection)1, v3);
v158 = SmartNeighbor;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v183.m_unknown2, &v137);
v156 = EditorUI::getSmartNeighbor(v22, v11, v21, (GJSmartDirection)2, v3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v183.m_uOrderOfArrival, &v137);
v163 = EditorUI::getSmartNeighbor(v24, v11, v23, (GJSmartDirection)3, v3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v183.data, &v137);
v162 = EditorUI::getSmartNeighbor(v26, v11, v25, (GJSmartDirection)4, v3);
cocos2d::CCPoint::CCPoint(&v184, &v137);
v161 = EditorUI::getSmartNeighbor(v28, v11, v27, TopLeft, v3);
cocos2d::CCPoint::CCPoint(&v185, &v137);
v147 = EditorUI::getSmartNeighbor(v30, v11, v29, TopRight, v3);
cocos2d::CCPoint::CCPoint(&v186, &v137);
v157 = EditorUI::getSmartNeighbor(v32, v11, v31, BottomLeft, v3);
cocos2d::CCPoint::CCPoint(&v187, &v137);
v43 = EditorUI::getSmartNeighbor(v34, v11, v33, BottomRight, v3);
v160 = v43;
v35 = SmartNeighbor != nullptr;
v36 = v156 != nullptr;
v37 = (int)v163;
v38 = v163 != nullptr;
v39 = v162 != nullptr;
v40 = v161 != nullptr;
v41 = v147 != nullptr;
v42 = (int)v157;
LOBYTE(v42) = v157 != nullptr;
v143 = v42;
LOBYTE(v43) = v43 != nullptr;
v144 = (int)v43;
v44 = v147;
if ( v158 )
{
if ( v158->m_referenceOnly )
v35 = 0;
v44 = v147;
}
if ( v156 && v156->m_referenceOnly )
v36 = 0;
if ( v163 )
{
v37 = 0;
if ( v163->m_referenceOnly )
v38 = 0;
}
if ( v162 && v162->m_referenceOnly )
v39 = v37;
if ( v161 && v161->m_referenceOnly )
v40 = v37;
if ( v44 && v44->m_referenceOnly )
v41 = v37;
if ( v157 )
{
v42 = (unsigned __int8)v42;
if ( v157->m_referenceOnly )
v42 = v37;
v143 = v42;
}
if ( v160 )
{
LODWORD(v43) = (unsigned __int8)v43;
if ( v160->m_referenceOnly )
LODWORD(v43) = v37;
v144 = (int)v43;
}
cocos2d::CCRect::CCRect(&v142, v137.x - 14.0, v137.y - 14.0, 28.0, 28.0);
height = v142.size.height;
if ( !v35 )
{
height = v142.size.height + 14.0;
v142.size.height = v142.size.height + 14.0;
}
if ( !v36 )
{
v142.size.height = height + 14.0;
v142.origin.y = v142.origin.y + -14.0;
}
width = v142.size.width;
if ( !v38 )
{
width = v142.size.width + 14.0;
v142.size.width = v142.size.width + 14.0;
v142.origin.x = v142.origin.x + -14.0;
}
if ( !v39 )
v142.size.width = width + 14.0;
v47 = (cocos2d::CCRect *)cocos2d::CCRect::CCRect(&v192, &v142);
v48 = LevelEditorLayer::objectsInRect(v148->m_editorLayer, v47, 1);
if ( v12 )
{
if ( v48 )
cocos2d::CCArray::addObjectsFromArray(v12, v48);
}
else
{
v12 = v48;
}
v49 = v141;
if ( v141 )
{
v11 = p_Buf2;
}
else
{
v128 = v35;
v129 = v36;
v130 = v38;
v131 = v39;
v132 = v40;
v133 = v41;
v134 = v143;
v135 = v144;
cocos2d::CCPoint::CCPoint(&v188, &v137);
v11 = p_Buf2;
v51 = GJSmartTemplate::keyFromNeighbors(
(unsigned int)v198,
v50,
(_DWORD)p_Buf2,
(_DWORD)v158,
(__int64)v156,
(__int64)v163,
(__int64)v162,
(__int64)v161,
(__int64)v147,
(__int64)v157,
(__int64)v160);
if ( &v196 != (__int128 *)v51 )
{
if ( v149 > 0xF )
{
v52 = (void *)v196;
if ( v149 + 1 >= 0x1000 )
{
v52 = *(void **)(v196 - 8);
if ( (unsigned __int64)(v196 - (_QWORD)v52 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v52);
}
v196 = *(_OWORD *)v51;
v197 = *(__m128i *)(v51 + 16);
v53 = v197;
*(_QWORD *)(v51 + 16) = 0;
*(_QWORD *)(v51 + 24) = 15;
*(_BYTE *)v51 = 0;
v149 = _mm_srli_si128(v53, 8).m128i_u64[0];
}
sub_14003A830((__int64)v198);
v49 = v141;
}
v16 = v49 + 1;
v141 = v16;
v3 = v165;
}
while ( v16 < v145 );
v54 = v148;
if ( v11->m_linkedGroup > 0 )
{
v55 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(
v148->m_editorLayer->m_linkedGroupDict,
v11->m_linkedGroup);
v56 = v55;
if ( v55 )
{
v57 = 0;
if ( cocos2d::CCArray::count(v55) )
{
do
{
v58 = cocos2d::CCArray::objectAtIndex(v56, v57);
if ( !cocos2d::CCArray::containsObject(v12, v58) )
cocos2d::CCArray::addObject(v12, v58);
++v57;
}
while ( v57 < cocos2d::CCArray::count(v56) );
}
}
}
if ( !v12 )
goto LABEL_160;
v59 = 0;
if ( cocos2d::CCArray::count(v12) )
{
do
{
v60 = cocos2d::CCArray::objectAtIndex(v12, v59);
v61 = v60;
if ( v60[22].m_uAutoReleaseCount == 5
|| cocos2d::CCDictionary::objectForKey(v164, (unsigned int)v60[16].m_eObjType) )
{
goto LABEL_120;
}
v62 = (const struct cocos2d::CCPoint *)((__int64 (__fastcall *)(struct cocos2d::CCObject *))v61->__vftable[2].getTag)(v61);
cocos2d::CCPoint::CCPoint(&v139, v62);
v65 = cocos2d::ccpDistance((cocos2d *)v138, &v139, v63);
v66 = v65;
if ( v136 )
v66 = fminf(v65, cocos2d::ccpDistance((cocos2d *)&v159, &v139, v64));
m_unknown2 = v61[15].m_unknown2;
if ( m_unknown2 > 0
&& m_unknown2 != v11->m_linkedGroup
&& cocos2d::CCDictionary::objectForKey(v166, v61[15].m_unknown2) )
{
goto LABEL_120;
}
v68 = v61[15].m_unknown2;
if ( v68 && v68 == v11->m_linkedGroup )
goto LABEL_119;
if ( v128 )
{
v69 = 30.0;
ObjectToolbox::sharedState();
if ( ObjectToolbox::gridNodeSizeForKey(v70, 0) == 15.0 )
v69 = 15.0;
cocos2d::CCPoint::CCPoint(&v167, 0.0, v69);
cocos2d::CCPoint::operator+(v138, &v168);
if ( v66 > cocos2d::ccpDistance((cocos2d *)&v139, &v168, v71) )
goto LABEL_120;
}
if ( v129 )
{
v72 = 30.0;
ObjectToolbox::sharedState();
if ( ObjectToolbox::gridNodeSizeForKey(v73, 0) == 15.0 )
v72 = 15.0;
cocos2d::CCPoint::CCPoint(&v169, 0.0, -v72);
cocos2d::CCPoint::operator+(v138, &v170);
if ( v66 > cocos2d::ccpDistance((cocos2d *)&v139, &v170, v74) )
goto LABEL_120;
}
if ( v130 )
{
v75 = 30.0;
ObjectToolbox::sharedState();
if ( ObjectToolbox::gridNodeSizeForKey(v76, 0) == 15.0 )
v75 = 15.0;
cocos2d::CCPoint::CCPoint(&v171, -v75, 0.0);
cocos2d::CCPoint::operator+(v138, &v172);
if ( v66 > cocos2d::ccpDistance((cocos2d *)&v139, &v172, v77) )
goto LABEL_120;
}
if ( v131 )
{
v78 = 30.0;
ObjectToolbox::sharedState();
if ( ObjectToolbox::gridNodeSizeForKey(v79, 0) == 15.0 )
v78 = 15.0;
cocos2d::CCPoint::CCPoint(&v173, v78, 0.0);
cocos2d::CCPoint::operator+(v138, &v174);
if ( v66 > cocos2d::ccpDistance((cocos2d *)&v139, &v174, v80) )
goto LABEL_120;
}
if ( v132 )
{
v81 = 30.0;
ObjectToolbox::sharedState();
if ( ObjectToolbox::gridNodeSizeForKey(v82, 0) == 15.0 )
v81 = 15.0;
cocos2d::CCPoint::CCPoint(&v175, -v81, v81);
cocos2d::CCPoint::operator+(v138, &v176);
if ( v66 > cocos2d::ccpDistance((cocos2d *)&v139, &v176, v83) )
goto LABEL_120;
}
if ( v133 )
{
v84 = 30.0;
ObjectToolbox::sharedState();
if ( ObjectToolbox::gridNodeSizeForKey(v85, 0) == 15.0 )
v84 = 15.0;
cocos2d::CCPoint::CCPoint(&v177, v84, v84);
cocos2d::CCPoint::operator+(v138, &v178);
if ( v66 > cocos2d::ccpDistance((cocos2d *)&v139, &v178, v86) )
goto LABEL_120;
}
if ( v134 )
{
v87 = 30.0;
ObjectToolbox::sharedState();
if ( ObjectToolbox::gridNodeSizeForKey(v88, 0) == 15.0 )
v87 = 15.0;
cocos2d::CCPoint::CCPoint(&v179, -v87, -v87);
cocos2d::CCPoint::operator+(v138, &v180);
if ( v66 > cocos2d::ccpDistance((cocos2d *)&v139, &v180, v89) )
goto LABEL_120;
}
if ( !v135 )
goto LABEL_119;
v90 = 30.0;
ObjectToolbox::sharedState();
if ( ObjectToolbox::gridNodeSizeForKey(v91, 0) == 15.0 )
v90 = 15.0;
cocos2d::CCPoint::CCPoint(&v181, v90, -v90);
cocos2d::CCPoint::operator+(v138, &v182);
if ( v66 > cocos2d::ccpDistance((cocos2d *)&v139, &v182, v92) )
{
LABEL_120:
cocos2d::CCArray::removeObjectAtIndex(v12, v59, 1);
}
else
{
LABEL_119:
cocos2d::CCDictionary::setObject(v164, v61, (unsigned int)v61[16].m_eObjType);
++v59;
}
}
while ( v59 < cocos2d::CCArray::count(v12) );
v54 = v148;
}
if ( cocos2d::CCArray::count(v12) )
{
v93 = (cocos2d::CCPoint)((__int64 (__fastcall *)(SmartGameObject *, char *))v11->getRealPosition)(v11, v189);
Object = EditorUI::createObject(v54, v11->m_objectID, v93);
cocos2d::CCArray::addObject(v12, Object);
v95 = Object->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v11->getRotation(v11);
((void (__fastcall *)(GameObject *))v95->setRotation)(Object);
v96 = Object->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v97 = v11->isFlipX(v11);
v96->setFlipX(Object, v97);
v98 = Object->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v99 = v11->isFlipY(v11);
v98->setFlipY(Object, v99);
Object->m_hasGroupParent = 1;
qsort(v12->data->arr, v12->data->num, 8u, (_CoreCrtNonSecureSearchSortCompareFunction)sub_1400DF2A0);
qsort(v12->data->arr, v12->data->num, 8u, (_CoreCrtNonSecureSearchSortCompareFunction)sub_1400DF370);
EditorUI::getGroupCenter(v100, &v183, (bool)v12);
*(_OWORD *)Src = 0;
v101 = 0;
v194 = 0;
v102 = 15;
v195 = 15;
LOBYTE(Src[0]) = 0;
v140 |= 1u;
data = v12->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
v106 = &arr[num - 1];
if ( arr <= v106 )
{
do
{
v107 = *arr;
if ( !*arr )
break;
if ( v107[18].m_eObjType != 749 )
{
v108 = (const struct cocos2d::CCPoint *)((__int64 (__fastcall *)(cocos2d::CCObject *))v107->__vftable[2].getTag)(*arr);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v183.m_nTag, v108);
v109 = ((__int64 (__fastcall *)(cocos2d::CCObject *))v107->__vftable[2].getTag)(v107);
cocos2d::CCPoint::operator-(v109, &v183.m_uID, &v183);
v107->__vftable[2].encodeWithCoder(v107, (DS_Dictionary *)&v183.m_uID);
((void (__fastcall *)(cocos2d::CCObject *, void **, LevelEditorLayer *))v107->__vftable[17].copyWithZone)(
v107,
v198,
v54->m_editorLayer);
v107->__vftable[2].encodeWithCoder(v107, (DS_Dictionary *)&v183.m_nTag);
v110 = v198;
if ( v198[3] > (void *)0xF )
v110 = (void **)v198[0];
sub_140041270(Src, v110, (size_t)v198[2]);
sub_140041270(Src, ";", 1u);
sub_14003A830((__int64)v198);
}
++arr;
}
while ( arr <= v106 );
v102 = v195;
v101 = v194;
}
}
Object->m_hasGroupParent = 0;
Object->m_wasSelected = Object->m_isSelected;
EditorUI::deselectObject(v54, Object);
m_editorLayer = v54->m_editorLayer;
LOBYTE(v112) = 1;
Object->deactivateObject(Object, v112);
GJBaseGameLayer::removeObjectFromSection(m_editorLayer, Object);
LevelEditorLayer::removeSpecial(m_editorLayer, Object);
m_editorLayer->m_unk3b22 = 1;
v54->m_rotationTouchID = -1;
if ( v54->m_rotationControl->isVisible(v54->m_rotationControl) )
{
v54->m_rotationControl->setVisible(v54->m_rotationControl, 0);
GJRotationControl::finishTouch(v54->m_rotationControl);
}
EditorUI::deactivateScaleControl(v54);
EditorUI::deactivateTransformControl(v54);
p_Buf2 = (SmartGameObject *)&Buf2;
Buf2 = 0;
Size = 0;
v154 = 0;
v117 = Src;
if ( v102 > 0xF )
v117 = (void **)Src[0];
if ( v101 > 0x7FFFFFFFFFFFFFFFLL )
sub_140007B50(v114, v113, v115, v116);
v154 = 15;
if ( v101 > 0xF )
{
v118 = v101 | 0xF;
if ( (v101 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
if ( v118 < 0x16 )
v118 = 22;
}
else
{
v118 = 0x7FFFFFFFFFFFFFFFLL;
}
*(_QWORD *)&Buf2 = sub_14003AA10(v118 + 1);
Size = v101;
v154 = v118;
memcpy((void *)Buf2, v117, v101 + 1);
}
else
{
Size = v101;
Buf2 = *(_OWORD *)v117;
}
v149 = (unsigned __int64)&Buf2;
v119 = (std::string *)sub_14003BDB0((__int64)v198, (__int64)&v196);
p_Buf2 = (SmartGameObject *)v119;
v4 = v155;
sub_14003CCE0((void **)&v155->m_unk0a8, byte_140518980, 0);
v121 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(v4->m_prefabArrays, v119);
if ( !v121 )
{
v121 = (cocos2d::CCArray *)cocos2d::CCArray::create(v120);
cocos2d::CCDictionary::setObject(v4->m_prefabArrays, v121, v119);
}
v122 = 0;
if ( cocos2d::CCArray::count(v121) )
{
while ( 1 )
{
v123 = cocos2d::CCArray::objectAtIndex(v121, v122);
if ( !sub_14003A760(&v123[1].m_uIndexInArray, &Buf2) )
break;
if ( ++v122 >= cocos2d::CCArray::count(v121) )
goto LABEL_150;
}
}
else
{
LABEL_150:
v124 = GJSmartPrefab::create();
if ( &v124->m_prefabData != (std::string *)&Buf2 )
{
v125 = &Buf2;
if ( v154 > 0xF )
v125 = (__int128 *)Buf2;
sub_14003CCE0((void **)&v124->m_prefabData, v125, Size);
}
if ( &v124->m_prefabKey != v119 )
{
m_bigStorage = v119;
if ( v119->m_data.m_capacity > 0xF )
m_bigStorage = (std::string *)v119->m_data.m_bigStorage;
sub_14003CCE0((void **)&v124->m_prefabKey, m_bigStorage, v119->m_data.m_size);
}
cocos2d::CCArray::addObject(v121, v124);
v127 = sub_14003BDB0((__int64)v199, (__int64)v119);
GJSmartTemplate::saveRemap(v4, v127);
}
sub_14003A830((__int64)v119);
sub_14003A830((__int64)&Buf2);
v140 &= ~1u;
sub_14003A830((__int64)Src);
}
else
{
LABEL_160:
v4 = v155;
}
sub_14003A830((__int64)&v196);
v3 = v165;
v10 = i;
}
++v10;
}
GJSmartTemplate::logTemplateStatus(v4, v199);
sub_14003A830((__int64)v199);
}
}