//
// EditorUI::createLoop from 0x6b66e8 to 0x6b6cdc (1524 bytes)
//
// 2 xrefs:
// > EditorPauseLayer::onCreateLoop @ 0x78ab78
// > ??> @ 0x76fe0
//
// 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)
{
GameObject *m_selectedObject; // x0
cocos2d::CCArray *v3; // x0
cocos2d::CCArray *v4; // x23
GameObject *v5; // x1
unsigned int i; // w19
GameObject *v7; // x0
float v8; // s10
unsigned int v9; // w21
float v10; // s11
cocos2d::CCArray *v11; // x0
__int64 v12; // x1
float v13; // s8
float v14; // s9
cocos2d::CCArray *v15; // x0
cocos2d::CCArray *v16; // x27
__int64 v17; // x0
__int64 v18; // x19
float v19; // s0
float v20; // s1
cocos2d::CCArray *Object; // x27
__int64 v22; // x0
float v23; // s10
LevelEditorLayer *m_editorLayer; // x19
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::_Hashtable_traits>::size_type v25; // x0
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::_Hashtable_traits>::__bucket_type *p_M_single_bucket; // x2
int v27; // w24
float v28; // s9
float v29; // s8
EffectGameObject *v30; // x19
LevelEditorLayer *v31; // x19
float (__fastcall *timeForPos)(LevelEditorLayer *__hidden, cocos2d::CCPoint, int, int, bool, int); // x21
float v33; // s13
cocos2d::CCArray *v34; // x0
float v35; // s11
float v36; // s10
cocos2d::CCArray *v37; // x23
unsigned int v38; // w19
int j; // w25
GameObject *v40; // x21
float v41; // s0
float v42; // s1
EffectGameObject *v43; // x21
LevelEditorLayer *v44; // x0
LevelEditorLayer *v45; // x25
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::_Hashtable_traits>::size_type v46; // x0
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::_Hashtable_traits>::__bucket_type *v47; // x2
cocos2d::CCArray *v48; // x0
__int64 v49; // x0
LevelEditorLayer *v50; // x19
float (__fastcall *v51)(LevelEditorLayer *__hidden, cocos2d::CCPoint, int, int, bool, int); // x21
cocos2d::CCArray *v52; // x0
cocos2d::CCArray *v53; // [xsp+98h] [xbp+98h]
int NextFreeGroupID; // [xsp+ACh] [xbp+ACh]
cocos2d::CCArray *v55; // [xsp+B0h] [xbp+B0h]
int v56; // [xsp+B8h] [xbp+B8h]
unsigned int v57; // [xsp+BCh] [xbp+BCh]
cocos2d::CCPoint v58; // [xsp+C8h] [xbp+C8h] BYREF
cocos2d::CCPoint v59; // [xsp+D0h] [xbp+D0h] BYREF
float v60; // [xsp+D8h] [xbp+D8h]
float v61; // [xsp+DCh] [xbp+DCh]
std::unordered_set v62; // [xsp+E0h] [xbp+E0h] BYREF
cocos2d::CCPoint v63; // 0:s0.4,4:s1.4
cocos2d::CCPoint v64; // 0:s0.4,4:s1.4
m_selectedObject = a1->m_selectedObject;
if ( m_selectedObject )
{
v3 = (cocos2d::CCArray *)cocos2d::CCArray::create((cocos2d::CCArray *)m_selectedObject);
v4 = v3;
v5 = a1->m_selectedObject;
if ( v5 )
{
LABEL_3:
cocos2d::CCArray::addObject(v3, v5);
goto LABEL_4;
}
}
else
{
v52 = (cocos2d::CCArray *)cocos2d::CCArray::count(a1->m_selectedObjects);
if ( !(_DWORD)v52 )
return;
v3 = (cocos2d::CCArray *)cocos2d::CCArray::create(v52);
v4 = v3;
v5 = a1->m_selectedObject;
if ( v5 )
goto LABEL_3;
}
cocos2d::CCArray::addObjectsFromArray(v3, a1->m_selectedObjects);
LABEL_4:
for ( i = 0; i < (unsigned int)cocos2d::CCArray::count(v4); cocos2d::CCArray::removeObjectAtIndex(v4, i, 1) )
{
while ( 1 )
{
v7 = (GameObject *)cocos2d::CCArray::objectAtIndex(v4, i);
if ( !GameObject::isSpawnableTrigger(v7) )
break;
if ( ++i >= (unsigned int)cocos2d::CCArray::count(v4) )
goto LABEL_8;
}
}
LABEL_8:
v8 = 0.0;
v9 = 0;
v10 = 0.0;
qsort(v4->data->arr, v4->data->num, 8u, (int (*)(const void *, const void *))alignXSort);
v53 = (cocos2d::CCArray *)cocos2d::CCArray::create(v11);
cocos2d::CCPoint::CCPoint(&v58);
while ( v9 < (unsigned int)cocos2d::CCArray::count(v4) )
{
v17 = cocos2d::CCArray::objectAtIndex(v4, v9);
v18 = v17;
if ( !v9 )
{
v19 = (*(float (__fastcall **)(__int64))(*(_QWORD *)v17 + 1344LL))(v17);
cocos2d::CCPoint::operator=(&v58, v19, v20);
}
v12 = *(_QWORD *)v18;
*(_BYTE *)(v18 + 1457) = 1;
*(_BYTE *)(v18 + 1648) = 1;
(*(void (__fastcall **)(__int64))(v12 + 1344))(v18);
v13 = v60;
if ( v10 <= v60 && v10 != 0.0 )
v13 = v10;
v14 = v61;
if ( v8 >= v61 && v8 != 0.0 )
v14 = v8;
v15 = (cocos2d::CCArray *)cocos2d::CCArray::count(v53);
if ( (_DWORD)v15
&& (Object = (cocos2d::CCArray *)cocos2d::CCArray::lastObject(v53),
v22 = cocos2d::CCArray::objectAtIndex(Object, 0),
v23 = v60,
v15 = (cocos2d::CCArray *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v22 + 1344LL))(v22),
(float)(v23 - *(float *)&v62._M_h._M_buckets) <= 0.1) )
{
cocos2d::CCArray::addObject(Object, (cocos2d::CCObject *)v18);
}
else
{
v16 = (cocos2d::CCArray *)cocos2d::CCArray::create(v15);
cocos2d::CCArray::addObject(v16, (cocos2d::CCObject *)v18);
cocos2d::CCArray::addObject(v53, v16);
}
v8 = v14;
++v9;
v10 = v13;
}
m_editorLayer = a1->m_editorLayer;
v62._M_h._M_before_begin._M_nxt = nullptr;
v62._M_h._M_element_count = 0;
v62._M_h._M_rehash_policy._M_max_load_factor = 1.0;
v62._M_h._M_rehash_policy._M_next_resize = 0;
v25 = sub_D146DC(&v62._M_h._M_rehash_policy, 10);
v62._M_h._M_bucket_count = v25;
if ( v25 == 1 )
{
v62._M_h._M_single_bucket = nullptr;
p_M_single_bucket = &v62._M_h._M_single_bucket;
}
else
{
p_M_single_bucket = (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::_Hashtable_traits>::__bucket_type *)sub_686A44(v25);
}
v62._M_h._M_buckets = p_M_single_bucket;
NextFreeGroupID = LevelEditorLayer::getNextFreeGroupID(m_editorLayer, &v62);
v27 = NextFreeGroupID;
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((__int64)&v62);
v57 = 0;
v28 = 0.0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v62, v10, v8 + 90.0);
v29 = 0.0;
v30 = (EffectGameObject *)EditorUI::createObject(a1, 1268, v63);
EffectGameObject::setTargetID(v30, NextFreeGroupID);
LevelEditorLayer::refreshSpecial(a1->m_editorLayer, v30);
v31 = a1->m_editorLayer;
timeForPos = v31->timeForPos;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v62, v10, 0.0);
v33 = ((float (__fastcall *)(LevelEditorLayer *, std::unordered_set *, _QWORD, _QWORD, _QWORD, _QWORD))timeForPos)(
v31,
&v62,
0,
0,
0,
0);
cocos2d::CCPoint::CCPoint(&v59);
v34 = (cocos2d::CCArray *)rand();
v35 = v8 + 60.0;
v55 = (cocos2d::CCArray *)cocos2d::CCArray::create(v34);
if ( (unsigned int)cocos2d::CCArray::count(v53) )
{
do
{
v36 = v29;
v56 = cocos2d::CCArray::count(v53) - 1;
v37 = (cocos2d::CCArray *)cocos2d::CCArray::objectAtIndex(v53, v57);
if ( v57 < (unsigned int)cocos2d::CCArray::count(v53) - 1 )
{
v48 = (cocos2d::CCArray *)cocos2d::CCArray::objectAtIndex(v53, v57 + 1);
v49 = cocos2d::CCArray::objectAtIndex(v48, 0);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v49 + 1344LL))(v49);
v50 = a1->m_editorLayer;
v51 = v50->timeForPos;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v62, *(float *)&v62._M_h._M_buckets, 0.0);
v36 = ((float (__fastcall *)(LevelEditorLayer *, std::unordered_set *, _QWORD, _QWORD, _QWORD, _QWORD))v51)(
v50,
&v62,
0,
0,
0,
0)
- v33;
}
v38 = 0;
for ( j = v27; v38 < (unsigned int)cocos2d::CCArray::count(v37); ++v38 )
{
v40 = (GameObject *)cocos2d::CCArray::objectAtIndex(v37, v38);
LevelEditorLayer::addObjectToGroup(a1->m_editorLayer, v40, v27);
if ( !v38 )
{
if ( v57 == v56 )
{
v29 = v36;
j = NextFreeGroupID;
}
else
{
v45 = a1->m_editorLayer;
v62._M_h._M_before_begin._M_nxt = nullptr;
v62._M_h._M_element_count = 0;
v62._M_h._M_rehash_policy._M_max_load_factor = 1.0;
v62._M_h._M_rehash_policy._M_next_resize = 0;
v46 = sub_D146DC(&v62._M_h._M_rehash_policy, 10);
v62._M_h._M_bucket_count = v46;
if ( v46 == 1 )
{
v62._M_h._M_single_bucket = nullptr;
v47 = &v62._M_h._M_single_bucket;
}
else
{
v47 = (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::_Hashtable_traits>::__bucket_type *)sub_686A44(v46);
}
v62._M_h._M_buckets = v47;
j = LevelEditorLayer::getNextFreeGroupID(v45, &v62);
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((__int64)&v62);
v29 = v36 - v28;
}
v40->getRealPosition(v40);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v62, v60, v35);
cocos2d::CCPoint::operator=(&v59, v41, v42);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v62, &v59);
v43 = (EffectGameObject *)EditorUI::createObject(a1, 1268, v64);
cocos2d::CCArray::addObject(v55, v43);
LevelEditorLayer::addObjectToGroup(a1->m_editorLayer, v43, v27);
EffectGameObject::setTargetID(v43, j);
v43->m_isSpawnTriggered = 1;
v44 = a1->m_editorLayer;
v43->m_isMultiTriggered = 1;
v43[1].m_fScaleX = v29;
LevelEditorLayer::refreshSpecial(v44, v43);
v28 = v28 + v29;
}
}
v27 = j;
++v57;
}
while ( v57 < (unsigned int)cocos2d::CCArray::count(v53) );
}
LevelEditorLayer::dirtifyTriggers(a1->m_editorLayer);
}