//
// EditorUI::onCreateObject from 0x1401b2930 to 0x1401b3297 (2407 bytes)
//
// 2 xrefs:
// > EditorUI::onCreate @ 0x1401b2697
// > ??> @ 0x140919fe8
//
// 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:56 +0000
//
// Hidden C++ exception states: #wind=2
struct cocos2d::CCObject *__fastcall EditorUI::onCreateObject(__int64 a1, int a2)
{
__int64 v4; // rax
float v5; // xmm3_4
float v6; // xmm2_4
float v7; // xmm1_4
int v8; // eax
unsigned __int8 v9; // di
char v10; // r14
int v11; // xmm6_4
_DWORD *v12; // rcx
double v13; // xmm0_8
__int64 v14; // rbx
cocos2d::CCPoint *v15; // rax
char *v16; // r8
__int64 v17; // rbx
int v18; // eax
unsigned int v19; // r14d
float *v20; // rax
float *v21; // r15
unsigned int v22; // edi
struct cocos2d::CCObject *v23; // rbx
__int64 v24; // rax
__int64 v25; // rbx
struct cocos2d::CCObject *v26; // rdi
__int64 v27; // rcx
__int64 v28; // rdx
int v29; // ecx
int v30; // eax
int v31; // ecx
__int64 v32; // rax
__int64 Object; // rax
struct cocos2d::CCObject *v34; // r15
__int64 v35; // rcx
__int64 v36; // rbx
__int64 v37; // rcx
struct cocos2d::CCObject *v38; // rdi
int v39; // ecx
int v40; // ecx
int v41; // ecx
bool v42; // zf
int v43; // ecx
int v44; // ecx
int v45; // ecx
int v46; // ecx
__int64 v47; // rbx
cocos2d::CCArray *v49; // r12
struct cocos2d::CCObject *v50; // rdx
__int64 v51; // rcx
__int64 v52; // rdx
int v53; // ecx
int v54; // eax
int v55; // ecx
_QWORD *v56; // rdx
size_t v57; // r8
cocos2d::CCArray *v58; // rax
cocos2d::CCArray *v59; // rdi
struct cocos2d::CCObject *v60; // r15
unsigned int v61; // ebx
__int64 v62; // rcx
__int64 v63; // rax
__int64 v64; // rax
unsigned int v65; // ebx
struct cocos2d::CCObject *v66; // r15
struct cocos2d::CCObject *v67; // r13
unsigned int v68; // ebx
struct cocos2d::CCObject *v69; // rax
unsigned int v70; // ebx
struct cocos2d::CCObject *v71; // rax
float (__fastcall *v72)(struct cocos2d::CCObject *); // rbx
double v73; // xmm0_8
float (__fastcall *v74)(struct cocos2d::CCObject *); // rbx
double v75; // xmm0_8
float v76; // xmm6_4
struct cocos2d::CCObject *v77; // rax
int v78; // ecx
int v79; // eax
int v80; // r8d
float v81; // [rsp+30h] [rbp-79h] BYREF
float v82; // [rsp+34h] [rbp-75h]
void *v83; // [rsp+38h] [rbp-71h] BYREF
char v84[8]; // [rsp+40h] [rbp-69h] BYREF
char v85[8]; // [rsp+48h] [rbp-61h] BYREF
char v86[8]; // [rsp+50h] [rbp-59h] BYREF
char v87[8]; // [rsp+58h] [rbp-51h] BYREF
__int128 v88; // [rsp+60h] [rbp-49h] BYREF
__int64 v89; // [rsp+70h] [rbp-39h]
__int64 v90; // [rsp+78h] [rbp-31h]
char v91[8]; // [rsp+80h] [rbp-29h] BYREF
char v92[8]; // [rsp+88h] [rbp-21h] BYREF
_QWORD v93[4]; // [rsp+90h] [rbp-19h] BYREF
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v83, (const struct cocos2d::CCPoint *)(a1 + 1560));
EditorUI::getGridSnappedPos(a1, &v81, v4);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v86, (const struct cocos2d::CCPoint *)&v81);
v5 = *(float *)(a1 + 696) * 0.5;
v6 = v81;
if ( v81 <= (float)(v5 - 3000.0) )
{
v6 = v5 - 3000.0;
v81 = v5 - 3000.0;
}
v7 = v82;
if ( v82 <= -3000.0 )
{
v7 = -3000.0;
v82 = -3000.0;
}
if ( v6 > (float)(240000.0 - v5) )
v81 = 240000.0 - v5;
v8 = 80;
if ( *(_BYTE *)(*(_QWORD *)(*(_QWORD *)(a1 + 1512) + 3528LL) + 461LL) )
v8 = 1000;
if ( v7 > (float)((float)((float)((float)v8 * 30.0) + 90.0) - v5) )
v82 = (float)((float)((float)v8 * 30.0) + 90.0) - v5;
offsetForKey((cocos2d::CCPoint *)v91, a2);
v9 = 0;
v10 = 0;
v11 = 0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v87);
v12 = *(_DWORD **)(a1 + 1568);
if ( v12 && v12[259] == a2 )
{
v9 = (*(__int64 (__fastcall **)(_DWORD *))(*(_QWORD *)v12 + 1272LL))(v12);
v10 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 1568) + 1280LL))(*(_QWORD *)(a1 + 1568));
v13 = (*(double (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 1568) + 360LL))(*(_QWORD *)(a1 + 1568));
v11 = LODWORD(v13);
v14 = *(_QWORD *)(a1 + 1568);
v15 = offsetForKey((cocos2d::CCPoint *)&v83, *(_DWORD *)(v14 + 1036));
GameToolbox::getRelativeOffset((cocos2d::CCPoint *)v85, v14, v15);
v16 = v85;
}
else
{
v16 = v91;
}
cocos2d::CCPoint::operator+(&v81, v84, v16);
cocos2d::CCPoint::operator=(v87, v84);
cocos2d::CCPoint::operator+(&v81, v84, v91);
cocos2d::CCPoint::operator=(&v81, v84);
v17 = *(_QWORD *)(a1 + 1512);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v83, (const struct cocos2d::CCPoint *)v87);
if ( !(unsigned __int8)LevelEditorLayer::typeExistsAtPosition(v17, a2, v18, v9, v10, v11) )
{
v19 = 0;
if ( a2 < 0 )
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v83, (const struct cocos2d::CCPoint *)v86);
v21 = v20;
v22 = 0;
if ( cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 928)) )
{
do
{
v23 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 928), v22);
if ( *(float *)(*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v23 + 200LL))(v23) == *v21
&& *(float *)((*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v23 + 200LL))(v23) + 4) == v21[1] )
{
goto LABEL_105;
}
}
while ( ++v22 < cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 928)) );
}
}
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v83, (const struct cocos2d::CCPoint *)v86);
v25 = v24;
v26 = (struct cocos2d::CCObject *)cocos2d::CCNode::create();
(*(void (__fastcall **)(struct cocos2d::CCObject *, __int64))(*(_QWORD *)v26 + 184LL))(v26, v25);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 928), v26);
if ( a2 <= 0 )
{
v49 = (cocos2d::CCArray *)cocos2d::CCArray::create(v27);
v50 = *(struct cocos2d::CCObject **)(a1 + 1568);
if ( v50 )
cocos2d::CCArray::addObject(v49, v50);
else
cocos2d::CCArray::addObjectsFromArray(v49, *(struct cocos2d::CCArray **)(a1 + 944));
v51 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v83 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager(v83);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v51 = qword_14090BFD0;
}
GameManager::stringForCustomObject(v51, v93, (unsigned int)a2);
if ( !*(_BYTE *)(a1 + 756) )
{
v52 = *(_QWORD *)(a1 + 1512);
v53 = *(_DWORD *)(v52 + 15504);
if ( v53 >= 0 )
{
v54 = *(_DWORD *)(v52 + 15440) - v53;
v55 = 0;
if ( v54 > 1 )
{
do
{
if ( v55 >= 7 )
break;
v54 = (unsigned int)v54 >> 1;
++v55;
}
while ( (unsigned int)v54 > 1 );
}
++*(_DWORD *)(v52 + 4LL * v55 + 15472);
}
*(_DWORD *)(v52 + 15504) = *(_DWORD *)(v52 + 15440);
}
*(_BYTE *)(a1 + 756) = 1;
v56 = v93;
if ( v93[3] > 0xFu )
v56 = (_QWORD *)v93[0];
v88 = 0;
v89 = 0;
v90 = 0;
v57 = -1;
do
++v57;
while ( *((_BYTE *)v56 + v57) );
sub_14003D230(&v88, v56, v57);
v58 = (cocos2d::CCArray *)EditorUI::pasteObjects(a1, &v88, 0, 0);
v59 = v58;
if ( v58 && cocos2d::CCArray::count(v58) )
{
v60 = nullptr;
v61 = 0;
if ( cocos2d::CCArray::count(v59) )
{
while ( 1 )
{
v60 = cocos2d::CCArray::objectAtIndex(v59, v61);
if ( *((_BYTE *)v60 + 1158) )
break;
if ( ++v61 >= cocos2d::CCArray::count(v59) )
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v85, (const struct cocos2d::CCPoint *)v86);
goto LABEL_82;
}
}
}
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v85, (const struct cocos2d::CCPoint *)v86);
if ( v60 )
{
EditorUI::getGroupCenter(v62, v84, v59, 0);
v63 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v60 + 200LL))(v60);
cocos2d::CCPoint::operator-(v84, v92, v63);
cocos2d::CCPoint::operator+(v85, &v83, v92);
cocos2d::CCPoint::operator=(v85, &v83);
}
LABEL_82:
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v83, (const struct cocos2d::CCPoint *)v85);
EditorUI::repositionObjectsToCenter(a1, v59, v64, 0);
v65 = cocos2d::CCArray::count(v59);
if ( v65 == cocos2d::CCArray::count(v49) )
{
v66 = nullptr;
v67 = nullptr;
v68 = 0;
if ( cocos2d::CCArray::count(v49) )
{
while ( 1 )
{
v69 = cocos2d::CCArray::objectAtIndex(v49, v68);
if ( *((_BYTE *)v69 + 1158) )
break;
if ( ++v68 >= cocos2d::CCArray::count(v49) )
goto LABEL_88;
}
v66 = v69;
}
LABEL_88:
v70 = 0;
if ( cocos2d::CCArray::count(v59) )
{
while ( 1 )
{
v71 = cocos2d::CCArray::objectAtIndex(v59, v70);
if ( *((_BYTE *)v71 + 1158) )
break;
if ( ++v70 >= cocos2d::CCArray::count(v59) )
goto LABEL_93;
}
v67 = v71;
}
LABEL_93:
if ( v66 )
{
if ( v67 )
{
if ( *((_DWORD *)v66 + 259) == *((_DWORD *)v67 + 259) )
{
v72 = *(float (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v67 + 360LL);
v73 = (*(double (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v66 + 360LL))(v66);
if ( *(float *)&v73 != v72(v67) )
{
v74 = *(float (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v67 + 360LL);
v75 = (*(double (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v66 + 360LL))(v66);
v76 = *(float *)&v75;
*(float *)&v75 = v74(v67);
if ( (int)(float)(v76 - *(float *)&v75) == 90 * ((int)(float)(v76 - *(float *)&v75) / 90)
|| !cocos2d::CCArray::count(v59) )
{
LABEL_103:
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v83,
(const struct cocos2d::CCPoint *)&dword_14090A6E8);
EditorUI::rotateObjects(a1, (_DWORD)v59, v80, v79, 0);
}
else
{
while ( 1 )
{
v77 = cocos2d::CCArray::objectAtIndex(v59, v19);
v78 = *((_DWORD *)v77 + 232);
if ( (!v78 || ((v78 - 21) & 0xFFFFFFFB) == 0) && !*((_BYTE *)v77 + 1222) )
break;
if ( ++v19 >= cocos2d::CCArray::count(v59) )
goto LABEL_103;
}
}
}
}
}
}
}
}
sub_14003D310((__int64)v93);
return nullptr;
}
if ( !*(_BYTE *)(a1 + 756) )
{
v28 = *(_QWORD *)(a1 + 1512);
v29 = *(_DWORD *)(v28 + 15504);
if ( v29 >= 0 )
{
v30 = *(_DWORD *)(v28 + 15440) - v29;
v31 = 0;
if ( v30 > 1 )
{
do
{
if ( v31 >= 7 )
break;
v30 = (unsigned int)v30 >> 1;
++v31;
}
while ( (unsigned int)v30 > 1 );
}
++*(_DWORD *)(v28 + 4LL * v31 + 15472);
}
*(_DWORD *)(v28 + 15504) = *(_DWORD *)(v28 + 15440);
}
*(_BYTE *)(a1 + 756) = 1;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v83, (const struct cocos2d::CCPoint *)&v81);
Object = EditorUI::createObject(a1, (unsigned int)a2, v32);
v34 = (struct cocos2d::CCObject *)Object;
v35 = *(_QWORD *)(a1 + 1568);
if ( v35 && *(_DWORD *)(Object + 1036) == *(_DWORD *)(v35 + 1036) )
{
EditorUI::removeOffset(a1, Object);
GameObject::duplicateValues(v34, *(_QWORD *)(a1 + 1568));
EditorUI::applyOffset(a1, v34);
}
if ( a2 == 914 )
{
v88 = 0;
v89 = 1;
v90 = 15;
LOWORD(v88) = 65;
TextGameObject::updateTextObject(v34, &v88, 0);
}
else if ( a2 == 3032 )
{
LevelEditorLayer::removeSpecial(*(_QWORD *)(a1 + 1512), v34);
v36 = *(_QWORD *)(a1 + 1512);
v38 = (struct cocos2d::CCObject *)cocos2d::CCArray::create(v37);
(*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)v38 + 64LL))(
v38,
*(unsigned int *)(v36 + 13880));
cocos2d::CCDictionary::setObject(*(cocos2d::CCDictionary **)(v36 + 13872), v38, *(int *)(v36 + 13880));
++*(_DWORD *)(v36 + 13880);
*((_DWORD *)v34 + 468) = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v38 + 56LL))(v38);
*((_DWORD *)v34 + 469) = 0;
LevelEditorLayer::addSpecial(*(_QWORD *)(a1 + 1512), v34);
}
EditorUI::selectObject(a1, v34, 0);
if ( !v34 || *((_DWORD *)v34 + 314) != 1 )
{
LABEL_57:
EditorUI::updateSlider(a1);
return v34;
}
v39 = *((_DWORD *)v34 + 259);
if ( v39 > 1934 )
{
v43 = v39 - 1935;
if ( v43 )
{
v44 = v43 - 965;
if ( v44 )
{
v45 = v44 - 2;
if ( v45 )
{
v46 = v45 - 120;
if ( v46 )
{
v42 = v46 == 5;
goto LABEL_52;
}
}
}
}
}
else if ( v39 != 1934 )
{
if ( v39 > 203 )
{
if ( v39 != 1334 )
{
v42 = v39 == 1917;
goto LABEL_52;
}
}
else if ( v39 != 203 )
{
v40 = v39 - 200;
if ( v40 )
{
v41 = v40 - 1;
if ( v41 )
{
v42 = v41 == 1;
LABEL_52:
if ( !v42
&& (!(*(unsigned __int8 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v34 + 1528LL))(v34)
|| !*((_BYTE *)v34 + 1796)) )
{
goto LABEL_57;
}
}
}
}
}
*((_BYTE *)v34 + 1784) = 1;
v47 = *(_QWORD *)(*(_QWORD *)(a1 + 1512) + 14944LL);
if ( !cocos2d::CCArray::containsObject(*(cocos2d::CCArray **)(v47 + 592), v34) )
{
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(v47 + 592), v34);
*(_BYTE *)(v47 + 633) = 1;
EffectGameObject::updateSpeedModType(v34);
}
goto LABEL_57;
}
LABEL_105:
cocos2d::CCPoint::operator=(a1 + 920, &dword_14090A6E8);
return nullptr;
}