//
// EditorUI::onCreateObject from 0x6bfc4c to 0x6c04ac (2144 bytes)
//
// 2 xrefs:
// > EditorUI::onCreate @ 0x6c058c
// > ??> @ 0x7a9d0
//
// 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 EditorUI::onCreateObject(EditorUI *a1, int a2)
{
float v4; // s1
float x; // s0
float y; // s2
LevelEditorLayer *m_editorLayer; // x0
float v8; // s0
float v9; // s1
GameObject *m_selectedObject; // x0
float v11; // s8
bool v12; // w27
float v13; // s0
float v14; // s1
float v15; // s0
float v16; // s1
LevelEditorLayer *v17; // x25
float v18; // s2
float v19; // s0
float v20; // s1
cocos2d::CCArray *v21; // x0
GameObject *Object; // x22
GameObject *v23; // x0
float v24; // s0
float v25; // s1
LevelEditorLayer *v26; // x0
cocos2d::CCArray *v27; // x0
cocos2d::CCArray *v28; // x24
GameObject *v29; // x1
GameManager *v30; // x0
cocos2d::CCArray *v31; // x21
void *v32; // x0
unsigned int i; // w22
_BYTE *v34; // x27
__int64 v35; // x0
float v36; // s0
float v37; // s1
int v38; // w22
bool v39; // zf
unsigned int v40; // w22
__int64 v41; // x25
unsigned int j; // w22
__int64 v43; // x24
char *v44; // x23
cocos2d::CCArray *NewKeyframeAnim; // x0
LevelEditorLayer *v46; // x0
float v47; // s8
float v48; // s8
int v49; // w22
unsigned int k; // w24
GameObject *v51; // x0
void *v52; // x0
unsigned int *v53; // x2
int v54; // w1
unsigned int *v55; // x22
int v56; // w0
unsigned int *v57; // x1
int v58; // w2
cocos2d::CCPoint v59; // [xsp+70h] [xbp+70h] BYREF
cocos2d::CCPoint v60; // [xsp+78h] [xbp+78h] BYREF
_BYTE v61[8]; // [xsp+80h] [xbp+80h] BYREF
cocos2d::CCPoint v62; // [xsp+88h] [xbp+88h] BYREF
char *v63; // [xsp+90h] [xbp+90h] BYREF
cocos2d::CCPoint v64; // [xsp+98h] [xbp+98h] BYREF
_BYTE v65[8]; // [xsp+A0h] [xbp+A0h] BYREF
cocos2d::CCPoint v66; // [xsp+A8h] [xbp+A8h] BYREF
cocos2d::CCPoint v67; // [xsp+B0h] [xbp+B0h] BYREF
cocos2d::CCPoint GroupCenter; // 0:kr18_8.8
cocos2d::CCPoint v69; // 0:s0.4,4:s1.4
cocos2d::CCPoint v70; // 0:s0.4,4:s1.4
cocos2d::CCPoint v71; // 0:s0.4,4:s1.4
cocos2d::CCPoint v72; // 0:s0.4,4:s1.4
cocos2d::CCPoint v73; // 0:s0.4,4:s1.4
cocos2d::CCPoint v74; // 0:s0.4,4:s1.4
cocos2d::CCPoint v75; // 0:s1.4,4:s2.4
cocos2d::CCPoint::CCPoint(&v67, &a1->m_clickAtPosition);
EditorUI::getGridSnappedPos(a1, v69);
cocos2d::CCPoint::CCPoint(&v60, &v59);
v4 = a1->m_gridSize * 0.5;
x = v4 - 3000.0;
if ( v59.x >= (float)(v4 - 3000.0) )
x = v59.x;
y = v59.y;
if ( v59.y < -3000.0 )
y = -3000.0;
if ( x >= (float)(240000.0 - v4) )
x = 240000.0 - v4;
m_editorLayer = a1->m_editorLayer;
v59.x = x;
if ( m_editorLayer->m_levelSettings->m_dynamicLevelHeight )
v8 = 30090.0;
else
v8 = 2490.0;
v9 = v8 - v4;
if ( y >= v9 )
y = v9;
v59.y = y;
EditorUI::offsetForKey(a1, a2);
cocos2d::CCPoint::CCPoint(&v62);
m_selectedObject = a1->m_selectedObject;
if ( m_selectedObject && m_selectedObject->m_objectID == a2 )
{
v12 = m_selectedObject->isFlipX(m_selectedObject);
a1->m_selectedObject->isFlipY(a1->m_selectedObject);
v11 = a1->m_selectedObject->getRotation(a1->m_selectedObject);
EditorUI::getRelativeOffset(a1, a1->m_selectedObject);
cocos2d::CCPoint::operator+(&v67, &v59, &v66);
cocos2d::CCPoint::operator=(&v62, v24, v25);
}
else
{
v11 = 0.0;
v12 = 0;
cocos2d::CCPoint::operator+(&v67, &v59, v61);
cocos2d::CCPoint::operator=(&v62, v13, v14);
}
cocos2d::CCPoint::operator+(&v67, &v59, v61);
cocos2d::CCPoint::operator=(&v59, v15, v16);
v17 = a1->m_editorLayer;
cocos2d::CCPoint::CCPoint(&v66, &v62);
v70.x = v11;
if ( LevelEditorLayer::typeExistsAtPosition(v17, a2, v70, (bool)&v66, v12, v18)
|| a2 < 0 && (cocos2d::CCPoint::CCPoint(&v67, &v60), EditorUI::positionIsInSnapped(a1, v74)) )
{
cocos2d::CCPoint::operator=(&a1->m_createPosition, v19, v20);
return;
}
cocos2d::CCPoint::CCPoint(&v67, &v60);
EditorUI::addSnapPosition(a1, v71);
if ( a2 > 0 )
{
cocos2d::CCPoint::CCPoint(&v67, &v59);
Object = EditorUI::createObject(a1, a2, v72);
v23 = a1->m_selectedObject;
if ( v23 && Object->m_objectID == v23->m_objectID )
{
EditorUI::removeOffset(a1, Object);
GameObject::duplicateValues(Object);
EditorUI::applyOffset(a1, Object);
}
if ( a2 == 914 )
{
sub_D153B8((int)&v67, "A");
TextGameObject::updateTextObject((__int64 *)Object, (const void **)&v67, 0);
v52 = (void *)(*(_QWORD *)&v67 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v67 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v53 = (unsigned int *)(*(_QWORD *)&v67 - 8LL);
do
v54 = __ldaxr(v53);
while ( __stlxr(v54 - 1, v53) );
}
else
{
v54 = *(_DWORD *)(*(_QWORD *)&v67 - 8LL);
*(_DWORD *)(*(_QWORD *)&v67 - 8LL) = v54 - 1;
}
if ( v54 <= 0 )
operator delete(v52);
}
}
else if ( a2 == 3032 )
{
LevelEditorLayer::removeSpecial(a1->m_editorLayer, Object);
NewKeyframeAnim = GJBaseGameLayer::createNewKeyframeAnim(a1->m_editorLayer);
LODWORD(Object[1].m_sQuad.bl.texCoords.v) = NewKeyframeAnim->getTag(NewKeyframeAnim);
v46 = a1->m_editorLayer;
Object[1].m_sQuad.tr.vertices.x = 0.0;
LevelEditorLayer::addSpecial(v46, Object);
EditorUI::selectObject(a1, Object, 0);
LABEL_24:
if ( Object->m_classType == Effect
&& (GameObject::isSpeedObject(Object) || Object->canReverse(Object) && LOBYTE(Object[1].m_obRect.origin.y)) )
{
v26 = a1->m_editorLayer;
LOBYTE(Object[1].m_pobTexture) = 1;
DrawGridLayer::addToSpeedObjects(v26->m_drawGridLayer, (EffectGameObject *)Object);
EditorUI::updateSlider(a1);
return;
}
LABEL_25:
EditorUI::updateSlider(a1);
return;
}
EditorUI::selectObject(a1, Object, 0);
if ( !Object )
goto LABEL_25;
goto LABEL_24;
}
v27 = (cocos2d::CCArray *)cocos2d::CCArray::create(v21);
v28 = v27;
v29 = a1->m_selectedObject;
if ( v29 )
cocos2d::CCArray::addObject(v27, v29);
else
cocos2d::CCArray::addObjectsFromArray(v27, a1->m_selectedObjects);
v30 = GameManager::sharedState();
GameManager::stringForCustomObject(v30, (const char *)(unsigned int)a2, (__int64)&v63);
sub_D153B8((int)&v67, v63);
v31 = EditorUI::pasteObjects(a1, (const void **)&v67, 0, 0);
v32 = (void *)(*(_QWORD *)&v67 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v67 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v57 = (unsigned int *)(*(_QWORD *)&v67 - 8LL);
do
v58 = __ldaxr(v57);
while ( __stlxr(v58 - 1, v57) );
}
else
{
v58 = *(_DWORD *)(*(_QWORD *)&v67 - 8LL);
*(_DWORD *)(*(_QWORD *)&v67 - 8LL) = v58 - 1;
}
if ( v58 <= 0 )
{
operator delete(v32);
if ( !v31 )
goto LABEL_52;
LABEL_34:
if ( (unsigned int)cocos2d::CCArray::count(v31) )
{
for ( i = 0; i < (unsigned int)cocos2d::CCArray::count(v31); ++i )
{
v34 = (_BYTE *)cocos2d::CCArray::objectAtIndex(v31, i);
if ( v34[1134] )
goto LABEL_40;
}
v34 = nullptr;
LABEL_40:
cocos2d::CCPoint::CCPoint(&v64, &v60);
if ( v34 )
{
GroupCenter = EditorUI::getGroupCenter(a1, v31, 0);
v35 = (*(__int64 (__fastcall **)(_BYTE *, float, float))(*(_QWORD *)v34 + 192LL))(
v34,
GroupCenter.x,
GroupCenter.y);
cocos2d::CCPoint::operator-(&v66, v65, v35);
cocos2d::CCPoint::operator+(&v67, &v64, &v66);
cocos2d::CCPoint::operator=(&v64, v36, v37);
}
cocos2d::CCPoint::CCPoint(&v67, &v64);
EditorUI::repositionObjectsToCenter(a1, v31, v73, (bool)&v67);
v38 = cocos2d::CCArray::count(v31);
v39 = v38 == (unsigned int)cocos2d::CCArray::count(v28);
v40 = 0;
if ( v39 )
{
while ( v40 < (unsigned int)cocos2d::CCArray::count(v28) )
{
v41 = cocos2d::CCArray::objectAtIndex(v28, v40);
if ( *(_BYTE *)(v41 + 1134) )
goto LABEL_48;
++v40;
}
v41 = 0;
LABEL_48:
for ( j = 0; j < (unsigned int)cocos2d::CCArray::count(v31); ++j )
{
v43 = cocos2d::CCArray::objectAtIndex(v31, j);
if ( *(_BYTE *)(v43 + 1134) )
{
if ( v41 )
{
if ( *(_DWORD *)(v41 + 1012) == *(_DWORD *)(v43 + 1012) )
{
v47 = (*(float (__fastcall **)(__int64))(*(_QWORD *)v41 + 352LL))(v41);
if ( v47 != (*(float (__fastcall **)(__int64))(*(_QWORD *)v43 + 352LL))(v43) )
{
v48 = (*(float (__fastcall **)(__int64))(*(_QWORD *)v41 + 352LL))(v41);
v49 = (int)(float)(v48 - (*(float (__fastcall **)(__int64))(*(_QWORD *)v43 + 352LL))(v43));
if ( v49 % 90 )
{
for ( k = 0; k < (unsigned int)cocos2d::CCArray::count(v31); ++k )
{
v51 = (GameObject *)cocos2d::CCArray::objectAtIndex(v31, k);
if ( !GameObject::canRotateFree(v51) )
goto LABEL_52;
}
}
cocos2d::CCPoint::CCPoint(&v67, (const cocos2d::CCPoint *)&dword_1242110);
EditorUI::rotateObjects(a1, v31, (float)v49, v75);
}
}
}
goto LABEL_52;
}
}
}
}
goto LABEL_52;
}
}
if ( v31 )
goto LABEL_34;
LABEL_52:
v44 = v63 - 24;
if ( v63 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v55 = (unsigned int *)(v63 - 8);
do
v56 = __ldaxr(v55);
while ( __stlxr(v56 - 1, v55) );
}
else
{
v56 = *((_DWORD *)v63 - 2);
*((_DWORD *)v63 - 2) = v56 - 1;
}
if ( v56 <= 0 )
operator delete(v44);
}
}