//
// SetupSmartBlockLayer::onCreate from 0x140458490 to 0x1404588ba (1066 bytes)
//
// 2 xrefs:
// > SetupSmartBlockLayer::init @ 0x140456e49
// > ??> @ 0x1406daa54
//
// 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=3
void SetupSmartBlockLayer::onCreate(SetupSmartBlockLayer *a1, cocos2d::CCObject *a2)
{
cocos2d::CCArray *v3; // rax
cocos2d::CCArray *v4; // rsi
SmartGameObject *m_gameObject; // rdx
struct cocos2d::CCArray *m_gameObjects; // rdx
int m_specialTemplate; // ecx
bool v8; // bp
int v9; // ebx
int v10; // ecx
int v11; // ecx
int v12; // ecx
int v13; // ecx
int v14; // ecx
int v15; // ecx
int v16; // ecx
int v17; // eax
__int64 v18; // r8
__int64 v19; // rax
GJSmartTemplate *v20; // rbx
__int64 v21; // rcx
bool v22; // [rsp+30h] [rbp-18h]
int v23; // [rsp+50h] [rbp+8h]
void *v24; // [rsp+50h] [rbp+8h]
void *v25; // [rsp+50h] [rbp+8h]
void *v26; // [rsp+50h] [rbp+8h]
v3 = (cocos2d::CCArray *)cocos2d::CCArray::create(a1);
v4 = v3;
m_gameObject = a1->m_gameObject;
if ( m_gameObject )
{
cocos2d::CCArray::addObject(v3, m_gameObject);
}
else
{
m_gameObjects = a1->m_gameObjects;
if ( m_gameObjects )
cocos2d::CCArray::addObjectsFromArray(v3, m_gameObjects);
}
m_specialTemplate = a1->m_specialTemplate;
if ( m_specialTemplate >= 0 )
{
v8 = m_specialTemplate == 9;
if ( m_specialTemplate == 9 )
{
a1->m_specialTemplate = 8;
}
else
{
v9 = 1861;
if ( m_specialTemplate > 1861 )
{
if ( m_specialTemplate == 2703 )
{
qword_1406C2EB8 = 214013 * qword_1406C2EB8 + 2531011;
v9 = ((int)floorf(
(float)((float)(((unsigned __int64)qword_1406C2EB8 >> 16) & 0x7FFF) / 32767.0)
+ (float)((float)(((unsigned __int64)qword_1406C2EB8 >> 16) & 0x7FFF) / 32767.0)) != 0)
+ 2703;
goto LABEL_39;
}
v9 = 2838;
if ( m_specialTemplate == 2838 )
{
qword_1406C2EB8 = 214013 * qword_1406C2EB8 + 2531011;
if ( (int)floorf(
(float)((float)(((unsigned __int64)qword_1406C2EB8 >> 16) & 0x7FFF) / 32767.0)
+ (float)((float)(((unsigned __int64)qword_1406C2EB8 >> 16) & 0x7FFF) / 32767.0)) )
v9 = 2840;
goto LABEL_39;
}
}
else
{
if ( m_specialTemplate == 1861 )
{
qword_1406C2EB8 = 214013 * qword_1406C2EB8 + 2531011;
v15 = (int)floorf((float)((float)(((unsigned __int64)qword_1406C2EB8 >> 16) & 0x7FFF) / 32767.0) * 4.0);
if ( v15 )
{
v16 = v15 - 1;
if ( v16 )
{
if ( v16 == 1 )
v9 = 1863;
else
v9 = 1864;
}
else
{
v9 = 1862;
}
}
goto LABEL_39;
}
v10 = m_specialTemplate - 869;
if ( !v10 )
{
qword_1406C2EB8 = 214013 * qword_1406C2EB8 + 2531011;
v9 = ((int)floorf(
(float)((float)(((unsigned __int64)qword_1406C2EB8 >> 16) & 0x7FFF) / 32767.0)
+ (float)((float)(((unsigned __int64)qword_1406C2EB8 >> 16) & 0x7FFF) / 32767.0)) != 0)
+ 869;
goto LABEL_39;
}
v11 = v10 - 562;
if ( !v11 )
{
qword_1406C2EB8 = 214013 * qword_1406C2EB8 + 2531011;
v14 = (int)floorf((float)((float)(((unsigned __int64)qword_1406C2EB8 >> 16) & 0x7FFF) / 32767.0) * 3.0);
if ( v14 )
{
if ( v14 == 1 )
v9 = 1432;
else
v9 = 1433;
}
else
{
v9 = 1431;
}
goto LABEL_39;
}
if ( v11 == 30 )
{
qword_1406C2EB8 = 214013 * qword_1406C2EB8 + 2531011;
v12 = (int)floorf((float)((float)(((unsigned __int64)qword_1406C2EB8 >> 16) & 0x7FFF) / 32767.0) * 4.0);
if ( v12 )
{
v13 = v12 - 1;
if ( v13 )
{
if ( v13 == 1 )
v9 = 1463;
else
v9 = 1464;
}
else
{
v9 = 1462;
}
}
else
{
v9 = 1461;
}
goto LABEL_39;
}
}
}
v9 = v23;
LABEL_39:
if ( !qword_1406C2ED8 )
{
v24 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v24);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
}
v17 = EditorUI::smartTypeForKey(v9);
EditorUI::createSmartObjectsFromType(
*(EditorUI **)(*(_QWORD *)(v18 + 528) + 14496LL),
v17,
v4,
v8,
a1->m_dontDelete);
goto LABEL_47;
}
v19 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v25 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v25);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v19 = qword_1406C2EC0;
}
v20 = *(GJSmartTemplate **)(v19 + 960);
v21 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v26 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v26);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v21 = qword_1406C2ED8;
}
EditorUI::createSmartObjectsFromTemplate(
*(EditorUI **)(*(_QWORD *)(v21 + 528) + 14496LL),
v20,
v4,
a1->m_useNearby,
a1->m_dontDelete,
0,
v22);
LABEL_47:
SetupSmartBlockLayer::onClose(a1, nullptr);
}