//
// EditorUI::onCreateObject from 0x100034bf0 to 0x100035627 (2615 bytes)
//
// 1 xrefs:
// > EditorUI::onCreate @ 0x10002e24b
//
// 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)
{
float m_gridSize; // xmm2_4
__m128 v4; // xmm0
__m128 v5; // xmm1
__m128 v6; // xmm0
__m128 m_gridSize_low; // xmm0
__m128 v8; // xmm2
__m128 v9; // xmm3
__m128 inserted; // xmm1
GameObject *m_selectedObject; // rdi
char v12; // r15
LevelEditorLayer *m_editorLayer; // r14
LevelEditorLayer *v14; // rdi
int v15; // r14d
double v16; // xmm0_8
cocos2d::CCNode *v17; // r15
cocos2d::CCArray *m_snapPositions; // rdi
LevelEditorLayer *v19; // r15
cocos2d::CCPoint v20; // xmm0_8
GameObject *Object; // rax
GameObject *v22; // r15
float m_pixelScaleX; // xmm0_4
GameObject *v24; // rax
__int64 v25; // rax
GameObject *v26; // rsi
__int64 v27; // rax
double v28; // xmm0_8
unsigned int v29; // r15d
__int64 v30; // r12
__int64 v31; // rax
__int64 v32; // r15
GameObject *v33; // rsi
cocos2d::CCArray *NewKeyframeAnim; // rax
GameManager *v35; // rax
const char *v36; // r14
size_t v37; // rax
size_t v38; // r12
char *v39; // r13
size_t v40; // r15
cocos2d::CCArray *v41; // r14
unsigned int v42; // r13d
_BYTE *v43; // r12
int SectionCount; // eax
int v45; // ecx
float v46; // xmm0_4
__int64 v47; // rax
cocos2d::CCPoint v48; // xmm0_8
int v49; // r15d
unsigned int v50; // r13d
__int64 v51; // r15
__int64 v52; // r12
unsigned int v53; // r15d
__int64 v54; // rax
__int64 v55; // r15
float v56; // xmm0_4
float v57; // xmm0_4
cocos2d::CCPoint v58; // xmm1_8
int v59; // r12d
unsigned int v60; // r15d
GameObject *v61; // rax
char v62[8]; // [rsp+8h] [rbp-C8h] BYREF
char v63[8]; // [rsp+10h] [rbp-C0h] BYREF
__int16 v64; // [rsp+18h] [rbp-B8h] BYREF
char v65; // [rsp+1Ah] [rbp-B6h]
void *__p; // [rsp+28h] [rbp-A8h]
char v67; // [rsp+30h] [rbp-A0h] BYREF
_QWORD __dst[2]; // [rsp+38h] [rbp-98h] BYREF
void *v69; // [rsp+48h] [rbp-88h]
cocos2d::CCArray v70; // [rsp+54h] [rbp-7Ch] BYREF
float XMin; // [rsp+94h] [rbp-3Ch]
__int64 v72; // [rsp+98h] [rbp-38h]
float v73; // [rsp+A0h] [rbp-30h] BYREF
float v74; // [rsp+A4h] [rbp-2Ch]
double v75; // 0:xmm0_8.8
cocos2d::CCPoint v76; // 0:xmm0_8.8
cocos2d::CCPoint v77; // 0:xmm0_8.8
double v78; // 0:xmm0_8.8
cocos2d::CCPoint v79; // 0:xmm0_8.8
double v80; // 0:xmm0_8.8
double v81; // 0:xmm0_8.8
sub_10028CC60(&v73, &a1->m_clickAtPosition);
m_gridSize = a1->m_editorLayer->m_drawGridLayer->m_gridSize;
v4 = (__m128)LODWORD(v73);
v5 = (__m128)LODWORD(v74);
v4.f32[0] = v73 / m_gridSize;
v5.f32[0] = v74 / m_gridSize;
sub_10028CBE0(
&v70.m_uUnknown,
(float)(_mm_round_ss(v4, v4, 9).f32[0] + 0.5) * m_gridSize,
(float)(_mm_round_ss(v5, v5, 9).f32[0] + 0.5) * m_gridSize);
v6 = (__m128)0x46EB1400u;
if ( !a1->m_editorLayer->m_levelSettings->m_dynamicLevelHeight )
v6 = (__m128)0x451BA000u;
_mm_storel_ps(
(double *)&v70.m_uUnknown,
_mm_min_ps(
_mm_max_ps((__m128)*(unsigned __int64 *)&v70.m_uUnknown, (__m128)xmmword_100815470),
_mm_insert_ps((__m128)0x486A6000u, v6, 16)));
sub_10028CC60(&v70.m_eObjType, &v70.m_uUnknown);
sub_10028CC60(&v70, &v70.m_eObjType);
m_gridSize_low = (__m128)LODWORD(a1->m_gridSize);
v8 = (__m128)0x3F000000u;
v9 = (__m128)0x46EB1400u;
if ( !a1->m_editorLayer->m_levelSettings->m_dynamicLevelHeight )
v9 = (__m128)0x451BA000u;
v8.f32[0] = (float)(0.5 * m_gridSize_low.f32[0]) + -3000.0;
inserted = _mm_insert_ps((__m128)0x486A6000u, v9, 16);
m_gridSize_low.f32[0] = m_gridSize_low.f32[0] * -0.5;
_mm_storel_ps(
(double *)&v70.m_eObjType,
_mm_min_ps(
_mm_max_ps(_mm_blend_ps(v8, (__m128)xmmword_100815480, 14), (__m128)*(unsigned __int64 *)&v70.m_eObjType),
_mm_add_ps(_mm_moveldup_ps(m_gridSize_low), inserted)));
*(cocos2d::CCPoint *)&v75 = EditorUI::offsetForKey((EditorUI *)&v67, (int)&v70.m_eObjType);
sub_10028CC30(&v70.m_uID);
m_selectedObject = a1->m_selectedObject;
LODWORD(v72) = a2;
if ( m_selectedObject && m_selectedObject->m_objectID == a2 )
{
v12 = ((__int64 (__fastcall *)(GameObject *, double))m_selectedObject->isFlipX)(m_selectedObject, v75);
((__int64 (__fastcall *)(GameObject *))a1->m_selectedObject->isFlipY)(a1->m_selectedObject);
XMin = ((float (__fastcall *)(GameObject *))a1->m_selectedObject->getRotation)(a1->m_selectedObject);
v76 = EditorUI::offsetForKey((EditorUI *)&v70.m_uUnknown, (int)&v70.m_eObjType);
GameToolbox::getRelativeOffset((GameObject *)&v73, v76);
sub_10028CCE0(&v70.m_uUnknown, &v70.m_eObjType);
sub_10028CC90(&v70.m_uID, &v70.m_uUnknown);
}
else
{
sub_10028CCE0(&v70.m_uUnknown, &v70.m_eObjType);
sub_10028CC90(&v70.m_uID, &v70.m_uUnknown);
XMin = 0.0;
v12 = 0;
}
sub_10028CCE0(&v70.m_uUnknown, &v70.m_eObjType);
sub_10028CC90(&v70.m_eObjType, &v70.m_uUnknown);
m_editorLayer = a1->m_editorLayer;
sub_10028CC60(&v70.m_uUnknown, &v70.m_uID);
v14 = m_editorLayer;
v15 = v72;
if ( LevelEditorLayer::typeExistsAtPosition(
v14,
v72,
(cocos2d::CCPoint)LODWORD(XMin),
(bool)&v70.m_uUnknown,
v12,
inserted.f32[0]) )
{
LABEL_10:
sub_10028CC90(&a1->m_createPosition, &qword_10099EC08);
return;
}
if ( v15 < 0 )
{
v28 = sub_10028CC60(&v70.m_uUnknown, &v70);
if ( (unsigned int)sub_100720070(a1->m_snapPositions) )
{
v29 = 0;
do
{
v30 = sub_1007200C0(a1->m_snapPositions, v29);
LODWORD(v28) = *(_DWORD *)(*(__int64 (__fastcall **)(__int64, double))(*(_QWORD *)v30 + 192LL))(v30, v28);
if ( *(float *)&v28 == *(float *)&v70.m_uUnknown )
{
*(_QWORD *)&v28 = *(unsigned int *)((*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v30 + 192LL))(v30) + 4);
if ( *(float *)&v28 == *(float *)&v70.m_unknown2 )
goto LABEL_10;
}
}
while ( ++v29 < (unsigned int)sub_100720070(a1->m_snapPositions) );
}
}
v16 = sub_10028CC60(&v70.m_uUnknown, &v70);
v17 = cocos2d::CCNode::create();
((void (__fastcall *)(cocos2d::CCNode *, int *, double))v17->setPosition)(v17, &v70.m_uUnknown, v16);
m_snapPositions = a1->m_snapPositions;
sub_10071FCD0(m_snapPositions, v17);
if ( v15 > 0 )
{
sub_10028CC60(&v73, &v70.m_eObjType);
v19 = a1->m_editorLayer;
*(double *)&v20 = sub_10028CC60(&v70.m_uUnknown, &v73);
Object = LevelEditorLayer::createObject(v19, v15, v20, (bool)&v70.m_uUnknown);
v22 = Object;
if ( Object )
{
m_pixelScaleX = Object->m_pixelScaleX;
if ( m_pixelScaleX != 1.0 || Object->m_pixelScaleY != 1.0 )
{
GameObject::updateCustomScaleX(Object, m_pixelScaleX);
GameObject::updateCustomScaleY(v22, v22->m_pixelScaleY);
}
}
v24 = a1->m_selectedObject;
if ( v24 && v22->m_objectID == v24->m_objectID )
{
v77 = EditorUI::offsetForKey((EditorUI *)&v70.m_uUnknown, v15);
*(cocos2d::CCPoint *)&v78 = GameToolbox::getRelativeOffset((GameObject *)&v73, v77);
v25 = ((__int64 (__fastcall *)(GameObject *, GameObject *, double))v22->getPosition)(v22, v22, v78);
sub_10028CD00(&v70.m_uUnknown, v25, &v73);
((void (__fastcall *)(GameObject *, int *))v22->setPosition)(v22, &v70.m_uUnknown);
GJBaseGameLayer::reorderObjectSection(a1->m_editorLayer, v22);
v26 = a1->m_selectedObject;
GameObject::duplicateValues(v22);
v79 = EditorUI::offsetForKey((EditorUI *)&v70.m_uUnknown, (int)v26);
*(cocos2d::CCPoint *)&v80 = GameToolbox::getRelativeOffset((GameObject *)&v73, v79);
v27 = ((__int64 (__fastcall *)(GameObject *, GameObject *, double))v22->getPosition)(v22, v22, v80);
sub_10028CCE0(&v70.m_uUnknown, v27);
((void (__fastcall *)(GameObject *, int *))v22->setPosition)(v22, &v70.m_uUnknown);
GJBaseGameLayer::reorderObjectSection(a1->m_editorLayer, v22);
}
if ( v15 == 3032 )
{
LevelEditorLayer::removeSpecial(a1->m_editorLayer, v22);
NewKeyframeAnim = GJBaseGameLayer::createNewKeyframeAnim(a1->m_editorLayer);
LODWORD(v22[1].m_sQuad.bl.texCoords.v) = ((__int64 (__fastcall *)(cocos2d::CCArray *))NewKeyframeAnim->getTag)(NewKeyframeAnim);
v22[1].m_sQuad.tr.vertices.x = 0.0;
LevelEditorLayer::addSpecial(a1->m_editorLayer, v22);
EditorUI::selectObject(a1, v22, 0);
if ( v22->m_classType != Effect )
{
LABEL_61:
LODWORD(v72) = *(_DWORD *)((__int64 (__fastcall *)(cocos2d::CCLayer *))a1->m_editorLayer->m_objectLayer->getPosition)(a1->m_editorLayer->m_objectLayer);
XMin = EditorUI::getXMin(a1, 0);
SectionCount = LevelEditorLayer::getSectionCount(a1->m_editorLayer);
v45 = 100;
if ( SectionCount >= 101 )
v45 = SectionCount;
*(float *)&v70.m_nTag = (float)v45 * -100.0;
v46 = ((float (__fastcall *)(cocos2d::CCLayer *))a1->m_editorLayer->m_objectLayer->getScale)(a1->m_editorLayer->m_objectLayer);
Slider::setValue(
a1->m_positionSlider,
fminf(fmaxf((float)(*(float *)&v72 - XMin) / (float)(v46 * *(float *)&v70.m_nTag), 0.0), 1.0));
return;
}
}
else
{
if ( v15 == 914 )
{
v64 = 16642;
v65 = 0;
TextGameObject::updateTextObject(v22, &v64, 0);
if ( (v64 & 1) != 0 )
operator delete(__p);
}
EditorUI::selectObject(a1, v22, 0);
if ( !v22 || v22->m_classType != Effect )
goto LABEL_61;
}
if ( GameObject::isSpeedObject(v22)
|| ((unsigned __int8 (__fastcall *)(GameObject *))v22->canReverse)(v22) && LOBYTE(v22[1].m_obRect.origin.y) == 1 )
{
LOBYTE(v22[1].m_pobTexture) = 1;
DrawGridLayer::addToSpeedObjects(a1->m_editorLayer->m_drawGridLayer, (EffectGameObject *)v22);
}
goto LABEL_61;
}
v31 = sub_10071F9E0(m_snapPositions, v17);
v32 = v31;
v33 = a1->m_selectedObject;
if ( v33 )
sub_10071FCD0(v31, v33);
else
sub_100720050(v31, a1->m_selectedObjects);
v35 = GameManager::sharedState();
GameManager::stringForCustomObject(&v70.m_uUnknown, v35, (unsigned int)v15);
if ( (v70.m_uUnknown & 1) != 0 )
v36 = *(const char **)&v70.m_unknown5;
else
v36 = (char *)&v70.m_uUnknown + 1;
v37 = strlen(v36);
if ( v37 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v16);
v38 = v37;
v72 = v32;
if ( v37 >= 0x17 )
{
v40 = 26;
if ( (v37 | 7) != 0x17 )
v40 = (v37 | 7) + 1;
v39 = (char *)operator new(v40);
v69 = v39;
__dst[0] = v40 | 1;
__dst[1] = v38;
}
else
{
LOBYTE(__dst[0]) = 2 * v37;
v39 = (char *)__dst + 1;
if ( !v37 )
goto LABEL_51;
}
memmove(v39, v36, v38);
LABEL_51:
v39[v38] = 0;
v41 = (cocos2d::CCArray *)EditorUI::pasteObjects(a1, __dst, 0, 0);
if ( (__dst[0] & 1) != 0 )
operator delete(v69);
if ( v41 && (unsigned int)sub_100720070(v41) )
{
v42 = 0;
while ( v42 < (unsigned int)sub_100720070(v41) )
{
v43 = (_BYTE *)sub_1007200C0(v41, v42++);
if ( v43[1150] )
goto LABEL_65;
}
v43 = nullptr;
LABEL_65:
sub_10028CC60(&v73, &v70);
if ( v43 )
{
*(cocos2d::CCPoint *)&v81 = EditorUI::getGroupCenter((EditorUI *)&v70.m_uReference, &v70, (bool)v41);
v47 = (*(__int64 (__fastcall **)(_BYTE *, double))(*(_QWORD *)v43 + 192LL))(v43, v81);
sub_10028CD00(v62, &v70.m_uReference, v47);
sub_10028CCE0(v63, &v73);
sub_10028CC90(&v73, v63);
}
*(double *)&v48 = sub_10028CC60(&v70.m_uReference, &v73);
EditorUI::repositionObjectsToCenter(a1, v41, v48, (bool)&v70.m_uReference);
v49 = sub_100720070(v41);
if ( v49 == (unsigned int)sub_100720070(v72) )
{
v50 = 0;
v51 = v72;
while ( v50 < (unsigned int)sub_100720070(v51) )
{
v52 = sub_1007200C0(v51, v50++);
if ( *(_BYTE *)(v52 + 1150) )
goto LABEL_73;
}
v52 = 0;
LABEL_73:
v53 = 0;
while ( v53 < (unsigned int)sub_100720070(v41) )
{
v54 = sub_1007200C0(v41, v53++);
if ( *(_BYTE *)(v54 + 1150) )
{
if ( v52 )
{
if ( *(_DWORD *)(v52 + 1028) == *(_DWORD *)(v54 + 1028) )
{
v55 = v54;
LODWORD(v72) = (*(float (__fastcall **)(__int64))(*(_QWORD *)v52 + 352LL))(v52);
v56 = (*(float (__fastcall **)(__int64))(*(_QWORD *)v55 + 352LL))(v55);
if ( *(float *)&v72 != v56 )
{
LODWORD(v72) = (*(float (__fastcall **)(__int64))(*(_QWORD *)v52 + 352LL))(v52);
v57 = (*(float (__fastcall **)(__int64))(*(_QWORD *)v55 + 352LL))(v55);
v58 = (cocos2d::CCPoint)(unsigned int)v72;
v58.x = *(float *)&v72 - v57;
v59 = (int)(float)(*(float *)&v72 - v57);
if ( __ROR4__(-1527099483 * v59 + 47721858, 1) >= 0x2D82D83u )
{
v60 = 0;
while ( v60 < (unsigned int)sub_100720070(v41) )
{
v61 = (GameObject *)sub_1007200C0(v41, v60++);
if ( !GameObject::canRotateFree(v61) )
goto LABEL_85;
}
}
sub_10028CC60(&v70.m_uReference, &qword_10099EC08);
EditorUI::rotateObjects(a1, v41, (float)v59, v58);
}
}
}
break;
}
}
}
}
LABEL_85:
if ( (v70.m_uUnknown & 1) != 0 )
operator delete(*(void **)&v70.m_unknown5);
}