//
// EditorUI::createLoop from 0x39dbf4 to 0x39dfc2 (974 bytes)
//
// 1 xrefs:
// > EditorPauseLayer::onCreateLoop @ 0x3ff2a4
//
// 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 EditorUI::createLoop(EditorUI *a1)
{
EditorUI *v1; // r4
cocos2d::CCArray *v2; // r0
cocos2d::CCObject *m_selectedObject; // r1
cocos2d::CCArray *v4; // r7
unsigned int v5; // r5
GameObject *v6; // r0
float v7; // s16
unsigned int v8; // r8
float v9; // s17
cocos2d::CCArray *v10; // r0
cocos2d::CCArray *v11; // r6
cocos2d::CCObject *v12; // r0
cocos2d::CCObject *v13; // r5
int v14; // r2
bool v15; // r3
float v16; // s18
float v17; // s17
cocos2d::CCArray *v18; // r0
cocos2d::CCArray *Object; // r11
int v20; // r0
float v21; // s16
cocos2d::CCArray *v22; // r0
cocos2d::CCObject *v23; // r1
LevelEditorLayer *m_editorLayer; // r5
float v25; // s18
cocos2d::CCPoint v26; // r2
EffectGameObject *v27; // r5
LevelEditorLayer *v28; // r8
unsigned int v29; // r5
float v30; // r1
float v31; // s17
float (__fastcall *timeForPos)(LevelEditorLayer *__hidden, cocos2d::CCPoint, int, int, bool, int); // r9
float v33; // s20
cocos2d::CCArray *v34; // r0
float v35; // s16
int v36; // r9
cocos2d::CCArray *v37; // r0
int v38; // r0
LevelEditorLayer *v39; // r10
float (__fastcall *v40)(LevelEditorLayer *__hidden, cocos2d::CCPoint, int, int, bool, int); // r8
float v41; // s19
int v42; // r10
unsigned int i; // r8
GameObject *v44; // r11
LevelEditorLayer *v45; // r10
int v46; // r2
bool v47; // r3
cocos2d::CCPoint v48; // r2
GameObject *v49; // r11
LevelEditorLayer *v50; // r0
cocos2d::CCArray *v51; // r11
int NextFreeGroupID; // [sp+Ch] [bp-68h]
cocos2d::CCArray *v53; // [sp+10h] [bp-64h]
cocos2d::CCArray *v54; // [sp+1Ch] [bp-58h]
int v55; // [sp+20h] [bp-54h]
cocos2d::CCPoint v56; // [sp+38h] [bp-3Ch] BYREF
cocos2d::CCPoint v57; // [sp+40h] [bp-34h] BYREF
float v58; // [sp+48h] [bp-2Ch] BYREF
float v59; // [sp+4Ch] [bp-28h]
std::unordered_set v60; // [sp+50h] [bp-24h] BYREF
v1 = a1;
if ( a1->m_selectedObject || (a1 = (EditorUI *)cocos2d::CCArray::count(a1->m_selectedObjects)) != nullptr )
{
v2 = (cocos2d::CCArray *)cocos2d::CCArray::create((cocos2d::CCArray *)a1);
m_selectedObject = v1->m_selectedObject;
v4 = v2;
if ( m_selectedObject )
cocos2d::CCArray::addObject(v2, m_selectedObject);
else
cocos2d::CCArray::addObjectsFromArray(v2, v1->m_selectedObjects);
v5 = 0;
while ( v5 < cocos2d::CCArray::count(v4) )
{
v6 = (GameObject *)cocos2d::CCArray::objectAtIndex(v4, v5);
if ( GameObject::isSpawnableTrigger(v6) )
++v5;
else
cocos2d::CCArray::removeObjectAtIndex(v4, v5, 1);
}
v7 = 0.0;
v8 = 0;
v9 = 0.0;
qsort(v4->data->arr, v4->data->num, 4u, (int (*)(const void *, const void *))alignXSort);
v11 = (cocos2d::CCArray *)cocos2d::CCArray::create(v10);
cocos2d::CCPoint::CCPoint(&v56);
while ( v8 < cocos2d::CCArray::count(v4) )
{
v12 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(v4, v8);
v13 = v12;
if ( !v8 )
{
((void (__fastcall *)(std::unordered_set *, cocos2d::CCObject *))v12->__vftable[16].getTag)(&v60, v12);
cocos2d::CCPoint::operator=((PlayerObject *)&v56, COERCE_FLOAT(&v60), v14, v15);
}
BYTE1(v13[24].m_unknown2) = 1;
LOBYTE(v13[28].m_uAutoReleaseCount) = 1;
((void (__fastcall *)(float *, cocos2d::CCObject *))v13->__vftable[16].getTag)(&v58, v13);
v16 = v58;
if ( v58 >= v9 && v9 != 0.0 )
v16 = v9;
v17 = v59;
if ( v59 <= v7 && v7 != 0.0 )
v17 = v7;
v18 = (cocos2d::CCArray *)cocos2d::CCArray::count(v11);
if ( v18
&& (Object = (cocos2d::CCArray *)cocos2d::CCArray::lastObject(v11),
v20 = cocos2d::CCArray::objectAtIndex(Object, 0),
v21 = v58,
v18 = (cocos2d::CCArray *)(*(int (__fastcall **)(std::unordered_set *, int))(*(_DWORD *)v20 + 672))(
&v60,
v20),
(float)(v21 - *(float *)&v60._M_h._M_buckets) <= 0.1) )
{
v22 = Object;
v23 = v13;
}
else
{
v51 = (cocos2d::CCArray *)cocos2d::CCArray::create(v18);
cocos2d::CCArray::addObject(v51, v13);
v22 = v11;
v23 = v51;
}
v7 = v17;
cocos2d::CCArray::addObject(v22, v23);
++v8;
v9 = v16;
}
m_editorLayer = v1->m_editorLayer;
std::_Hashtable,std::__detail::_Identity,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::_Hashtable(
&v60,
10);
NextFreeGroupID = LevelEditorLayer::getNextFreeGroupID(m_editorLayer, &v60);
std::_Hashtable,std::__detail::_Identity,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::~_Hashtable((int)&v60);
v25 = 0.0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v60, v9, v7 + 90.0);
LODWORD(v26.x) = &v60;
v27 = (EffectGameObject *)EditorUI::createObject(v1, 1268, v26);
EffectGameObject::setTargetID(v27, NextFreeGroupID);
LevelEditorLayer::refreshSpecial(v1->m_editorLayer, v27);
v28 = v1->m_editorLayer;
v29 = 0;
v30 = v9;
v31 = 0.0;
timeForPos = v28->timeForPos;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v60, v30, 0.0);
v33 = COERCE_FLOAT(
((int (__fastcall *)(LevelEditorLayer *, std::unordered_set *, _DWORD, _DWORD, _DWORD, _DWORD))timeForPos)(
v28,
&v60,
0,
0,
0,
0));
cocos2d::CCPoint::CCPoint(&v57);
v34 = (cocos2d::CCArray *)rand();
v35 = v7 + 60.0;
v36 = NextFreeGroupID;
v54 = (cocos2d::CCArray *)cocos2d::CCArray::create(v34);
while ( v29 < cocos2d::CCArray::count(v11) )
{
v55 = cocos2d::CCArray::count(v11) - 1;
v53 = (cocos2d::CCArray *)cocos2d::CCArray::objectAtIndex(v11, v29);
if ( v29 >= cocos2d::CCArray::count(v11) - 1 )
{
v41 = v31;
}
else
{
v37 = (cocos2d::CCArray *)cocos2d::CCArray::objectAtIndex(v11, v29 + 1);
v38 = cocos2d::CCArray::objectAtIndex(v37, 0);
(*(void (__fastcall **)(std::unordered_set *, int))(*(_DWORD *)v38 + 672))(&v60, v38);
v39 = v1->m_editorLayer;
v40 = v39->timeForPos;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v60, *(float *)&v60._M_h._M_buckets, 0.0);
v41 = ((float (__fastcall *)(LevelEditorLayer *, std::unordered_set *, _DWORD, _DWORD, _DWORD, _DWORD))v40)(
v39,
&v60,
0,
0,
0,
0)
- v33;
}
v42 = v36;
for ( i = 0; i < cocos2d::CCArray::count(v53); ++i )
{
v44 = (GameObject *)cocos2d::CCArray::objectAtIndex(v53, i);
LevelEditorLayer::addObjectToGroup(v1->m_editorLayer, v44, v36);
if ( !i )
{
if ( v29 == v55 )
{
v31 = v41;
v42 = NextFreeGroupID;
}
else
{
v45 = v1->m_editorLayer;
std::_Hashtable,std::__detail::_Identity,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::_Hashtable(
&v60,
10);
v42 = LevelEditorLayer::getNextFreeGroupID(v45, &v60);
std::_Hashtable,std::__detail::_Identity,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::~_Hashtable((int)&v60);
v31 = v41 - v25;
}
v44->getRealPosition((cocos2d::CCPoint *)&v58, v44);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v60, v58, v35);
cocos2d::CCPoint::operator=((PlayerObject *)&v57, COERCE_FLOAT(&v60), v46, v47);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v60, &v57);
LODWORD(v48.x) = &v60;
v49 = EditorUI::createObject(v1, 1268, v48);
cocos2d::CCArray::addObject(v54, v49);
LevelEditorLayer::addObjectToGroup(v1->m_editorLayer, v49, v36);
EffectGameObject::setTargetID((EffectGameObject *)v49, v42);
v50 = v1->m_editorLayer;
*(float *)&v49[1].m_followingSprite = v31;
BYTE1(v49[1].m_sAdditionalTransform.d) = 1;
LOBYTE(v49[1].m_transformToBatch.tx) = 1;
LevelEditorLayer::refreshSpecial(v50, v49);
v25 = v25 + v31;
}
}
++v29;
v36 = v42;
}
LevelEditorLayer::dirtifyTriggers(v1->m_editorLayer);
}
}