//
// EditorUI::addObjectsToSmartTemplate from 0x1401b5860 to 0x1401b6817 (4023 bytes)
//
// 2 xrefs:
// > SetupSmartBlockLayer::onCreateTemplate @ 0x1405ee32f
// > ??> @ 0x14091a228
//
// This function is hookable on this platform (idp: pc, 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 11:27:58 +0000
//
// Hidden C++ exception states: #wind=7
void __fastcall EditorUI::addObjectsToSmartTemplate(__int64 a1, __int64 a2, cocos2d::CCArray *a3)
{
cocos2d::CCArray *v3; // r15
__int64 v4; // r14
cocos2d::CCDictionary *v5; // rsi
unsigned int v6; // edi
struct cocos2d::CCObject *v7; // rax
int *v8; // rbx
int v9; // eax
unsigned int v10; // ebx
struct cocos2d::CCObject *v11; // rsi
cocos2d::CCArray *v12; // r14
__int64 v13; // rax
unsigned int v14; // eax
__int64 v15; // rax
__int64 v16; // rax
int v17; // eax
const struct cocos2d::CCPoint *v18; // rdx
int v19; // eax
int v20; // ecx
__int64 SmartNeighbor; // rdi
int v22; // eax
int v23; // ecx
__int64 v24; // rbx
int v25; // eax
int v26; // ecx
int v27; // eax
int v28; // ecx
int v29; // eax
int v30; // ecx
int v31; // eax
int v32; // ecx
int v33; // eax
int v34; // ecx
int v35; // eax
int v36; // ecx
bool v37; // r12
bool v38; // si
bool v39; // di
bool v40; // r15
bool v41; // r13
__int64 v42; // rax
int v43; // ecx
__int64 v44; // rdx
__int64 v45; // r11
bool v46; // zf
float v47; // xmm0_4
float v48; // xmm1_4
__int64 v49; // rbx
__int64 v50; // rax
__int64 v51; // r8
struct cocos2d::CCArray *v52; // rax
int v53; // eax
int v54; // eax
__int64 v55; // rbx
void *v56; // rcx
__m128i v57; // xmm1
cocos2d::CCArray *v58; // rax
cocos2d::CCArray *v59; // rsi
unsigned int v60; // edi
unsigned int v61; // ebx
struct cocos2d::CCObject *v62; // rdi
bool v63; // r15
bool v64; // r13
struct cocos2d::CCObject *v65; // rax
unsigned int *v66; // rbx
const struct cocos2d::CCPoint *v67; // rax
const struct cocos2d::CCPoint *v68; // r8
const struct cocos2d::CCPoint *v69; // r8
float v70; // xmm0_4
float v71; // xmm6_4
int v72; // eax
unsigned int v73; // eax
float v74; // xmm8_4
__int64 v75; // rcx
const struct cocos2d::CCPoint *v76; // r8
float v77; // xmm8_4
__int64 v78; // rcx
const struct cocos2d::CCPoint *v79; // r8
float v80; // xmm8_4
__int64 v81; // rcx
const struct cocos2d::CCPoint *v82; // r8
float v83; // xmm8_4
__int64 v84; // rcx
const struct cocos2d::CCPoint *v85; // r8
float v86; // xmm8_4
__int64 v87; // rcx
const struct cocos2d::CCPoint *v88; // r8
float v89; // xmm8_4
__int64 v90; // rcx
const struct cocos2d::CCPoint *v91; // r8
float v92; // xmm8_4
__int64 v93; // rcx
const struct cocos2d::CCPoint *v94; // r8
float v95; // xmm8_4
__int64 v96; // rcx
const struct cocos2d::CCPoint *v97; // r8
unsigned int v98; // ebx
const struct cocos2d::CCPoint *v99; // rax
struct cocos2d::CCObject *Object; // rdi
__int64 v101; // rbx
__int64 v102; // rbx
unsigned __int8 v103; // al
__int64 v104; // rbx
unsigned __int8 v105; // al
__int64 v106; // rsi
__int64 v107; // rbx
__int64 v108; // rdx
void **v109; // rsi
void **v110; // r14
__int64 v111; // rbx
__int64 v112; // rcx
cocos2d::CCArray *v113; // rdi
unsigned int v114; // ebx
struct cocos2d::CCObject *v115; // rax
void **v116; // rbx
void *v117; // rdx
void *v118; // rdx
__int64 v119; // rax
bool v120; // [rsp+60h] [rbp-A0h]
bool v121; // [rsp+61h] [rbp-9Fh]
bool v122; // [rsp+62h] [rbp-9Eh]
bool v123; // [rsp+63h] [rbp-9Dh]
char v124; // [rsp+64h] [rbp-9Ch]
char v125; // [rsp+65h] [rbp-9Bh]
char v126; // [rsp+66h] [rbp-9Ah]
char v127; // [rsp+67h] [rbp-99h]
bool v128; // [rsp+68h] [rbp-98h]
float v129[2]; // [rsp+70h] [rbp-90h] BYREF
char v130[8]; // [rsp+78h] [rbp-88h] BYREF
char v131[8]; // [rsp+80h] [rbp-80h] BYREF
int v132; // [rsp+88h] [rbp-78h]
float v133; // [rsp+90h] [rbp-70h] BYREF
float v134; // [rsp+94h] [rbp-6Ch]
float v135; // [rsp+98h] [rbp-68h]
float v136; // [rsp+9Ch] [rbp-64h]
int v137; // [rsp+A0h] [rbp-60h]
int v138; // [rsp+A4h] [rbp-5Ch]
int v139; // [rsp+A8h] [rbp-58h]
int v140; // [rsp+ACh] [rbp-54h]
unsigned int v141; // [rsp+B0h] [rbp-50h]
struct cocos2d::CCObject *v142; // [rsp+B8h] [rbp-48h]
float v143[2]; // [rsp+C0h] [rbp-40h] BYREF
__int64 v144; // [rsp+C8h] [rbp-38h]
__int64 v145; // [rsp+D0h] [rbp-30h]
unsigned __int64 v146; // [rsp+D8h] [rbp-28h]
__int64 v147; // [rsp+E0h] [rbp-20h]
__int64 v148; // [rsp+E8h] [rbp-18h]
char v149[8]; // [rsp+F0h] [rbp-10h] BYREF
__int64 v150; // [rsp+F8h] [rbp-8h]
_BYTE *v151; // [rsp+100h] [rbp+0h]
__int64 v152; // [rsp+108h] [rbp+8h]
__int64 v153; // [rsp+110h] [rbp+10h]
__int64 v154; // [rsp+118h] [rbp+18h]
cocos2d::CCDictionary *v155; // [rsp+120h] [rbp+20h]
cocos2d::CCArray *v156; // [rsp+128h] [rbp+28h]
__int64 v157; // [rsp+130h] [rbp+30h]
char v158[8]; // [rsp+138h] [rbp+38h] BYREF
cocos2d::CCDictionary *v159; // [rsp+140h] [rbp+40h]
char v160[8]; // [rsp+148h] [rbp+48h] BYREF
char v161[8]; // [rsp+150h] [rbp+50h] BYREF
char v162[8]; // [rsp+158h] [rbp+58h] BYREF
char v163[8]; // [rsp+160h] [rbp+60h] BYREF
char v164[8]; // [rsp+168h] [rbp+68h] BYREF
char v165[8]; // [rsp+170h] [rbp+70h] BYREF
char v166[8]; // [rsp+178h] [rbp+78h] BYREF
char v167[8]; // [rsp+180h] [rbp+80h] BYREF
char v168[8]; // [rsp+188h] [rbp+88h] BYREF
char v169[8]; // [rsp+190h] [rbp+90h] BYREF
char v170[8]; // [rsp+198h] [rbp+98h] BYREF
char v171[8]; // [rsp+1A0h] [rbp+A0h] BYREF
char v172[8]; // [rsp+1A8h] [rbp+A8h] BYREF
char v173[8]; // [rsp+1B0h] [rbp+B0h] BYREF
char v174[8]; // [rsp+1B8h] [rbp+B8h] BYREF
char v175[8]; // [rsp+1C0h] [rbp+C0h] BYREF
char v176[8]; // [rsp+1C8h] [rbp+C8h] BYREF
char v177[8]; // [rsp+1D0h] [rbp+D0h] BYREF
char v178[8]; // [rsp+1D8h] [rbp+D8h] BYREF
char v179[8]; // [rsp+1E0h] [rbp+E0h] BYREF
char v180[8]; // [rsp+1E8h] [rbp+E8h] BYREF
char v181[8]; // [rsp+1F0h] [rbp+F0h] BYREF
char v182[8]; // [rsp+1F8h] [rbp+F8h] BYREF
char v183[8]; // [rsp+200h] [rbp+100h] BYREF
char v184[8]; // [rsp+208h] [rbp+108h] BYREF
char v185[8]; // [rsp+210h] [rbp+110h] BYREF
char v186[8]; // [rsp+218h] [rbp+118h] BYREF
char v187[8]; // [rsp+220h] [rbp+120h] BYREF
char v188[16]; // [rsp+228h] [rbp+128h] BYREF
_BYTE v189[32]; // [rsp+238h] [rbp+138h] BYREF
char v190[32]; // [rsp+258h] [rbp+158h] BYREF
__int128 v191; // [rsp+278h] [rbp+178h] BYREF
__m128i v192; // [rsp+288h] [rbp+188h]
_BYTE v193[32]; // [rsp+298h] [rbp+198h] BYREF
_BYTE v194[32]; // [rsp+2B8h] [rbp+1B8h] BYREF
if ( a2 )
{
v3 = a3;
v156 = a3;
v4 = a2;
v150 = a2;
v145 = a1;
v155 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create();
v5 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create();
v159 = v5;
v6 = 0;
while ( v6 < cocos2d::CCArray::count(v3) )
{
v7 = cocos2d::CCArray::objectAtIndex(v3, v6);
v8 = (int *)v7;
if ( *((_DWORD *)v7 + 314) == 5 )
{
v9 = *((_DWORD *)v7 + 259);
if ( v9 == 2896 || v9 == 2897 )
GameObject::determineSlopeDirection(v8);
if ( v8[220] > 0 )
cocos2d::CCDictionary::setObject(v5, (struct cocos2d::CCObject *)v8, v8[220]);
++v6;
}
else
{
cocos2d::CCArray::removeObjectAtIndex(v3, v6, 1);
}
}
v10 = 0;
v141 = 0;
if ( cocos2d::CCArray::count(v3) )
{
while ( 1 )
{
v11 = cocos2d::CCArray::objectAtIndex(v3, v10);
v142 = v11;
if ( !*((_BYTE *)v11 + 1360) )
break;
LABEL_144:
v141 = ++v10;
if ( v10 >= cocos2d::CCArray::count(v3) )
{
v4 = v150;
goto LABEL_146;
}
}
v12 = nullptr;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v187, (const struct cocos2d::CCPoint *)&dword_14090A6E8);
v14 = GJSmartTemplate::smartObjectToType(v11, v13);
GJSmartTemplate::offsetForType(v143, v14);
v15 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v11 + 200LL))(v11);
cocos2d::CCPoint::operator+(v15, v130, v143);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v149);
v140 = 1;
if ( v143[0] == *(float *)&dword_14090A6E8 && v143[1] == *(float *)&dword_14090A6EC )
{
v127 = 0;
}
else
{
v127 = 1;
v140 = 2;
cocos2d::CCPoint::operator-(v143, v158);
v16 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v11 + 200LL))(v11);
cocos2d::CCPoint::operator+(v16, v176, v158);
cocos2d::CCPoint::operator=(v149, v176);
}
v191 = 0;
v192.m128i_i64[0] = 0;
v146 = 15;
v192.m128i_i64[1] = 15;
LOBYTE(v191) = 0;
v17 = 0;
v132 = 0;
do
{
v18 = (const struct cocos2d::CCPoint *)v130;
if ( v17 )
v18 = (const struct cocos2d::CCPoint *)v149;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v129, v18);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v177, (const struct cocos2d::CCPoint *)v129);
SmartNeighbor = EditorUI::getSmartNeighbor(v20, (_DWORD)v11, v19, 1, (__int64)v3);
v148 = SmartNeighbor;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v178, (const struct cocos2d::CCPoint *)v129);
v24 = EditorUI::getSmartNeighbor(v23, (_DWORD)v11, v22, 2, (__int64)v3);
v151 = (_BYTE *)v24;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v179, (const struct cocos2d::CCPoint *)v129);
v152 = EditorUI::getSmartNeighbor(v26, (_DWORD)v11, v25, 3, (__int64)v3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v180, (const struct cocos2d::CCPoint *)v129);
v154 = EditorUI::getSmartNeighbor(v28, (_DWORD)v11, v27, 4, (__int64)v3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v181, (const struct cocos2d::CCPoint *)v129);
v157 = EditorUI::getSmartNeighbor(v30, (_DWORD)v11, v29, 5, (__int64)v3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v182, (const struct cocos2d::CCPoint *)v129);
v144 = EditorUI::getSmartNeighbor(v32, (_DWORD)v11, v31, 6, (__int64)v3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v183, (const struct cocos2d::CCPoint *)v129);
v147 = EditorUI::getSmartNeighbor(v34, (_DWORD)v11, v33, 7, (__int64)v3);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v184, (const struct cocos2d::CCPoint *)v129);
v42 = EditorUI::getSmartNeighbor(v36, (_DWORD)v11, v35, 8, (__int64)v3);
v44 = v42;
v153 = v42;
v37 = SmartNeighbor != 0;
v38 = v24 != 0;
v39 = v152 != 0;
v40 = v154 != 0;
v41 = v157 != 0;
LOBYTE(v42) = v144 != 0;
v137 = v42;
v43 = v147;
LOBYTE(v43) = v147 != 0;
v138 = v43;
LOBYTE(v44) = v44 != 0;
v139 = v44;
v45 = v144;
if ( v148 )
{
if ( *(_BYTE *)(v148 + 1360) )
v37 = 0;
v45 = v144;
}
if ( v24 )
{
v46 = *(_BYTE *)(v24 + 1360) == 0;
LODWORD(v24) = 0;
if ( !v46 )
v38 = 0;
}
if ( v152 && *(_BYTE *)(v152 + 1360) )
v39 = v24;
if ( v154 && *(_BYTE *)(v154 + 1360) )
v40 = v24;
if ( v157 && *(_BYTE *)(v157 + 1360) )
v41 = v24;
if ( v45 )
{
LODWORD(v42) = (unsigned __int8)v42;
if ( *(_BYTE *)(v45 + 1360) )
LODWORD(v42) = v24;
v137 = v42;
}
if ( v147 )
{
v43 = (unsigned __int8)v43;
if ( *(_BYTE *)(v147 + 1360) )
v43 = v24;
v138 = v43;
}
if ( v153 )
{
LODWORD(v44) = (unsigned __int8)v44;
if ( *(_BYTE *)(v153 + 1360) )
LODWORD(v44) = v24;
v139 = v44;
}
cocos2d::CCRect::CCRect((cocos2d::CCRect *)&v133, v129[0] - 14.0, v129[1] - 14.0, 28.0, 28.0);
v47 = v136;
if ( !v37 )
{
v47 = v136 + 14.0;
v136 = v136 + 14.0;
}
if ( !v38 )
{
v136 = v47 + 14.0;
v134 = v134 + -14.0;
}
v48 = v135;
if ( !v39 )
{
v48 = v135 + 14.0;
v135 = v135 + 14.0;
v133 = v133 + -14.0;
}
if ( !v40 )
v135 = v48 + 14.0;
v49 = *(_QWORD *)(v145 + 1512);
v50 = cocos2d::CCRect::CCRect((cocos2d::CCRect *)v188, (const struct cocos2d::CCRect *)&v133);
LOBYTE(v51) = 1;
v52 = (struct cocos2d::CCArray *)LevelEditorLayer::objectsInRect(v49, v50, v51);
if ( v12 )
{
if ( v52 )
cocos2d::CCArray::addObjectsFromArray(v12, v52);
}
else
{
v12 = v52;
}
v53 = v132;
if ( v132 )
{
v11 = v142;
v37 = v128;
}
else
{
v128 = v37;
v120 = v38;
v121 = v39;
v122 = v40;
v123 = v41;
v124 = v137;
v125 = v138;
v126 = v139;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v185, (const struct cocos2d::CCPoint *)v129);
v11 = v142;
v55 = GJSmartTemplate::keyFromNeighbors(
(unsigned int)v193,
v54,
(_DWORD)v142,
v148,
(__int64)v151,
v152,
v154,
v157,
v144,
v147,
v153);
if ( &v191 != (__int128 *)v55 )
{
if ( v146 > 0xF )
{
v56 = (void *)v191;
if ( v146 + 1 >= 0x1000 )
{
v56 = *(void **)(v191 - 8);
if ( (unsigned __int64)(v191 - (_QWORD)v56 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v56);
}
v191 = *(_OWORD *)v55;
v192 = *(__m128i *)(v55 + 16);
v57 = v192;
*(_QWORD *)(v55 + 16) = 0;
*(_QWORD *)(v55 + 24) = 15;
*(_BYTE *)v55 = 0;
v146 = _mm_srli_si128(v57, 8).m128i_u64[0];
}
sub_14003D310((__int64)v193);
v53 = v132;
}
v17 = v53 + 1;
v132 = v17;
v3 = v156;
}
while ( v17 < v140 );
if ( *((int *)v11 + 220) > 0 )
{
v58 = cocos2d::CCDictionary::objectForKey(
*(cocos2d::CCDictionary **)(*(_QWORD *)(v145 + 1512) + 4256LL),
*((int *)v11 + 220));
v59 = v58;
v60 = 0;
if ( !v58 || (v61 = 0, !cocos2d::CCArray::count(v58)) )
{
v11 = v142;
goto LABEL_79;
}
do
{
v62 = cocos2d::CCArray::objectAtIndex(v59, v61);
if ( !cocos2d::CCArray::containsObject(v12, v62) )
cocos2d::CCArray::addObject(v12, v62);
++v61;
}
while ( v61 < cocos2d::CCArray::count(v59) );
v11 = v142;
}
v60 = 0;
LABEL_79:
if ( v12 )
{
v63 = v120;
v64 = v121;
if ( cocos2d::CCArray::count(v12) )
{
do
{
v65 = cocos2d::CCArray::objectAtIndex(v12, v60);
v66 = (unsigned int *)v65;
if ( *((_DWORD *)v65 + 314) == 5 || cocos2d::CCDictionary::objectForKey(v155, *((unsigned int *)v65 + 231)) )
goto LABEL_124;
v67 = (const struct cocos2d::CCPoint *)(*(__int64 (__fastcall **)(unsigned int *))(*(_QWORD *)v66 + 200LL))(v66);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v131, v67);
v70 = cocos2d::ccpDistance((cocos2d *)v130, (const struct cocos2d::CCPoint *)v131, v68);
v71 = v70;
if ( v127 )
{
v70 = cocos2d::ccpDistance((cocos2d *)v149, (const struct cocos2d::CCPoint *)v131, v69);
v71 = fminf(v71, v70);
}
v72 = v66[220];
if ( v72 > 0 && v72 != *((_DWORD *)v11 + 220) && cocos2d::CCDictionary::objectForKey(v159, (int)v66[220]) )
goto LABEL_124;
v73 = v66[220];
if ( v73 && v73 == *((_DWORD *)v11 + 220) )
goto LABEL_122;
if ( v37 )
{
v74 = 30.0;
ObjectToolbox::sharedState();
ObjectToolbox::gridNodeSizeForKey(v75, 0);
if ( v70 == 15.0 )
v74 = 15.0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v160, 0.0, v74);
cocos2d::CCPoint::operator+(v130, v161, v160);
v70 = cocos2d::ccpDistance((cocos2d *)v131, (const struct cocos2d::CCPoint *)v161, v76);
if ( v71 > v70 )
goto LABEL_124;
}
if ( v120 )
{
v77 = 30.0;
ObjectToolbox::sharedState();
ObjectToolbox::gridNodeSizeForKey(v78, 0);
if ( v70 == 15.0 )
v77 = 15.0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v162, 0.0, -v77);
cocos2d::CCPoint::operator+(v130, v163, v162);
v70 = cocos2d::ccpDistance((cocos2d *)v131, (const struct cocos2d::CCPoint *)v163, v79);
if ( v71 > v70 )
goto LABEL_124;
}
if ( v121 )
{
v80 = 30.0;
ObjectToolbox::sharedState();
ObjectToolbox::gridNodeSizeForKey(v81, 0);
if ( v70 == 15.0 )
v80 = 15.0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v164, -v80, 0.0);
cocos2d::CCPoint::operator+(v130, v165, v164);
v70 = cocos2d::ccpDistance((cocos2d *)v131, (const struct cocos2d::CCPoint *)v165, v82);
if ( v71 > v70 )
goto LABEL_124;
}
if ( v122 )
{
v83 = 30.0;
ObjectToolbox::sharedState();
ObjectToolbox::gridNodeSizeForKey(v84, 0);
if ( v70 == 15.0 )
v83 = 15.0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v166, v83, 0.0);
cocos2d::CCPoint::operator+(v130, v167, v166);
v70 = cocos2d::ccpDistance((cocos2d *)v131, (const struct cocos2d::CCPoint *)v167, v85);
if ( v71 > v70 )
goto LABEL_124;
}
if ( v123 )
{
v86 = 30.0;
ObjectToolbox::sharedState();
ObjectToolbox::gridNodeSizeForKey(v87, 0);
if ( v70 == 15.0 )
v86 = 15.0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v168, -v86, v86);
cocos2d::CCPoint::operator+(v130, v169, v168);
v70 = cocos2d::ccpDistance((cocos2d *)v131, (const struct cocos2d::CCPoint *)v169, v88);
if ( v71 > v70 )
goto LABEL_124;
}
if ( v124 )
{
v89 = 30.0;
ObjectToolbox::sharedState();
ObjectToolbox::gridNodeSizeForKey(v90, 0);
if ( v70 == 15.0 )
v89 = 15.0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v170, v89, v89);
cocos2d::CCPoint::operator+(v130, v171, v170);
v70 = cocos2d::ccpDistance((cocos2d *)v131, (const struct cocos2d::CCPoint *)v171, v91);
if ( v71 > v70 )
goto LABEL_124;
}
if ( v125 )
{
v92 = 30.0;
ObjectToolbox::sharedState();
ObjectToolbox::gridNodeSizeForKey(v93, 0);
if ( v70 == 15.0 )
v92 = 15.0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v172, -v92, -v92);
cocos2d::CCPoint::operator+(v130, v173, v172);
v70 = cocos2d::ccpDistance((cocos2d *)v131, (const struct cocos2d::CCPoint *)v173, v94);
if ( v71 > v70 )
goto LABEL_124;
}
if ( !v126 )
goto LABEL_122;
v95 = 30.0;
ObjectToolbox::sharedState();
ObjectToolbox::gridNodeSizeForKey(v96, 0);
if ( v70 == 15.0 )
v95 = 15.0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v174, v95, -v95);
cocos2d::CCPoint::operator+(v130, v175, v174);
if ( v71 > cocos2d::ccpDistance((cocos2d *)v131, (const struct cocos2d::CCPoint *)v175, v97) )
{
LABEL_124:
cocos2d::CCArray::removeObjectAtIndex(v12, v60, 1);
}
else
{
LABEL_122:
cocos2d::CCDictionary::setObject(v155, (struct cocos2d::CCObject *)v66, v66[231]);
++v60;
}
}
while ( v60 < cocos2d::CCArray::count(v12) );
}
if ( cocos2d::CCArray::count(v12) )
{
v98 = *((_DWORD *)v11 + 259);
v99 = (const struct cocos2d::CCPoint *)(*(__int64 (__fastcall **)(struct cocos2d::CCObject *, char *))(*(_QWORD *)v11 + 1208LL))(
v11,
v186);
Object = (struct cocos2d::CCObject *)EditorUI::createObject(v145, v98, v99);
cocos2d::CCArray::addObject(v12, Object);
v101 = *(_QWORD *)Object;
(*(void (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v11 + 360LL))(v11);
(*(void (__fastcall **)(struct cocos2d::CCObject *))(v101 + 352))(Object);
v102 = *(_QWORD *)Object;
v103 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v11 + 1272LL))(v11);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(v102 + 1088))(Object, v103);
v104 = *(_QWORD *)Object;
v105 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v11 + 1280LL))(v11);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(v104 + 1096))(Object, v105);
*((_BYTE *)Object + 1158) = 1;
qsort(
*(void **)(*((_QWORD *)v12 + 7) + 16LL),
**((unsigned int **)v12 + 7),
8u,
(_CoreCrtNonSecureSearchSortCompareFunction)sub_14019F210);
v106 = v145;
EditorUI::copyObjectsDetailed(v145, v193, v12);
*((_BYTE *)Object + 1158) = 0;
*((_BYTE *)Object + 1140) = *((_BYTE *)Object + 1141);
EditorUI::deselectObject(v106, Object);
v107 = *(_QWORD *)(v106 + 1512);
LOBYTE(v108) = 1;
(*(void (__fastcall **)(struct cocos2d::CCObject *, __int64))(*(_QWORD *)Object + 1160LL))(Object, v108);
GJBaseGameLayer::removeObjectFromSection(v107, Object);
LevelEditorLayer::removeSpecial(v107, Object);
*(_BYTE *)(v107 + 15666) = 1;
EditorUI::deactivateRotationControl(v106);
EditorUI::deactivateScaleControl(v106);
EditorUI::deactivateTransformControl(v106);
v151 = v189;
v109 = (void **)sub_14003F4F0((__int64)v189, (__int64)v193);
v146 = (unsigned __int64)v109;
v110 = (void **)sub_14003F4F0((__int64)v190, (__int64)&v191);
v151 = v110;
v111 = v150;
sub_1400405A0((void **)(v150 + 168), &byte_1406ED6E0, 0);
v113 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(*(_QWORD *)(v111 + 56), v110);
if ( !v113 )
{
v113 = (cocos2d::CCArray *)cocos2d::CCArray::create(v112);
cocos2d::CCDictionary::setObject(*(_QWORD *)(v111 + 56), v113, v110);
}
v114 = 0;
if ( cocos2d::CCArray::count(v113) )
{
while ( 1 )
{
v115 = cocos2d::CCArray::objectAtIndex(v113, v114);
if ( !sub_14003D160((_QWORD *)v115 + 11, v109) )
break;
if ( ++v114 >= cocos2d::CCArray::count(v113) )
goto LABEL_132;
}
}
else
{
LABEL_132:
v116 = (void **)GJSmartPrefab::create();
if ( v116 + 11 != v109 )
{
v117 = v109;
if ( (unsigned __int64)v109[3] > 0xF )
v117 = *v109;
sub_1400405A0(v116 + 11, v117, (size_t)v109[2]);
}
if ( v116 + 7 != v110 )
{
v118 = v110;
if ( (unsigned __int64)v110[3] > 0xF )
v118 = *v110;
sub_1400405A0(v116 + 7, v118, (size_t)v110[2]);
}
cocos2d::CCArray::addObject(v113, (struct cocos2d::CCObject *)v116);
v119 = sub_14003F4F0((__int64)v194, (__int64)v110);
GJSmartTemplate::saveRemap(v150, v119);
}
sub_14003D310((__int64)v110);
sub_14003D310((__int64)v109);
sub_14003D310((__int64)v193);
}
}
else
{
v63 = v120;
v64 = v121;
}
sub_14003D310((__int64)&v191);
v128 = v37;
v120 = v63;
v121 = v64;
v3 = v156;
v10 = v141;
goto LABEL_144;
}
LABEL_146:
GJSmartTemplate::logTemplateStatus(v4, v194);
sub_14003D310((__int64)v194);
}
}