//
// EditorUI::onCreateObject from 0x14010f5f0 to 0x14010ff16 (2342 bytes)
//
// 2 xrefs:
// > EditorUI::onCreate @ 0x14010f5c9
// > ??> @ 0x1406c8e68
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
// Hidden C++ exception states: #wind=2
void EditorUI::onCreateObject(EditorUI *a1, int a2)
{
float m_gridSize; // xmm8_4
float *v5; // rax
float v6; // xmm6_4
float v7; // xmm7_4
float v8; // xmm0_4
float v9; // xmm3_4
float x; // xmm2_4
float y; // xmm1_4
int v12; // eax
bool v13; // di
bool v14; // r14
float v15; // xmm6_4
GameObject *m_selectedObject; // rcx
double v17; // xmm0_8
GameObject *v18; // rbx
cocos2d::CCPoint v19; // rax
unsigned int v20; // r14d
float *v21; // rax
float *v22; // r15
unsigned int v23; // edi
struct cocos2d::CCObject *v24; // rbx
DS_Dictionary *v25; // rax
DS_Dictionary *v26; // rbx
struct cocos2d::CCObject *v27; // rdi
__int64 v28; // rcx
cocos2d::CCPoint v29; // rax
GameObject *Object; // rax
bool v31; // r8
GameObject *v32; // r15
GameObject *v33; // rcx
LevelEditorLayer *m_editorLayer; // rbx
__int64 v35; // rcx
struct cocos2d::CCObject *v36; // rdi
int m_objectID; // ecx
int v38; // ecx
int v39; // ecx
bool v40; // zf
int v41; // ecx
int v42; // ecx
int v43; // ecx
int v44; // ecx
DrawGridLayer *m_drawGridLayer; // rbx
cocos2d::CCArray *v46; // r15
GameObject *v47; // rdx
__int64 v48; // rcx
_QWORD *v49; // rdx
size_t v50; // r8
cocos2d::CCArray *v51; // rax
cocos2d::CCArray *v52; // rdi
struct cocos2d::CCObject *v53; // r12
unsigned int v54; // ebx
EditorUI *v55; // rcx
__int64 v56; // rax
cocos2d::CCPoint v57; // rax
unsigned int v58; // ebx
struct cocos2d::CCObject *v59; // r12
struct cocos2d::CCObject *v60; // r13
unsigned int v61; // ebx
struct cocos2d::CCObject *v62; // rax
unsigned int v63; // ebx
struct cocos2d::CCObject *v64; // rax
double v65; // xmm0_8
double v66; // xmm0_8
int v67; // ebx
int v68; // r15d
struct cocos2d::CCObject *v69; // rax
unsigned int m_uIndexInArray; // ecx
cocos2d::CCPoint v71; // rax
struct cocos2d::CCPoint v72; // [rsp+38h] [rbp-99h] BYREF
cocos2d::CCPoint v73; // [rsp+40h] [rbp-91h] BYREF
cocos2d::CCArray v74; // [rsp+48h] [rbp-89h] BYREF
__int64 v75; // [rsp+88h] [rbp-49h]
char v76; // [rsp+90h] [rbp-41h] BYREF
_QWORD v77[4]; // [rsp+98h] [rbp-39h] BYREF
cocos2d::CCPoint::CCPoint(&v73, &a1->m_clickAtPosition);
m_gridSize = a1->m_editorLayer->m_drawGridLayer->m_gridSize;
v6 = v5[1] / m_gridSize;
v7 = (float)(floorf(*v5 / m_gridSize) + 0.5) * m_gridSize;
v8 = floorf(v6);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v74.m_uIndexInArray, v7, (float)(v8 + 0.5) * m_gridSize);
EditorUI::getLimitedPosition(a1, (cocos2d::CCPoint)&v72);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v74.m_nTag, &v72);
v9 = a1->m_gridSize * 0.5;
x = v72.x;
if ( v72.x <= (float)(v9 - 3000.0) )
{
x = v9 - 3000.0;
v72.x = v9 - 3000.0;
}
y = v72.y;
if ( v72.y <= -3000.0 )
{
y = -3000.0;
v72.y = -3000.0;
}
if ( x > (float)(240000.0 - v9) )
v72.x = 240000.0 - v9;
v12 = 80;
if ( a1->m_editorLayer->m_levelSettings->m_dynamicLevelHeight )
v12 = 1000;
if ( y > (float)((float)((float)((float)v12 * 30.0) + 90.0) - v9) )
v72.y = (float)((float)((float)v12 * 30.0) + 90.0) - v9;
EditorUI::offsetForKey(a1, (int)&v76);
v13 = 0;
v14 = 0;
v15 = 0.0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v74.m_uAutoReleaseCount);
m_selectedObject = a1->m_selectedObject;
if ( m_selectedObject && m_selectedObject->m_objectID == a2 )
{
v13 = m_selectedObject->isFlipX(m_selectedObject);
v14 = a1->m_selectedObject->isFlipY(a1->m_selectedObject);
v17 = ((double (__fastcall *)(GameObject *))a1->m_selectedObject->getRotation)(a1->m_selectedObject);
v15 = *(float *)&v17;
v18 = a1->m_selectedObject;
EditorUI::offsetForKey(a1, (int)&v73);
GameToolbox::getRelativeOffset((GameObject *)&v74.m_uID, (cocos2d::CCPoint)v18);
}
cocos2d::CCPoint::operator+(&v72, &v74);
cocos2d::CCPoint::operator=(&v74.m_uAutoReleaseCount, &v74);
cocos2d::CCPoint::operator+(&v72, &v74);
cocos2d::CCPoint::operator=(&v72, &v74);
cocos2d::CCPoint::CCPoint(&v73, (const struct cocos2d::CCPoint *)&v74.m_uAutoReleaseCount);
if ( LevelEditorLayer::typeExistsAtPosition(a1->m_editorLayer, a2, v19, v13, v14, v15) )
{
LABEL_91:
cocos2d::CCPoint::operator=(&a1->m_createPosition, &dword_1406C1AA8);
return;
}
v20 = 0;
if ( a2 < 0 )
{
cocos2d::CCPoint::CCPoint(&v73, (const struct cocos2d::CCPoint *)&v74.m_nTag);
v22 = v21;
v23 = 0;
if ( cocos2d::CCArray::count(a1->m_snapPositions) )
{
do
{
v24 = cocos2d::CCArray::objectAtIndex(a1->m_snapPositions, v23);
if ( *(float *)((__int64 (__fastcall *)(struct cocos2d::CCObject *))v24->__vftable[2].getTag)(v24) == *v22
&& *(float *)(((__int64 (__fastcall *)(struct cocos2d::CCObject *))v24->__vftable[2].getTag)(v24) + 4) == v22[1] )
{
goto LABEL_91;
}
}
while ( ++v23 < cocos2d::CCArray::count(a1->m_snapPositions) );
}
}
cocos2d::CCPoint::CCPoint(&v73, (const struct cocos2d::CCPoint *)&v74.m_nTag);
v26 = v25;
v27 = (struct cocos2d::CCObject *)cocos2d::CCNode::create();
v27->__vftable[2].encodeWithCoder(v27, v26);
cocos2d::CCArray::addObject(a1->m_snapPositions, v27);
if ( a2 > 0 )
{
cocos2d::CCPoint::CCPoint(&v73, &v72);
Object = EditorUI::createObject(a1, a2, v29);
v32 = Object;
v33 = a1->m_selectedObject;
if ( v33 && Object->m_objectID == v33->m_objectID )
{
EditorUI::removeOffset(a1, Object);
GameObject::duplicateValues(v32);
EditorUI::applyOffset(a1, v32);
}
if ( a2 == 914 )
{
*(_OWORD *)&v74.m_unknown2 = 0;
v74.data = (cocos2d::ccArray *)1;
v75 = 15;
LOWORD(v74.m_unknown2) = 65;
TextGameObject::updateTextObject(v32, &v74.m_unknown2, 0);
}
else if ( a2 == 3032 )
{
LevelEditorLayer::removeSpecial(a1->m_editorLayer, v32);
m_editorLayer = a1->m_editorLayer;
v36 = (struct cocos2d::CCObject *)cocos2d::CCArray::create(v35);
v36->setTag(v36, m_editorLayer->m_keyframeGroup);
cocos2d::CCDictionary::setObject(m_editorLayer->m_keyframeGroups, v36, m_editorLayer->m_keyframeGroup);
++m_editorLayer->m_keyframeGroup;
LODWORD(v32[1].m_sQuad.tr.vertices.y) = v36->getTag(v36);
v32[1].m_sQuad.tr.vertices.z = 0.0;
LevelEditorLayer::addSpecial(a1->m_editorLayer, v32);
}
EditorUI::selectObject(a1, v32, v31);
if ( !v32 || v32->m_classType != Effect )
goto LABEL_49;
m_objectID = v32->m_objectID;
if ( m_objectID > 1934 )
{
v41 = m_objectID - 1935;
if ( v41 )
{
v42 = v41 - 965;
if ( v42 )
{
v43 = v42 - 2;
if ( v43 )
{
v44 = v43 - 120;
if ( v44 )
{
v40 = v44 == 5;
goto LABEL_44;
}
}
}
}
}
else if ( m_objectID != 1934 )
{
if ( m_objectID > 203 )
{
if ( m_objectID != 1334 )
{
v40 = m_objectID == 1917;
goto LABEL_44;
}
}
else if ( m_objectID != 203 )
{
v38 = m_objectID - 200;
if ( v38 )
{
v39 = v38 - 1;
if ( v39 )
{
v40 = v39 == 1;
LABEL_44:
if ( !v40 && (!v32->canReverse(v32) || !LOBYTE(v32[1].m_obRect.size.height)) )
goto LABEL_49;
}
}
}
}
LOBYTE(v32[1].m_obRect.origin.x) = 1;
m_drawGridLayer = a1->m_editorLayer->m_drawGridLayer;
if ( !cocos2d::CCArray::containsObject(m_drawGridLayer->m_speedObjects, v32) )
{
cocos2d::CCArray::addObject(m_drawGridLayer->m_speedObjects, v32);
m_drawGridLayer->m_updateSpeedObjects = 1;
EffectGameObject::updateSpeedModType((EffectGameObject *)v32);
}
LABEL_49:
EditorUI::updateSlider(a1);
return;
}
v46 = (cocos2d::CCArray *)cocos2d::CCArray::create(v28);
v47 = a1->m_selectedObject;
if ( v47 )
cocos2d::CCArray::addObject(v46, v47);
else
cocos2d::CCArray::addObjectsFromArray(v46, a1->m_selectedObjects);
v48 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v73 = (cocos2d::CCPoint)operator new(0x668u);
qword_1406C2ED8 = ((__int64 (__fastcall *)(_QWORD))sub_14017AB00)(v73);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v48 = qword_1406C2ED8;
}
GameManager::stringForCustomObject(v48, v77, (unsigned int)a2);
v49 = v77;
if ( v77[3] > 0xFu )
v49 = (_QWORD *)v77[0];
memset(&v74.m_unknown2, 0, 24);
v75 = 0;
v50 = -1;
do
++v50;
while ( *((_BYTE *)v49 + v50) );
sub_14003A930(&v74.m_unknown2, v49, v50);
v51 = (cocos2d::CCArray *)EditorUI::pasteObjects(a1, &v74.m_unknown2, 0, 0);
v52 = v51;
if ( v51 && cocos2d::CCArray::count(v51) )
{
v53 = nullptr;
v54 = 0;
if ( cocos2d::CCArray::count(v52) )
{
while ( 1 )
{
v53 = cocos2d::CCArray::objectAtIndex(v52, v54);
if ( BYTE2(v53[20].m_uUnknown) )
break;
if ( ++v54 >= cocos2d::CCArray::count(v52) )
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v74.m_uID, (const struct cocos2d::CCPoint *)&v74.m_nTag);
goto LABEL_67;
}
}
}
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v74.m_uID, (const struct cocos2d::CCPoint *)&v74.m_nTag);
if ( v53 )
{
EditorUI::getGroupCenter(v55, &v74, (bool)v52);
v56 = ((__int64 (__fastcall *)(struct cocos2d::CCObject *))v53->__vftable[2].getTag)(v53);
cocos2d::CCPoint::operator-(&v74, &v74.m_uIndexInArray, v56);
cocos2d::CCPoint::operator+(&v74.m_uID, &v73);
cocos2d::CCPoint::operator=(&v74.m_uID, &v73);
}
LABEL_67:
cocos2d::CCPoint::CCPoint(&v73, (const struct cocos2d::CCPoint *)&v74.m_uID);
EditorUI::repositionObjectsToCenter(a1, v52, v57, 0);
v58 = cocos2d::CCArray::count(v52);
if ( v58 == cocos2d::CCArray::count(v46) )
{
v59 = nullptr;
v60 = nullptr;
v61 = 0;
if ( cocos2d::CCArray::count(v46) )
{
while ( 1 )
{
v62 = cocos2d::CCArray::objectAtIndex(v46, v61);
if ( BYTE2(v62[20].m_uUnknown) )
break;
if ( ++v61 >= cocos2d::CCArray::count(v46) )
goto LABEL_73;
}
v59 = v62;
}
LABEL_73:
v63 = 0;
if ( cocos2d::CCArray::count(v52) )
{
while ( 1 )
{
v64 = cocos2d::CCArray::objectAtIndex(v52, v63);
if ( BYTE2(v64[20].m_uUnknown) )
break;
if ( ++v63 >= cocos2d::CCArray::count(v52) )
goto LABEL_78;
}
v60 = v64;
}
LABEL_78:
if ( v59 )
{
if ( v60 )
{
if ( v59[18].m_eObjType == v60[18].m_eObjType )
{
v65 = ((double (__fastcall *)(struct cocos2d::CCObject *))v59->__vftable[4].getTag)(v59);
if ( *(float *)&v65 != ((float (__fastcall *)(struct cocos2d::CCObject *))v60->__vftable[4].getTag)(v60) )
{
v66 = ((double (__fastcall *)(struct cocos2d::CCObject *))v59->__vftable[4].getTag)(v59);
v67 = (int)(float)(*(float *)&v66
- ((float (__fastcall *)(struct cocos2d::CCObject *))v60->__vftable[4].getTag)(v60));
if ( v67 == 90 * (v67 / 90) || !cocos2d::CCArray::count(v52) )
{
LABEL_89:
cocos2d::CCPoint::CCPoint(&v73, (const struct cocos2d::CCPoint *)&dword_1406C1AA8);
EditorUI::rotateObjects(a1, v52, (float)v67, v71);
}
else
{
v68 = 35651585;
while ( 1 )
{
v69 = cocos2d::CCArray::objectAtIndex(v52, v20);
m_uIndexInArray = v69[16].m_uIndexInArray;
if ( m_uIndexInArray <= 0x19 && _bittest(&v68, m_uIndexInArray) && !BYTE2(v69[21].m_nZOrder) )
break;
if ( ++v20 >= cocos2d::CCArray::count(v52) )
goto LABEL_89;
}
}
}
}
}
}
}
}
sub_14003A830((__int64)v77);
}