//
// EditorUI::createPrefab from 0x1000147a0 to 0x100014cc5 (1317 bytes)
//
// 2 xrefs:
// > SetupSmartBlockLayer::onCreateAll @ 0x1004e1be1
// > BrowseSmartTemplateLayer::createPrefab @ 0x1004e51db
//
// 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 12:18:54 +0000
//
void __fastcall EditorUI::createPrefab(__int64 a1, __int64 a2, std::string *a3, int a4)
{
__int64 v5; // rdi
__int64 v6; // rax
__int64 v7; // r14
float v8; // xmm0_4
__m128 v9; // xmm1
__m128 v10; // xmm3
std::string *v11; // r14
unsigned int v12; // ebx
unsigned int v13; // r15d
__int64 v14; // r14
__int64 Object; // rax
__int64 v16; // r14
std::string::size_type v17; // r13
__int64 v18; // rbx
unsigned int v19; // r12d
int v20; // eax
int v21; // eax
unsigned int v22; // r14d
__int64 v23; // r15
__int64 v24; // rax
__int64 v25; // r14
unsigned int v26; // ebx
__int64 PrefabWithID; // rbx
__int64 v28; // rbx
__int64 v29; // rbx
__int64 v30; // r15
__int128 v31; // [rsp+10h] [rbp-B0h] BYREF
void *__p; // [rsp+20h] [rbp-A0h] BYREF
__int128 v33; // [rsp+30h] [rbp-90h] BYREF
void *v34; // [rsp+40h] [rbp-80h]
float v35[2]; // [rsp+48h] [rbp-78h] BYREF
char v36[8]; // [rsp+50h] [rbp-70h] BYREF
void **p_p; // [rsp+58h] [rbp-68h]
char v38[8]; // [rsp+64h] [rbp-5Ch] BYREF
int v39; // [rsp+6Ch] [rbp-54h]
std::string *v40; // [rsp+70h] [rbp-50h]
char v41[8]; // [rsp+78h] [rbp-48h] BYREF
float v42; // [rsp+80h] [rbp-40h] BYREF
__int64 v43; // [rsp+88h] [rbp-38h]
float v44; // [rsp+90h] [rbp-30h] BYREF
float v45; // [rsp+94h] [rbp-2Ch]
v39 = a4;
v40 = a3;
v5 = *(_QWORD *)(a1 + 1440) + 14704LL;
EditorBuildStats::noteAction(v5);
v6 = cocos2d::CCDirector::sharedDirector(v5, a2);
cocos2d::CCDirector::getWinSize(v35, v6);
v7 = *(_QWORD *)(*(_QWORD *)(a1 + 1440) + 3920LL);
sub_100278250(v41, v35[0] * 0.5, (float)(*(float *)(a1 + 856) * 0.5) + (float)(v35[1] * 0.5));
cocos2d::CCNode::convertToNodeSpace(&v42, v7, v41);
v42 = (float)((float)(4 * *(_DWORD *)(a2 + 196)) * 30.0) + v42;
sub_1002782D0(&v44, &v42);
LODWORD(v43) = *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 1440) + 14288LL) + 604LL);
v8 = fmodf(90.0, *(float *)&v43);
v9 = (__m128)LODWORD(v44);
v10 = (__m128)LODWORD(v45);
v9.f32[0] = v44 / *(float *)&v43;
v10.f32[0] = (float)(v45 - v8) / *(float *)&v43;
sub_100278250(
v41,
(float)(_mm_round_ss((__m128)0LL, v9, 9).f32[0] + 0.5) * *(float *)&v43,
(float)((float)(_mm_round_ss((__m128)0LL, v10, 9).f32[0] + 0.5) * *(float *)&v43) + v8);
v43 = a1;
v11 = v40;
EditorUI::getLimitedPosition(v38, a1, v41);
sub_100278300(&v42, v38);
++*(_DWORD *)(a2 + 196);
sub_1002782D0(v38, &qword_100BE0DD8);
v12 = *std::string::at(v11, 0);
if ( v12 != 48 )
{
GJSmartTemplate::offsetForType(&v44, v12);
sub_100278300(v38, &v44);
v13 = GJSmartTemplate::smartTypeToObjectKey(v12);
sub_100278350(v36, &v42, &v44);
v14 = *(_QWORD *)(v43 + 1440);
sub_1002782D0(v41, v36);
Object = LevelEditorLayer::createObject(v14, v13, v41, 0);
v16 = Object;
if ( Object && (*(float *)(Object + 1312) != 1.0 || *(float *)(Object + 1316) != 1.0) )
{
GameObject::updateCustomScaleX(Object);
GameObject::updateCustomScaleY(v16, *(float *)(v16 + 1316));
}
GJSmartTemplate::applyTransformationsForType(v12, v16);
v11 = v40;
}
p_p = &__p;
v17 = 1;
v18 = 8;
do
{
v19 = *std::string::at(v11, v17);
if ( v19 != 48 )
{
GJSmartTemplate::offsetForType(&v44, v19);
if ( (unsigned int)v17 <= 6 )
{
v20 = 98;
if ( _bittest(&v20, v17) )
v45 = v45 + 30.0;
}
if ( (unsigned int)v17 <= 8 )
{
v21 = 388;
if ( _bittest(&v21, v17) )
v45 = v45 + -30.0;
}
if ( v18 == 4 || (v17 & 0xB) == 3 )
v44 = v44 + -30.0;
if ( v18 == 1 || (v17 & 0xD) == 4 )
v44 = v44 + 30.0;
v22 = GJSmartTemplate::smartTypeToObjectKey(v19);
sub_100278350(v36, &v42, &v44);
v23 = *(_QWORD *)(v43 + 1440);
sub_1002782D0(v41, v36);
v24 = LevelEditorLayer::createObject(v23, v22, v41, 0);
v25 = v24;
if ( v24 && (*(float *)(v24 + 1312) != 1.0 || *(float *)(v24 + 1316) != 1.0) )
{
GameObject::updateCustomScaleX(v24);
GameObject::updateCustomScaleY(v25, *(float *)(v25 + 1316));
}
GJSmartTemplate::applyTransformationsForType(v19, v25);
*(_BYTE *)(v25 + 1347) = 1;
SmartGameObject::updateSmartFrame(v25);
v11 = v40;
}
++v17;
--v18;
}
while ( v18 );
v26 = v39;
if ( v39 > 0 )
{
if ( (*(_BYTE *)&v11->__r_.__value_.__s.0 & 1) != 0 )
{
sub_10001AD30(&v31, v11->__r_.__value_.__r.__words[2], v11->__r_.__value_.__l.__size_);
}
else
{
__p = v11->__r_.__value_.__l.__data_;
v31 = *(_OWORD *)&v11->__r_.__value_.__l.0;
}
PrefabWithID = GJSmartTemplate::getPrefabWithID(a2, &v31, v26);
if ( (v31 & 1) != 0 )
operator delete(__p);
if ( PrefabWithID )
{
if ( (*(_BYTE *)(PrefabWithID + 80) & 1) != 0 )
{
sub_10001AD30(&v33, *(_QWORD *)(PrefabWithID + 96), *(_QWORD *)(PrefabWithID + 88));
}
else
{
v28 = PrefabWithID + 80;
v34 = *(void **)(v28 + 16);
v33 = *(_OWORD *)v28;
}
v29 = EditorUI::pasteObjects(v43, &v33, 0, 0);
if ( (v33 & 1) != 0 )
operator delete(v34);
if ( v29 )
{
sub_100278350(v41, &v42, v38);
v30 = v43;
EditorUI::repositionObjectsToCenter(v43, v29, v41, 0);
EditorUI::deleteSmartBlocksFromObjects(v30, v29);
}
}
}
}