//
// EditorUI::createLoop from 0x140119630 to 0x140119cca (1690 bytes)
//
// 2 xrefs:
// > EditorPauseLayer::onCreateLoop @ 0x1400dcd0e
// > ??> @ 0x1406c9444
//
// 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=4
void EditorUI::createLoop(EditorUI *a1)
{
__int128 y_low; // xmm0
int v3; // esi
cocos2d::CCArray *v4; // r14
GameObject *m_selectedObject; // rdx
unsigned int v6; // ebx
GameObject *v7; // rax
__int64 v8; // rcx
cocos2d::CCArray *v9; // r13
float x; // xmm6_4
float y; // xmm9_4
unsigned int i; // r12d
__int64 v13; // r8
struct cocos2d::CCObject *v14; // rax
struct cocos2d::CCObject *v15; // rdi
__int64 v16; // rax
__int64 v17; // rcx
cocos2d::CCArray *Object; // rbx
struct cocos2d::CCObject *v19; // rax
float *v20; // rax
struct cocos2d::CCObject *v21; // rdx
cocos2d::CCArray *v22; // rcx
cocos2d::CCArray *v23; // rbx
int NextFreeGroupID; // r14d
cocos2d::CCPoint v25; // rax
GameObject *v26; // rdi
int v27; // ecx
LevelEditorLayer *m_editorLayer; // rbx
LevelEditorLayer_vtbl *v29; // rbx
__int64 v30; // rax
double v31; // xmm0_8
float v32; // xmm11_4
__int128 v33; // xmm6
float v34; // xmm9_4
float v35; // xmm8_4
int v36; // r12d
__int64 v37; // rcx
unsigned int v38; // r14d
unsigned int v39; // r13d
cocos2d::CCArray *j; // rbx
cocos2d::CCArray *v41; // rdi
cocos2d::CCArray *v42; // rax
struct cocos2d::CCObject *v43; // rax
float *v44; // rax
LevelEditorLayer_vtbl *v45; // rbx
__int64 v46; // rax
__int128 v47; // xmm7
struct cocos2d::CCObject *v48; // rbx
LevelEditorLayer *v49; // rdi
__int64 v50; // r8
unsigned int v51; // edi
float *v52; // rax
__int64 v53; // rax
cocos2d::CCPoint v54; // rax
GameObject *v55; // rdi
LevelEditorLayer *v56; // rbx
int v57; // eax
LevelEditorLayer *v58; // rbx
LevelEditorLayer *v59; // rax
int v60; // [rsp+28h] [rbp-E0h]
__int64 v61; // [rsp+38h] [rbp-D0h] BYREF
cocos2d::CCArray *v62; // [rsp+40h] [rbp-C8h]
cocos2d::CCPoint v63; // [rsp+48h] [rbp-C0h] BYREF
cocos2d::CCPoint v64; // [rsp+50h] [rbp-B8h] BYREF
cocos2d::CCArray *v65; // [rsp+58h] [rbp-B0h]
cocos2d::CCArray *v66; // [rsp+60h] [rbp-A8h]
_BYTE v67[8]; // [rsp+68h] [rbp-A0h] BYREF
cocos2d::CCPoint v68; // [rsp+70h] [rbp-98h] BYREF
_BYTE v69[8]; // [rsp+78h] [rbp-90h] BYREF
cocos2d::CCPoint v70; // [rsp+80h] [rbp-88h] BYREF
cocos2d::CCPoint v71; // [rsp+88h] [rbp-80h] BYREF
std::unordered_set v72[2]; // [rsp+90h] [rbp-78h] BYREF
cocos2d::CCPoint v73; // [rsp+188h] [rbp+80h] BYREF
int v74; // [rsp+190h] [rbp+88h] BYREF
unsigned int v75; // [rsp+198h] [rbp+90h] BYREF
int v76; // [rsp+1A0h] [rbp+98h]
v3 = 0;
LODWORD(v61) = 0;
if ( a1->m_selectedObject || cocos2d::CCArray::count(a1->m_selectedObjects) )
{
v4 = (cocos2d::CCArray *)cocos2d::CCArray::create(a1);
m_selectedObject = a1->m_selectedObject;
if ( m_selectedObject )
cocos2d::CCArray::addObject(v4, m_selectedObject);
else
cocos2d::CCArray::addObjectsFromArray(v4, a1->m_selectedObjects);
v6 = 0;
while ( v6 < cocos2d::CCArray::count(v4) )
{
v7 = (GameObject *)cocos2d::CCArray::objectAtIndex(v4, v6);
if ( GameObject::isSpawnableTrigger(v7) )
++v6;
else
cocos2d::CCArray::removeObjectAtIndex(v4, v6, 1);
}
qsort(v4->data->arr, v4->data->num, 8u, (_CoreCrtNonSecureSearchSortCompareFunction)sub_1400DF200);
v9 = (cocos2d::CCArray *)cocos2d::CCArray::create(v8);
v62 = v9;
cocos2d::CCPoint::CCPoint(&v64);
x = 0.0;
y = 0.0;
for ( i = 0; i < cocos2d::CCArray::count(v4); ++i )
{
v14 = cocos2d::CCArray::objectAtIndex(v4, i);
v15 = v14;
if ( !i )
{
v16 = ((__int64 (__fastcall *)(struct cocos2d::CCObject *, int *))v14->__vftable[16].encodeWithCoder)(v14, &v74);
cocos2d::CCPoint::operator=(&v64, v16);
}
BYTE1(v15[26].m_uIndexInArray) = 1;
LOBYTE(v15[30].__vftable) = 1;
v15->__vftable[16].encodeWithCoder(v15, (DS_Dictionary *)&v73);
if ( x > v73.x || x == 0.0 )
x = v73.x;
y_low = LODWORD(v73.y);
if ( v73.y > y || y == 0.0 )
y = v73.y;
if ( cocos2d::CCArray::count(v9)
&& (Object = (cocos2d::CCArray *)cocos2d::CCArray::lastObject(v9),
v19 = cocos2d::CCArray::objectAtIndex(Object, 0),
v20 = (float *)((__int64 (__fastcall *)(struct cocos2d::CCObject *, unsigned int *))v19->__vftable[16].encodeWithCoder)(
v19,
&v75),
y_low = LODWORD(v73.x),
(float)(v73.x - *v20) <= 0.1) )
{
v21 = v15;
v22 = Object;
}
else
{
v23 = (cocos2d::CCArray *)cocos2d::CCArray::create(v17);
cocos2d::CCArray::addObject(v23, v15);
v21 = v23;
v22 = v9;
}
cocos2d::CCArray::addObject(v22, v21);
}
v73.x = 0.0;
sub_14005E660((__int64)v72, &v73, v13);
NextFreeGroupID = LevelEditorLayer::getNextFreeGroupID(a1->m_editorLayer, v72);
v76 = NextFreeGroupID;
sub_14005D100((__int64)&v72[0]._Vec);
sub_14005D870((void **)&v72[0]._List._Mypair._Myval2._Myhead);
cocos2d::CCPoint::CCPoint(&v73, x, y + 90.0);
v26 = EditorUI::createObject(a1, 1268, v25);
v27 = NextFreeGroupID;
if ( NextFreeGroupID < 0 )
v27 = 0;
if ( v27 > 9999 )
v27 = 9999;
LODWORD(v26[1].m_sAdditionalTransform.b) = v27;
m_editorLayer = a1->m_editorLayer;
LevelEditorLayer::removeSpecial(m_editorLayer, v26);
LevelEditorLayer::addSpecial(m_editorLayer, v26);
v29 = a1->m_editorLayer->__vftable;
cocos2d::CCPoint::CCPoint(&v73, x, 0.0);
v31 = ((double (__fastcall *)(LevelEditorLayer *, __int64, _QWORD, _QWORD, _BYTE, _DWORD, _DWORD))v29->timeForPos)(
a1->m_editorLayer,
v30,
0,
0,
0,
0,
v61);
v32 = *(float *)&v31;
v33 = 0;
cocos2d::CCPoint::CCPoint(&v63);
rand();
v34 = y + 60.0;
v35 = 0.0;
v36 = NextFreeGroupID;
v65 = (cocos2d::CCArray *)cocos2d::CCArray::create(v37);
v38 = 0;
v39 = 0;
for ( j = v62; v39 < cocos2d::CCArray::count(j); v38 = 0 )
{
v74 = v36;
v75 = cocos2d::CCArray::count(j) - 1;
v41 = (cocos2d::CCArray *)cocos2d::CCArray::objectAtIndex(j, v39);
v66 = v41;
LODWORD(v73.x) = v36;
if ( v39 >= cocos2d::CCArray::count(j) - 1 )
{
v47 = v33;
}
else
{
v42 = (cocos2d::CCArray *)cocos2d::CCArray::objectAtIndex(j, v39 + 1);
v43 = cocos2d::CCArray::objectAtIndex(v42, 0);
v44 = (float *)((__int64 (__fastcall *)(struct cocos2d::CCObject *, _BYTE *))v43->__vftable[16].encodeWithCoder)(
v43,
v67);
v45 = a1->m_editorLayer->__vftable;
cocos2d::CCPoint::CCPoint(&v68, *v44, 0.0);
LOBYTE(v60) = 0;
*(double *)&y_low = ((double (__fastcall *)(LevelEditorLayer *, __int64, _QWORD, _QWORD, int, _DWORD))v45->timeForPos)(
a1->m_editorLayer,
v46,
0,
0,
v60,
0);
v47 = y_low;
*(float *)&v47 = *(float *)&y_low - v32;
j = v62;
}
if ( cocos2d::CCArray::count(v41) )
{
do
{
v48 = cocos2d::CCArray::objectAtIndex(v41, v38);
v49 = a1->m_editorLayer;
if ( ((unsigned int (__fastcall *)(struct cocos2d::CCObject *, _QWORD))v48->__vftable[19].setTag)(
v48,
LODWORD(v73.x)) == 1 )
v49->addToGroup(v49, (GameObject *)v48, LODWORD(v73.x), 0);
if ( !v38 )
{
v33 = v47;
v51 = v75;
if ( v39 == v75 )
{
v36 = v76;
}
else
{
LODWORD(v61) = 0;
sub_14005E660((__int64)v72, &v61, v50);
v3 |= 2u;
LODWORD(v61) = v3;
v36 = LevelEditorLayer::getNextFreeGroupID(a1->m_editorLayer, v72);
}
if ( (v3 & 2) != 0 )
{
v3 &= ~2u;
sub_14005D100((__int64)&v72[0]._Vec);
sub_14005D870((void **)&v72[0]._List._Mypair._Myval2._Myhead);
}
if ( v39 != v51 )
{
v33 = v47;
*(float *)&v33 = *(float *)&v47 - v35;
}
v52 = (float *)((__int64 (__fastcall *)(struct cocos2d::CCObject *, _BYTE *))v48->__vftable[16].encodeWithCoder)(
v48,
v69);
cocos2d::CCPoint::CCPoint(&v70, *v52, v34);
cocos2d::CCPoint::operator=(&v63, v53);
cocos2d::CCPoint::CCPoint(&v71, &v63);
v55 = EditorUI::createObject(a1, 1268, v54);
cocos2d::CCArray::addObject(v65, v55);
v56 = a1->m_editorLayer;
if ( v55->addToGroup(v55, v74) == 1 )
v56->addToGroup(v56, v55, v74, 0);
v57 = v36;
if ( v36 < 0 )
v57 = 0;
if ( v57 > 9999 )
v57 = 9999;
LODWORD(v55[1].m_sAdditionalTransform.b) = v57;
*(_DWORD *)&v55[1].m_bUseVertexMod = v33;
BYTE1(v55[1].m_sAdditionalTransform.d) = 1;
LOBYTE(v55[1].CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCRGBAProtocol::__vftable) = 1;
v58 = a1->m_editorLayer;
LevelEditorLayer::removeSpecial(v58, v55);
LevelEditorLayer::addSpecial(v58, v55);
v35 = v35 + *(float *)&v33;
}
++v38;
v41 = v66;
}
while ( v38 < cocos2d::CCArray::count(v66) );
j = v62;
}
++v39;
}
v59 = a1->m_editorLayer;
*(_DWORD *)&v59->m_triggersChanged = 16843009;
v59->m_spawnTriggersChanged = 1;
}
}