//
// EditorUI::createLoop from 0x1401b9360 to 0x1401b9a65 (1797 bytes)
//
// 3 xrefs:
// > EditorCommandsPopup::onCommand @ 0x14017db76
// > EditorUI::handleEditorAction @ 0x1401c349c
// > ??> @ 0x14091a3c0
//
// 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:59 +0000
//
// Hidden C++ exception states: #wind=12
int __fastcall EditorUI::createLoop(__int64 a1)
{
int v2; // esi
__int64 v3; // rax
cocos2d::CCArray *v4; // r14
struct cocos2d::CCObject *v5; // rdx
unsigned int v6; // ebx
struct cocos2d::CCObject *v7; // rax
__int64 v8; // rcx
cocos2d::CCArray *v9; // r13
float v10; // xmm6_4
float v11; // xmm9_4
unsigned int i; // r12d
struct cocos2d::CCObject *v13; // rax
struct cocos2d::CCObject *v14; // rdi
__int64 v15; // rax
__int64 v16; // rcx
cocos2d::CCArray *Object; // rbx
struct cocos2d::CCObject *v18; // rax
float *v19; // rax
struct cocos2d::CCObject *v20; // rdx
cocos2d::CCArray *v21; // rcx
cocos2d::CCArray *v22; // rbx
_QWORD *v23; // rax
__int64 v24; // r8
__int64 v25; // r9
int NextFreeGroupID; // r14d
__int128 v27; // xmm0
const struct cocos2d::CCPoint *v28; // rax
__int64 v29; // rdi
int v30; // ecx
__int64 v31; // rbx
__int64 *v32; // rdi
__int64 v33; // rbx
__int64 v34; // rax
double v35; // xmm0_8
float v36; // xmm11_4
__int128 v37; // xmm6
float v38; // xmm9_4
float v39; // xmm8_4
int v40; // r12d
__int64 v41; // rcx
unsigned int v42; // ebx
cocos2d::CCArray *v43; // rdi
unsigned int v44; // r13d
cocos2d::CCArray *v45; // r14
cocos2d::CCArray *v46; // rax
struct cocos2d::CCObject *v47; // rax
float *v48; // rax
__int64 *v49; // rdi
__int64 v50; // rbx
__int64 v51; // rax
__int128 v52; // xmm7
unsigned int v53; // r14d
struct cocos2d::CCObject *v54; // rbx
__int64 v55; // rdi
float v56; // edi
_QWORD *v57; // rax
__int64 v58; // r8
__int64 v59; // r9
float *v60; // rax
__int64 v61; // rax
const struct cocos2d::CCPoint *v62; // rax
__int64 v63; // rdi
__int64 v64; // rbx
int v65; // eax
__int64 v66; // rbx
int v68; // [rsp+28h] [rbp-E0h]
__int64 v69; // [rsp+38h] [rbp-D0h] BYREF
cocos2d::CCArray *v70; // [rsp+40h] [rbp-C8h]
cocos2d::CCArray *v71; // [rsp+48h] [rbp-C0h]
__int64 v72; // [rsp+50h] [rbp-B8h] BYREF
void *v73; // [rsp+58h] [rbp-B0h] BYREF
_QWORD v74[3]; // [rsp+60h] [rbp-A8h] BYREF
__int64 v75; // [rsp+78h] [rbp-90h]
__int64 v76; // [rsp+80h] [rbp-88h]
__int64 v77; // [rsp+88h] [rbp-80h]
_BYTE v78[8]; // [rsp+90h] [rbp-78h] BYREF
cocos2d::CCArray *v79; // [rsp+98h] [rbp-70h]
_BYTE v80[8]; // [rsp+A0h] [rbp-68h] BYREF
_BYTE v81[8]; // [rsp+A8h] [rbp-60h] BYREF
_BYTE v82[8]; // [rsp+B0h] [rbp-58h] BYREF
_BYTE v83[8]; // [rsp+B8h] [rbp-50h] BYREF
_BYTE v84[112]; // [rsp+C0h] [rbp-48h] BYREF
float v85; // [rsp+178h] [rbp+70h] BYREF
float v86; // [rsp+17Ch] [rbp+74h]
unsigned int v87; // [rsp+180h] [rbp+78h] BYREF
int v88; // [rsp+188h] [rbp+80h] BYREF
int v89; // [rsp+190h] [rbp+88h]
v2 = 0;
v89 = 0;
if ( *(_QWORD *)(a1 + 1568) || (LODWORD(v3) = cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 944)), (_DWORD)v3) )
{
v4 = (cocos2d::CCArray *)cocos2d::CCArray::create(a1);
v5 = *(struct cocos2d::CCObject **)(a1 + 1568);
if ( v5 )
cocos2d::CCArray::addObject(v4, v5);
else
cocos2d::CCArray::addObjectsFromArray(v4, *(struct cocos2d::CCArray **)(a1 + 944));
v6 = 0;
while ( v6 < cocos2d::CCArray::count(v4) )
{
v7 = cocos2d::CCArray::objectAtIndex(v4, v6);
if ( (unsigned __int8)GameObject::isSpawnableTrigger(v7) )
++v6;
else
cocos2d::CCArray::removeObjectAtIndex(v4, v6, 1);
}
qsort(
*(void **)(*((_QWORD *)v4 + 7) + 16LL),
**((unsigned int **)v4 + 7),
8u,
(_CoreCrtNonSecureSearchSortCompareFunction)sub_14019F170);
v9 = (cocos2d::CCArray *)cocos2d::CCArray::create(v8);
v71 = v9;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v78);
v10 = 0.0;
v11 = 0.0;
for ( i = 0; i < cocos2d::CCArray::count(v4); ++i )
{
v13 = cocos2d::CCArray::objectAtIndex(v4, i);
v14 = v13;
if ( !i )
{
v15 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *, unsigned int *))(*(_QWORD *)v13 + 1208LL))(
v13,
&v87);
cocos2d::CCPoint::operator=(v78, v15);
}
*((_BYTE *)v14 + 1489) = 1;
*((_BYTE *)v14 + 1680) = 1;
(*(void (__fastcall **)(struct cocos2d::CCObject *, float *))(*(_QWORD *)v14 + 1208LL))(v14, &v85);
if ( v10 > v85 || v10 == 0.0 )
v10 = v85;
if ( v86 > v11 || v11 == 0.0 )
v11 = v86;
if ( cocos2d::CCArray::count(v9)
&& (Object = cocos2d::CCArray::lastObject(v9),
v18 = cocos2d::CCArray::objectAtIndex(Object, 0),
v19 = (float *)(*(__int64 (__fastcall **)(struct cocos2d::CCObject *, int *))(*(_QWORD *)v18 + 1208LL))(
v18,
&v88),
(float)(v85 - *v19) <= 0.1) )
{
v20 = v14;
v21 = Object;
}
else
{
v22 = (cocos2d::CCArray *)cocos2d::CCArray::create(v16);
cocos2d::CCArray::addObject(v22, v14);
v20 = v22;
v21 = v9;
}
cocos2d::CCArray::addObject(v21, v20);
}
v74[0] = 0;
v23 = operator new(0x18u);
*v23 = v23;
v23[1] = v23;
v73 = v23;
v27 = 0;
*(_OWORD *)&v74[1] = 0;
v75 = 0;
v76 = 7;
v77 = 8;
LODWORD(v72) = 1065353216;
sub_14003F200((__int64)&v74[1], 0x10u, (unsigned __int64)v23);
NextFreeGroupID = LevelEditorLayer::getNextFreeGroupID(*(_QWORD *)(a1 + 1512), &v72, v24, v25);
v88 = NextFreeGroupID;
sub_14003EA90(&v74[1]);
sub_14003EB00(&v73);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v85, v10, v11 + 90.0);
v29 = EditorUI::createObject(a1, 0x4F4u, v28);
v30 = NextFreeGroupID;
if ( NextFreeGroupID < 0 )
v30 = 0;
if ( v30 > 9999 )
v30 = 9999;
*(_DWORD *)(v29 + 1480) = v30;
v31 = *(_QWORD *)(a1 + 1512);
LevelEditorLayer::removeSpecial(v31, v29);
LevelEditorLayer::addSpecial(v31, v29);
v32 = *(__int64 **)(a1 + 1512);
v33 = *v32;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v85, v10, 0.0);
v35 = (*(double (__fastcall **)(__int64 *, __int64, _QWORD, _QWORD, _BYTE, _DWORD))(v33 + 1256))(
v32,
v34,
0,
0,
0,
0);
v36 = *(float *)&v35;
v37 = 0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v69);
rand();
v38 = v11 + 60.0;
v39 = 0.0;
v40 = NextFreeGroupID;
v79 = (cocos2d::CCArray *)cocos2d::CCArray::create(v41);
*(float *)&v42 = 0.0;
v85 = 0.0;
if ( cocos2d::CCArray::count(v9) )
{
do
{
v87 = cocos2d::CCArray::count(v9) - 1;
v43 = cocos2d::CCArray::objectAtIndex(v9, v42);
v70 = v43;
v44 = v40;
v45 = v71;
if ( v42 >= cocos2d::CCArray::count(v71) - 1 )
{
v52 = v37;
}
else
{
v46 = cocos2d::CCArray::objectAtIndex(v45, v42 + 1);
v47 = cocos2d::CCArray::objectAtIndex(v46, 0);
v48 = (float *)(*(__int64 (__fastcall **)(struct cocos2d::CCObject *, _BYTE *))(*(_QWORD *)v47 + 1208LL))(
v47,
v80);
v49 = *(__int64 **)(a1 + 1512);
v50 = *v49;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v81, *v48, 0.0);
LOBYTE(v68) = 0;
*(double *)&v27 = (*(double (__fastcall **)(__int64 *, __int64, _QWORD, _QWORD, int, _DWORD))(v50 + 1256))(
v49,
v51,
0,
0,
v68,
0);
v52 = v27;
*(float *)&v52 = *(float *)&v27 - v36;
*(float *)&v42 = v85;
v43 = v70;
}
v53 = 0;
if ( cocos2d::CCArray::count(v43) )
{
do
{
v54 = cocos2d::CCArray::objectAtIndex(v43, v53);
v55 = *(_QWORD *)(a1 + 1512);
if ( (*(unsigned int (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)v54 + 1448LL))(
v54,
v44) == 1 )
(*(void (__fastcall **)(__int64, struct cocos2d::CCObject *, _QWORD, _QWORD))(*(_QWORD *)v55 + 1200LL))(
v55,
v54,
v44,
0);
if ( !v53 )
{
v37 = v52;
v56 = v85;
if ( LODWORD(v85) == v87 )
{
v40 = v88;
}
else
{
v74[0] = 0;
v57 = operator new(0x18u);
*v57 = v57;
v57[1] = v57;
v73 = v57;
v27 = 0;
*(_OWORD *)&v74[1] = 0;
v75 = 0;
v76 = 7;
v77 = 8;
LODWORD(v72) = 1065353216;
sub_14003F200((__int64)&v74[1], 0x10u, (unsigned __int64)v57);
v2 |= 2u;
v89 = v2;
v40 = LevelEditorLayer::getNextFreeGroupID(*(_QWORD *)(a1 + 1512), &v72, v58, v59);
}
if ( (v2 & 2) != 0 )
{
v2 &= ~2u;
sub_14003EA90(&v74[1]);
sub_14003EB00(&v73);
}
if ( LODWORD(v56) != v87 )
{
v37 = v52;
*(float *)&v37 = *(float *)&v52 - v39;
}
v60 = (float *)(*(__int64 (__fastcall **)(struct cocos2d::CCObject *, _BYTE *))(*(_QWORD *)v54 + 1208LL))(
v54,
v82);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v83, *v60, v38);
cocos2d::CCPoint::operator=(&v69, v61);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v84, (const struct cocos2d::CCPoint *)&v69);
v63 = EditorUI::createObject(a1, 0x4F4u, v62);
cocos2d::CCArray::addObject(v79, (struct cocos2d::CCObject *)v63);
v64 = *(_QWORD *)(a1 + 1512);
if ( (*(unsigned int (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v63 + 1448LL))(v63, v44) == 1 )
(*(void (__fastcall **)(__int64, __int64, _QWORD, _QWORD))(*(_QWORD *)v64 + 1200LL))(v64, v63, v44, 0);
v65 = v40;
if ( v40 < 0 )
v65 = 0;
if ( v65 > 9999 )
v65 = 9999;
*(_DWORD *)(v63 + 1480) = v65;
*(_DWORD *)(v63 + 1920) = v37;
*(_BYTE *)(v63 + 1489) = 1;
*(_BYTE *)(v63 + 1680) = 1;
v66 = *(_QWORD *)(a1 + 1512);
LevelEditorLayer::removeSpecial(v66, v63);
LevelEditorLayer::addSpecial(v66, v63);
v39 = v39 + *(float *)&v37;
}
++v53;
v43 = v70;
}
while ( v53 < cocos2d::CCArray::count(v70) );
*(float *)&v42 = v85;
}
++v42;
v85 = *(float *)&v42;
v9 = v71;
}
while ( v42 < cocos2d::CCArray::count(v71) );
}
v3 = *(_QWORD *)(a1 + 1512);
*(_DWORD *)(v3 + 14824) = 16843009;
*(_BYTE *)(v3 + 14828) = 1;
}
return v3;
}