//
// EditorUI::createPrefab from 0x486fac to 0x487232 (646 bytes)
//
// 2 xrefs:
// > BrowseSmartTemplateLayer::createPrefab @ 0x673db0
// > SetupSmartBlockLayer::onCreateAll @ 0x6740d8
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 11:49:26 +0000
//
unsigned int __fastcall EditorUI::createPrefab(int a1, int a2, unsigned __int8 *a3, int a4)
{
cocos2d::CCDirector *v8; // r0
const cocos2d::CCPoint *v9; // r6
unsigned int v10; // r11
unsigned int result; // r0
unsigned int v12; // r2
std::logic_error *exception; // r4
unsigned __int8 *v14; // r2
int v15; // r9
int PrefabWithID; // r7
cocos2d::CCArray *v17; // r7
GameObject *v18; // [sp+Ch] [bp-40h]
GameObject *Object; // [sp+Ch] [bp-40h]
float v20[2]; // [sp+10h] [bp-3Ch] BYREF
float v21[2]; // [sp+18h] [bp-34h] BYREF
_BYTE v22[8]; // [sp+20h] [bp-2Ch] BYREF
float v23; // [sp+28h] [bp-24h] BYREF
float v24; // [sp+2Ch] [bp-20h]
_BYTE v25[8]; // [sp+30h] [bp-1Ch] BYREF
int v26[3]; // [sp+38h] [bp-14h] BYREF
v8 = (cocos2d::CCDirector *)EditorBuildStats::noteAction((EditorBuildStats *)(*(_DWORD *)(a1 + 944) + 12104));
cocos2d::CCDirector::sharedDirector(v8);
cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)v20);
v9 = *(const cocos2d::CCPoint **)(*(_DWORD *)(a1 + 944) + 2436);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v25,
v20[0] * 0.5,
(float)(*(float *)(a1 + 632) * 0.5) + (float)(v20[1] * 0.5));
cocos2d::CCNode::convertToNodeSpace((cocos2d::CCNode *)v21, v9);
v10 = 0;
v21[0] = v21[0] + (float)((float)(4 * *(_DWORD *)(a2 + 124)) * 30.0);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v23, (const cocos2d::CCPoint *)v21);
EditorUI::getGridSnappedPos((int)v25, a1, &v23);
cocos2d::CCPoint::operator=(v21, v25);
++*(_DWORD *)(a2 + 124);
result = cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v22, (const cocos2d::CCPoint *)&flt_D2B938);
do
{
v12 = *a3;
if ( (v12 & 1) != 0 )
{
if ( v10 >= *((_DWORD *)a3 + 1) )
goto LABEL_6;
v14 = *((unsigned __int8 **)a3 + 2);
}
else
{
if ( v10 >= v12 >> 1 )
{
LABEL_6:
exception = (std::logic_error *)_cxa_allocate_exception(8u);
std::logic_error::logic_error(exception, "basic_string");
*(_DWORD *)exception = &off_D1548C;
_cxa_throw(
exception,
(struct type_info *)&`typeinfo for'std::out_of_range,
(void (*)(void *))std::length_error::~length_error);
}
v14 = a3 + 1;
}
v15 = v14[v10];
if ( v15 != 48 )
{
GJSmartTemplate::offsetForType(&v23, v14[v10]);
if ( v10 )
{
if ( v10 == 1 || v10 - 5 <= 1 )
v24 = v24 + 30.0;
if ( v10 == 2 )
{
LABEL_17:
v24 = v24 - 30.0;
LABEL_18:
if ( (v10 & 0xFFFFFFFB) == 3 || v10 == 5 )
v23 = v23 - 30.0;
if ( (v10 & 0xFFFFFFFD) == 4 || v10 == 8 )
v23 = v23 + 30.0;
v18 = (GameObject *)GJSmartTemplate::smartTypeToObjectKey(v15);
cocos2d::CCPoint::operator+(v25, v21, &v23);
Object = EditorUI::createObject(a1, v18, (const cocos2d::CCPoint *)v25);
result = GJSmartTemplate::applyTransformationsForType(v15, Object);
if ( v10 )
{
*((_BYTE *)Object + 1167) = 1;
result = SmartGameObject::updateSmartFrame(Object);
}
goto LABEL_26;
}
}
else
{
cocos2d::CCPoint::operator=(v22, &v23);
}
if ( v10 - 7 > 1 )
goto LABEL_18;
goto LABEL_17;
}
LABEL_26:
++v10;
}
while ( v10 != 9 );
if ( a4 > 0 )
{
std::string::basic_string(v26, (int)a3);
PrefabWithID = GJSmartTemplate::getPrefabWithID(a2, v26, a4);
result = std::string::~string((int)v26);
if ( PrefabWithID )
{
std::string::basic_string(v26, PrefabWithID + 64);
v17 = (cocos2d::CCArray *)EditorUI::pasteObjects(a1, (int)v26);
result = std::string::~string((int)v26);
if ( v17 )
{
cocos2d::CCPoint::operator+(v25, v21, v22);
EditorUI::repositionObjectsToCenter(a1, v17, v25, 0);
return EditorUI::deleteSmartBlocksFromObjects((GJBaseGameLayer **)a1, v17);
}
}
}
return result;
}