//
// SetupSmartBlockLayer::onCreateAll from 0x9dc548 to 0x9dc7b0 (616 bytes)
//
// 3 xrefs:
// > ??> @ 0x5ec68
// > SetupSmartBlockLayer::init @ 0x9dd0cc
// > ??> @ 0x122b100
//
// 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 SetupSmartBlockLayer::onCreateAll(SetupSmartBlockLayer *a1, cocos2d::CCObject *a2)
{
GameLevelManager *v2; // x0
GJSmartTemplate *ActiveSmartTemplate; // x0
GJSmartTemplate *v4; // x26
cocos2d::CCDictionary *m_prefabArrays; // x0
unsigned int v6; // w28
cocos2d::CCString *v7; // x0
char *CString; // x0
cocos2d::CCArray *v9; // x21
unsigned int v10; // w19
__int64 v11; // x22
EditorUI *m_editorUI; // x23
void *v13; // x0
unsigned int *v14; // x1
int v15; // w2
char *v16; // x0
unsigned int *v17; // x1
int v18; // w2
_QWORD v19[13]; // [xsp+0h] [xbp+0h] BYREF
cocos2d::CCDictionary *v20; // [xsp+68h] [xbp+68h]
cocos2d::CCArray *v21; // [xsp+70h] [xbp+70h]
__int64 v22; // [xsp+78h] [xbp+78h]
char v23; // [xsp+80h] [xbp+80h] BYREF
std::string v24; // [xsp+88h] [xbp+88h] BYREF
__int64 v25; // [xsp+90h] [xbp+90h] BYREF
v2 = GameLevelManager::sharedState();
ActiveSmartTemplate = GameLevelManager::getActiveSmartTemplate(v2);
v4 = ActiveSmartTemplate;
if ( ActiveSmartTemplate )
{
m_prefabArrays = ActiveSmartTemplate->m_prefabArrays;
v20 = m_prefabArrays;
v4->m_prefabIndex = 0;
if ( m_prefabArrays )
{
v21 = cocos2d::CCDictionary::allKeys(m_prefabArrays);
v19[12] = &v23;
v6 = 0;
while ( v6 < (unsigned int)cocos2d::CCArray::count(v21) )
{
v22 = 19062784;
v7 = cocos2d::CCArray::stringAtIndex(v21, v6);
CString = (char *)cocos2d::CCString::getCString(v7);
sub_D153B8((unsigned int)v19 + 136, CString);
v9 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(v20, &v24);
v10 = 0;
v22 = 19062784;
while ( v10 < (unsigned int)cocos2d::CCArray::count(v9) )
{
v11 = cocos2d::CCArray::objectAtIndex(v9, v10);
m_editorUI = GameManager::sharedState()->m_levelEditorLayer->m_editorUI;
sub_D18D28(&v25);
EditorUI::createPrefab(m_editorUI, v4, &v25, *(_DWORD *)(v11 + 72));
v13 = (void *)(v25 - 24);
if ( (__int64 *)(v25 - 24) == &qword_124B6B0 )
goto LABEL_7;
if ( &pthread_create )
{
v14 = (unsigned int *)(v25 - 8);
do
v15 = __ldaxr(v14);
while ( __stlxr(v15 - 1, v14) );
}
else
{
v15 = *(_DWORD *)(v25 - 8);
*(_DWORD *)(v25 - 8) = v15 - 1;
}
if ( v15 > 0 )
{
LABEL_7:
++v10;
}
else
{
++v10;
operator delete(v13);
}
}
v16 = (char *)v24.m_data.m_data - 24;
if ( (__int64 *)v24.m_data.m_data - 3 == &qword_124B6B0 )
goto LABEL_15;
if ( &pthread_create )
{
v17 = (unsigned int *)((char *)v24.m_data.m_data - 8);
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 - 1, v17) );
}
else
{
v18 = *((_DWORD *)v24.m_data.m_data - 2);
*((_DWORD *)v24.m_data.m_data - 2) = v18 - 1;
}
if ( v18 > 0 )
{
LABEL_15:
++v6;
}
else
{
++v6;
operator delete(v16);
}
}
}
}
}