//
// EditorUI::createPrefab from 0x1401b7380 to 0x1401b7738 (952 bytes)
//
// 3 xrefs:
// > SetupSmartBlockLayer::onCreateAll @ 0x1405edce1
// > BrowseSmartTemplateLayer::createPrefab @ 0x1405f0ba7
// > ??> @ 0x14091a240
//
// This function is hookable on this platform (idp: pc, 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 11:27:58 +0000
//
// Hidden C++ exception states: #wind=1
void __fastcall EditorUI::createPrefab(__int64 a1, __int64 a2, _QWORD *a3, int a4)
{
__int64 v8; // rdx
__int64 v9; // rcx
int v10; // edi
int v11; // eax
__int64 v12; // rax
__int64 v13; // rbx
__int64 v14; // rax
__int64 v15; // rax
__int64 GridSnappedPos; // rax
__int64 v17; // rdx
__int64 v18; // rcx
__int64 v19; // r8
__int64 v20; // r9
__int64 v21; // r15
_QWORD *v22; // rax
unsigned int v23; // r14d
float v24; // xmm0_4
float v25; // xmm0_4
unsigned int v26; // edx
__int64 Object; // rbx
__int64 v28; // rax
__int64 PrefabWithID; // rax
__int64 v30; // rax
__int64 v31; // rbx
float v32; // [rsp+28h] [rbp-89h] BYREF
float v33; // [rsp+2Ch] [rbp-85h]
float v34; // [rsp+30h] [rbp-81h] BYREF
_BYTE v35[8]; // [rsp+38h] [rbp-79h] BYREF
__int64 v36; // [rsp+40h] [rbp-71h] BYREF
float v37[2]; // [rsp+48h] [rbp-69h] BYREF
_BYTE v38[8]; // [rsp+50h] [rbp-61h] BYREF
_BYTE v39[32]; // [rsp+58h] [rbp-59h] BYREF
_BYTE v40[32]; // [rsp+78h] [rbp-39h] BYREF
_QWORD *v41; // [rsp+98h] [rbp-19h]
v36 = a2;
v41 = a3;
v8 = *(_QWORD *)(a1 + 1512);
v9 = *(unsigned int *)(v8 + 15504);
v10 = 0;
if ( (int)v9 >= 0 )
{
v11 = *(_DWORD *)(v8 + 15440) - v9;
v9 = 0;
if ( v11 > 1 )
{
do
{
if ( (int)v9 >= 7 )
break;
v11 = (unsigned int)v11 >> 1;
v9 = (unsigned int)(v9 + 1);
}
while ( (unsigned int)v11 > 1 );
}
++*(_DWORD *)(v8 + 4LL * (int)v9 + 15472);
}
*(_DWORD *)(v8 + 15504) = *(_DWORD *)(v8 + 15440);
v12 = cocos2d::CCDirector::sharedDirector(v9);
cocos2d::CCDirector::getWinSize(v12, v37);
v13 = *(_QWORD *)(*(_QWORD *)(a1 + 1512) + 4296LL);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v35,
v37[0] * 0.5,
(float)(*(float *)(a1 + 904) * 0.5) + (float)(v37[1] * 0.5));
cocos2d::CCNode::convertToNodeSpace(v13, &v34, v14);
v34 = v34 + (float)((float)(4 * *(_DWORD *)(a2 + 204)) * 30.0);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v35, (const struct cocos2d::CCPoint *)&v34);
GridSnappedPos = EditorUI::getGridSnappedPos(a1, &v32, v15);
cocos2d::CCPoint::operator=(&v34, GridSnappedPos);
++*(_DWORD *)(a2 + 204);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v38, (const struct cocos2d::CCPoint *)&dword_14090A6E8);
v21 = 0;
do
{
if ( a3[2] <= (unsigned __int64)(unsigned int)v10 )
sub_14003F4D0(v18, v17, v19, v20);
v22 = a3;
if ( a3[3] > 0xFu )
v22 = (_QWORD *)*a3;
v23 = *((char *)v22 + v21);
if ( v23 != 48 )
{
GJSmartTemplate::offsetForType(&v32, v23);
if ( v10 )
{
if ( ((v10 - 1) & 0xFFFFFFFA) != 0 || v10 == 2 )
{
v24 = v33;
}
else
{
v24 = v33 + 30.0;
v33 = v33 + 30.0;
}
if ( v10 == 2 || (unsigned int)(v10 - 7) <= 1 )
v33 = v24 + -30.0;
if ( ((v10 - 3) & 0xFFFFFFF9) != 0 )
{
v25 = v32;
}
else
{
v25 = v32 + -30.0;
v32 = v32 + -30.0;
}
if ( ((v10 - 4) & 0xFFFFFFF9) == 0 )
v32 = v25 + 30.0;
}
else
{
cocos2d::CCPoint::operator=(v38, &v32);
}
cocos2d::CCPoint::operator+(&v34, v35, &v32);
switch ( v23 )
{
case '2':
case '3':
case '4':
case '5':
v26 = 2896;
break;
case '6':
case '7':
case '8':
case '9':
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
v26 = 2897;
break;
default:
v26 = 2895;
break;
}
Object = EditorUI::createObject(a1, v26, (const struct cocos2d::CCPoint *)v35);
GJSmartTemplate::applyTransformationsForType(v23, Object);
if ( v10 )
{
*(_BYTE *)(Object + 1360) = 1;
SmartGameObject::updateSmartFrame(Object);
}
}
++v10;
++v21;
}
while ( v10 < 9 );
if ( a4 > 0 )
{
v28 = sub_14003F4F0((__int64)v39, (__int64)a3);
PrefabWithID = GJSmartTemplate::getPrefabWithID(v36, v28, (unsigned int)a4);
if ( PrefabWithID )
{
v30 = sub_14003F4F0((__int64)v40, PrefabWithID + 88);
v31 = EditorUI::pasteObjects(a1, v30, 0, 0);
if ( v31 )
{
cocos2d::CCPoint::operator+(&v34, &v36, v38);
EditorUI::repositionObjectsToCenter(a1, v31, &v36, 0);
EditorUI::deleteSmartBlocksFromObjects(a1, v31);
}
}
}
sub_14003D310((__int64)a3);
}