//
// EditorUI::onCreateObject from 0x1003eb2d0 to 0x1003eb95c (1676 bytes)
//
// 1 xrefs:
// > EditorUI::onCreate @ 0x1003e6c4c
//
// 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
//
void __fastcall EditorUI::onCreateObject(EditorUI *a1, int a2)
{
EditorUI *v4; // x0
float32x2_t v5; // d0
int32x2_t v6; // d1
float v7; // s3
float32x2_t v8; // d1
float32x2_t v9; // d5
float32x2_t v10; // d1
float32x2_t v11; // d5
GameObject *m_selectedObject; // x0
char v13; // w21
EditorUI *v14; // x0
float v15; // s0
float v16; // s8
GameObject *v17; // x23
LevelEditorLayer *m_editorLayer; // x23
float v19; // s2
cocos2d::CCNode *v20; // x0
GameObject *Object; // x0
__int64 v22; // x21
GameObject *v23; // x8
cocos2d::CCObject *v24; // x0
__int64 v25; // x21
cocos2d::CCArray *NewKeyframeAnim; // x0
GameManager *v27; // x0
char *v28; // x1
__int64 v29; // x0
cocos2d::CCArray *v30; // x20
unsigned int v31; // w23
_BYTE *v32; // x22
EditorUI *v33; // x0
float32x2_t *v34; // x0
int v35; // w22
unsigned int v36; // w23
__int64 v37; // x22
unsigned int v38; // w23
__int64 v39; // x0
__int64 v40; // x21
float v41; // s8
float v42; // s8
int v43; // w22
unsigned __int64 v44; // t2
unsigned int v45; // w21
GameObject *v46; // x0
float32x2_t v47; // [xsp+8h] [xbp-C8h] BYREF
float32x2_t v48; // [xsp+10h] [xbp-C0h] BYREF
float32x2_t v49; // [xsp+18h] [xbp-B8h] BYREF
void *__s[2]; // [xsp+20h] [xbp-B0h] BYREF
char v51; // [xsp+37h] [xbp-99h]
void *v52[2]; // [xsp+38h] [xbp-98h] BYREF
char v53; // [xsp+4Fh] [xbp-81h]
std::string __p; // [xsp+50h] [xbp-80h] BYREF
float32x2_t v55; // [xsp+68h] [xbp-68h] BYREF
__int64 v56; // [xsp+70h] [xbp-60h] BYREF
float32x2_t v57; // [xsp+78h] [xbp-58h] BYREF
__int64 v58; // [xsp+80h] [xbp-50h] BYREF
int8x8_t v59; // [xsp+88h] [xbp-48h] BYREF
cocos2d::CCPoint GroupCenter; // 0:kr20_8.8
cocos2d::CCPoint v61; // 0:s0.4,4:s1.4
cocos2d::CCPoint v62; // 0:s0.4,4:s1.4
cocos2d::CCPoint v63; // 0:s0.4,4:s1.4
cocos2d::CCPoint v64; // 0:s0.4,4:s1.4
cocos2d::CCPoint v65; // 0:s0.4,4:s1.4
cocos2d::CCPoint v66; // 0:s0.4,4:s1.4
cocos2d::CCPoint v67; // 0:s1.4,4:s2.4
v61.x = sub_1000229B8((__int64 *)v52, (__int64 *)&a1->m_clickAtPosition);
EditorUI::getGridSnappedPos(a1, v61);
sub_1000229B8(&v58, (__int64 *)&v59);
v5.i32[0] = LODWORD(a1->m_gridSize);
v6.i32[0] = -985956352;
v7 = 80.0;
if ( a1->m_editorLayer->m_levelSettings->m_dynamicLevelHeight )
v7 = 1000.0;
v8.i32[1] = vdup_lane_s32(v6, 0).i32[1];
v8.f32[0] = (float)(v5.f32[0] * 0.5) + -3000.0;
v9.f32[0] = vld1_dup_f32((const float *)&dword_1006455C4).f32[0];
v9.f32[1] = (float)(v7 * 30.0) + 90.0;
v10 = (float32x2_t)vbsl_s8((int8x8_t)vcgt_f32(v8, (float32x2_t)v59), (int8x8_t)v8, v59);
v11 = vmls_lane_f32(v9, (float32x2_t)0x3F0000003F000000LL, v5, 0);
v59 = vbsl_s8((int8x8_t)vcgt_f32(v11, v10), (int8x8_t)v10, (int8x8_t)v11);
EditorUI::offsetForKey(v4, a2);
sub_1000229B0(&v56);
m_selectedObject = a1->m_selectedObject;
if ( m_selectedObject && m_selectedObject->m_objectID == a2 )
{
v13 = ((__int64 (__fastcall *)(GameObject *))m_selectedObject->isFlipX)(m_selectedObject);
((void (__fastcall *)(GameObject *))a1->m_selectedObject->isFlipY)(a1->m_selectedObject);
v14 = (EditorUI *)((__int64 (__fastcall *)(GameObject *))a1->m_selectedObject->getRotation)(a1->m_selectedObject);
v16 = v15;
v17 = a1->m_selectedObject;
v66 = EditorUI::offsetForKey(v14, v17->m_objectID);
GameToolbox::getRelativeOffset(v17, v66);
sub_1000229DC((float32x2_t *)&v59, &v55, (float32x2_t *)v52);
sub_1000229D0(&v56, (double *)v52);
}
else
{
sub_1000229DC((float32x2_t *)&v59, &v57, (float32x2_t *)v52);
sub_1000229D0(&v56, (double *)v52);
v13 = 0;
v16 = 0.0;
}
sub_1000229DC((float32x2_t *)&v59, &v57, (float32x2_t *)v52);
sub_1000229D0(&v59, (double *)v52);
m_editorLayer = a1->m_editorLayer;
sub_1000229B8((__int64 *)v52, &v56);
v62.x = v16;
if ( LevelEditorLayer::typeExistsAtPosition(m_editorLayer, a2, v62, (bool)v52, v13, v19)
|| a2 < 0 && (v63.x = sub_1000229B8((__int64 *)v52, &v58), EditorUI::positionIsInSnapped(a1, v63)) )
{
sub_1000229D0(&a1->m_createPosition, (double *)&dword_10086E8B0);
return;
}
sub_1000229B8((__int64 *)v52, &v58);
v20 = cocos2d::CCNode::create();
((void (__fastcall *)(cocos2d::CCNode *, void **))v20->setPosition)(v20, v52);
sub_10024A2D0((__int64)a1->m_snapPositions);
if ( a2 >= 1 )
{
v64.x = sub_1000229B8((__int64 *)v52, (__int64 *)&v59);
Object = EditorUI::createObject(a1, a2, v64);
v22 = (__int64)Object;
v23 = a1->m_selectedObject;
if ( v23 && Object->m_objectID == v23->m_objectID )
{
EditorUI::removeOffset(a1, Object);
GameObject::duplicateValues((GameObject *)v22);
EditorUI::applyOffset(a1, (GameObject *)v22);
}
if ( a2 == 3032 )
{
LevelEditorLayer::removeSpecial(a1->m_editorLayer, (GameObject *)v22);
NewKeyframeAnim = GJBaseGameLayer::createNewKeyframeAnim(a1->m_editorLayer);
*(_DWORD *)(v22 + 1856) = ((__int64 (__fastcall *)(cocos2d::CCArray *))NewKeyframeAnim->getTag)(NewKeyframeAnim);
*(_DWORD *)(v22 + 1860) = 0;
LevelEditorLayer::addSpecial(a1->m_editorLayer, (GameObject *)v22);
EditorUI::selectObject(a1, (GameObject *)v22, 0);
}
else
{
if ( a2 == 914 )
{
sub_100009900(&__p, "A");
TextGameObject::updateTextObject(v22, &__p, 0);
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__p.__r_.__value_.__l.__data_);
}
EditorUI::selectObject(a1, (GameObject *)v22, 0);
if ( !v22 )
goto LABEL_43;
}
if ( *(_DWORD *)(v22 + 1248) == 1
&& (GameObject::isSpeedObject((GameObject *)v22)
|| (*(unsigned int (__fastcall **)(__int64))(*(_QWORD *)v22 + 1664LL))(v22) && *(_BYTE *)(v22 + 1780) == 1) )
{
*(_BYTE *)(v22 + 1768) = 1;
DrawGridLayer::addToSpeedObjects(a1->m_editorLayer->m_drawGridLayer, (EffectGameObject *)v22);
}
LABEL_43:
EditorUI::updateSlider(a1);
return;
}
v24 = sub_10024A15C();
v25 = (__int64)v24;
if ( a1->m_selectedObject )
sub_10024A2D0((__int64)v24);
else
sub_10024A360((__int64)v24, (__int64)a1->m_selectedObjects);
v27 = GameManager::sharedState();
GameManager::stringForCustomObject((__int64)v27, a2, v52);
if ( v53 >= 0 )
v28 = (char *)v52;
else
v28 = (char *)v52[0];
sub_100009900(__s, v28);
v29 = EditorUI::pasteObjects((int)a1, __s);
v30 = (cocos2d::CCArray *)v29;
if ( v51 < 0 )
{
operator delete(__s[0]);
if ( !v30 )
goto LABEL_65;
LABEL_36:
if ( (unsigned int)sub_10024A36C((__int64)v30) )
{
v31 = 0;
while ( v31 < (unsigned int)sub_10024A36C((__int64)v30) )
{
v32 = (_BYTE *)sub_10024A388((__int64)v30, v31++);
if ( (v32[1150] & 1) != 0 )
goto LABEL_45;
}
v32 = nullptr;
LABEL_45:
sub_1000229B8((__int64 *)&v55, &v58);
if ( v32 )
{
GroupCenter = EditorUI::getGroupCenter(v33, v30, 0);
v34 = (float32x2_t *)(*(__int64 (__fastcall **)(_BYTE *, float, float))(*(_QWORD *)v32 + 192LL))(
v32,
GroupCenter.x,
GroupCenter.y);
sub_1000229F0(&v49, v34, &v48);
sub_1000229DC(&v55, &v48, &v47);
sub_1000229D0(&v55, (double *)&v47);
}
v65.x = sub_1000229B8((__int64 *)&v49, (__int64 *)&v55);
EditorUI::repositionObjectsToCenter(a1, v30, v65, (bool)&v49);
v35 = sub_10024A36C((__int64)v30);
if ( v35 == (unsigned int)sub_10024A36C(v25) )
{
v36 = 0;
while ( v36 < (unsigned int)sub_10024A36C(v25) )
{
v37 = sub_10024A388(v25, v36++);
if ( (*(_BYTE *)(v37 + 1150) & 1) != 0 )
goto LABEL_53;
}
v37 = 0;
LABEL_53:
v38 = 0;
while ( v38 < (unsigned int)sub_10024A36C((__int64)v30) )
{
v39 = sub_10024A388((__int64)v30, v38);
v40 = v39;
++v38;
if ( (*(_BYTE *)(v39 + 1150) & 1) != 0 )
{
if ( v37 )
{
if ( *(_DWORD *)(v37 + 1028) == *(_DWORD *)(v39 + 1028) )
{
v41 = (*(float (__fastcall **)(__int64))(*(_QWORD *)v37 + 352LL))(v37);
if ( v41 != (*(float (__fastcall **)(__int64))(*(_QWORD *)v40 + 352LL))(v40) )
{
v42 = (*(float (__fastcall **)(__int64))(*(_QWORD *)v37 + 352LL))(v37);
v43 = (int)(float)(v42 - (*(float (__fastcall **)(__int64))(*(_QWORD *)v40 + 352LL))(v40));
HIDWORD(v44) = -1527099483 * v43 + 47721858;
LODWORD(v44) = HIDWORD(v44);
if ( (unsigned int)(v44 >> 1) >= 0x2D82D83 )
{
v45 = 0;
while ( v45 < (unsigned int)sub_10024A36C((__int64)v30) )
{
v46 = (GameObject *)sub_10024A388((__int64)v30, v45++);
if ( !GameObject::canRotateFree(v46) )
goto LABEL_65;
}
}
sub_1000229B8((__int64 *)&v49, (__int64 *)&dword_10086E8B0);
EditorUI::rotateObjects(a1, v30, (float)v43, v67);
}
}
}
goto LABEL_65;
}
}
}
}
goto LABEL_65;
}
if ( v29 )
goto LABEL_36;
LABEL_65:
if ( v53 < 0 )
operator delete(v52[0]);
}