//
// EditorUI::createPrefab from 0x7c9b64 to 0x7c9fa0 (1084 bytes)
//
// 3 xrefs:
// > SetupSmartBlockLayer::onCreateAll @ 0xb15f80
// > BrowseSmartTemplateLayer::createPrefab @ 0xb16130
// > ??> @ 0xefab8
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:54:10 +0000
//
__int64 __fastcall EditorUI::createPrefab(__int64 a1, __int64 a2, char *a3, int a4)
{
__int64 v6; // x0
cocos2d::CCDirector *v8; // x0
cocos2d::CCDirector *v9; // x0
int v10; // w27
unsigned __int64 v11; // x19
float v12; // s2
char *v13; // x0
unsigned int v14; // w24
_BOOL4 v15; // w6
_BOOL4 v16; // w1
unsigned int v17; // w25
float *Object; // x25
char v19; // w0
__int64 v20; // x0
__int64 v21; // x1
__int64 PrefabWithID; // x19
__int64 v23; // x1
cocos2d::CCArray *v24; // x19
std::logic_error *exception; // x19
__int64 v27; // [xsp+0h] [xbp+0h] BYREF
_BYTE *v28; // [xsp+78h] [xbp+78h]
cocos2d::CCNode *v29; // [xsp+80h] [xbp+80h]
int v30; // [xsp+8Ch] [xbp+8Ch]
__int64 v31; // [xsp+98h] [xbp+98h] BYREF
__int64 v32; // [xsp+A0h] [xbp+A0h] BYREF
_BYTE v33[8]; // [xsp+A8h] [xbp+A8h] BYREF
float v34; // [xsp+B0h] [xbp+B0h] BYREF
float v35; // [xsp+B4h] [xbp+B4h]
__int64 v36; // [xsp+B8h] [xbp+B8h] BYREF
__int64 v37; // [xsp+C0h] [xbp+C0h] BYREF
__int64 v38; // [xsp+C8h] [xbp+C8h]
void *v39; // [xsp+D0h] [xbp+D0h]
v6 = *(_QWORD *)(a1 + 1440);
v30 = a4;
v28 = v33;
v8 = (cocos2d::CCDirector *)EditorBuildStats::noteAction((EditorBuildStats *)(v6 + 14704));
v9 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v8);
v10 = -4;
cocos2d::CCDirector::getWinSize(&v31, v9);
v11 = 0;
v12 = *(float *)(a1 + 856) * 0.5;
v29 = *(cocos2d::CCNode **)(*(_QWORD *)(a1 + 1440) + 3920LL);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v36, *(float *)&v31 * 0.5, v12 + (float)(*((float *)&v31 + 1) * 0.5));
cocos2d::CCNode::convertToNodeSpace(&v32, v29, (const cocos2d::CCPoint *)&v36);
*(float *)&v32 = *(float *)&v32 + (float)((float)(4 * *(_DWORD *)(a2 + 196)) * 30.0);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v34, (const cocos2d::CCPoint *)&v32);
EditorUI::getGridSnappedPos(a1, &v34, (__int64)&v36);
cocos2d::CCPoint::operator=(&v32, &v36);
++*(_DWORD *)(a2 + 196);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v33, (const cocos2d::CCPoint *)&dword_155C778);
do
{
if ( (*a3 & 1) != 0 )
{
if ( v11 >= *((_QWORD *)a3 + 1) )
goto LABEL_39;
v13 = *((char **)a3 + 2);
}
else
{
if ( v11 >= (unsigned __int8)*a3 >> 1 )
{
LABEL_39:
exception = (std::logic_error *)_cxa_allocate_exception(0x10u);
std::logic_error::logic_error(exception, "basic_string");
*(_QWORD *)exception = off_1536D68;
_cxa_throw(
exception,
(struct type_info *)&`typeinfo for'std::out_of_range,
(void (*)(void *))std::logic_error::~logic_error);
}
v13 = a3 + 1;
}
v14 = (unsigned __int8)v13[v11];
if ( v14 != 48 )
{
GJSmartTemplate::offsetForType((unsigned __int8)v13[v11]);
if ( v11 )
{
v15 = v11 == 5;
v16 = v11 == 6;
if ( (unsigned int)(v10 - 1) <= 1 || (_DWORD)v11 == 1 )
v35 = v35 + 30.0;
}
else
{
cocos2d::CCPoint::operator=(v28, &v34);
v16 = 0;
v15 = 0;
}
if ( (unsigned int)(v10 - 3) <= 1 || (_DWORD)v11 == 2 )
v35 = v35 - 30.0;
if ( v15 || (v11 & 0xFFFFFFFB) == 3 )
v34 = v34 - 30.0;
if ( v16 || (v10 & 0xFFFFFFFB) == 0 )
v34 = v34 + 30.0;
v17 = GJSmartTemplate::smartTypeToObjectKey(v14);
cocos2d::CCPoint::operator+(&v36, &v32);
Object = EditorUI::createObject(a1, v17, (const cocos2d::CCPoint *)&v36);
GJSmartTemplate::applyTransformationsForType(v14, (cocos2d::CCSprite *)Object);
if ( v11 )
{
*((_BYTE *)Object + 1347) = 1;
SmartGameObject::updateSmartFrame((SmartGameObject *)Object);
}
}
++v10;
++v11;
}
while ( v10 != 5 );
if ( v30 > 0 )
{
v19 = *a3;
v37 = 0;
v38 = 0;
v39 = nullptr;
if ( (v19 & 1) != 0 )
{
std::string::__init(&v37, *((void **)a3 + 2), *((_QWORD *)a3 + 1));
}
else
{
v20 = *(_QWORD *)a3;
v21 = *((_QWORD *)a3 + 1);
v39 = *((void **)a3 + 2);
v37 = v20;
v38 = v21;
}
PrefabWithID = GJSmartTemplate::getPrefabWithID(a2, &v37, (unsigned int)v30);
if ( (v37 & 1) != 0 )
operator delete(v39);
if ( PrefabWithID )
{
v37 = 0;
v38 = 0;
v39 = nullptr;
if ( (*(_BYTE *)(PrefabWithID + 80) & 1) != 0 )
{
std::string::__init(&v37, *(void **)(PrefabWithID + 96), *(_QWORD *)(PrefabWithID + 88));
}
else
{
v23 = *(_QWORD *)(PrefabWithID + 88);
v37 = *(_QWORD *)(PrefabWithID + 80);
v38 = v23;
v39 = *(void **)(PrefabWithID + 96);
}
v24 = (cocos2d::CCArray *)EditorUI::pasteObjects(a1, (unsigned int)&v27 + 192);
if ( (v37 & 1) != 0 )
operator delete(v39);
if ( v24 )
{
cocos2d::CCPoint::operator+(&v36, &v32);
EditorUI::repositionObjectsToCenter(a1, v24, &v36, 0);
EditorUI::deleteSmartBlocksFromObjects((GJBaseGameLayer **)a1, v24);
}
}
}
return _stack_chk_guard;
}