//
// EditorUI::onDelete from 0x6c0a50 to 0x6c0e04 (948 bytes)
//
// 2 xrefs:
// > EditorUI::clickOnPosition @ 0x6c175c
// > ??> @ 0x76cc8
//
// 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::onDelete(EditorUI *a1, cocos2d::CCObject *a2)
{
LevelEditorLayer *m_editorLayer; // x21
cocos2d::CCArray *v4; // x22
int v5; // w19
int v6; // w23
GameObject *CycledObject; // x21
_BOOL4 v8; // w23
cocos2d::CCDictionary *v9; // x25
cocos2d::CCArray *m_deleteObjects; // x0
cocos2d::ccArray *data; // x1
cocos2d::CCObject **arr; // x19
__int64 v13; // x0
char *v14; // x22
cocos2d::CCObject *v15; // x21
int m_nTag; // w1
cocos2d::CCDictionary *v17; // x0
unsigned int v18; // w25
cocos2d::CCArray *v19; // x26
unsigned int v20; // w19
__int64 v21; // x0
cocos2d::CCArray *StickyGroup; // x0
cocos2d::CCArray *v23; // x21
cocos2d::CCObject *v24; // x22
cocos2d::CCArray *v25; // x2
cocos2d::ccArray *v26; // x0
GameObject **v27; // x19
GameObject **v28; // x21
GameObject *v29; // x1
UndoObject *v30; // x0
cocos2d::CCArray *v31; // x0
cocos2d::ccArray *v32; // x0
cocos2d::CCDirector *v33; // x0
unsigned int v34; // w19
int v35; // w25
GameObject *v36; // x21
cocos2d::CCPoint v37; // [xsp+50h] [xbp+50h] BYREF
cocos2d::CCPoint v38; // 0:s0.4,4:s1.4
m_editorLayer = a1->m_editorLayer;
cocos2d::CCPoint::CCPoint(&v37, &a1->m_clickAtPosition);
v4 = LevelEditorLayer::objectsAtPosition(m_editorLayer, v38);
if ( !a1->m_swipeEnabled
|| (v33 = cocos2d::CCDirector::sharedDirector(), v33->getKeyboardDispatcher(v33)->m_bShiftPressed) )
{
v5 = 0;
v6 = cocos2d::CCArray::count(v4);
if ( v6 > 0 )
{
do
{
CycledObject = EditorUI::getCycledObject(a1, v4, 1);
if ( !CycledObject )
break;
if ( EditorUI::shouldDeleteObject(a1, CycledObject) )
{
if ( CycledObject->m_objectID == 747 )
EditorUI::deselectTargetPortals(a1);
cocos2d::CCArray::addObject(a1->m_deleteObjects, CycledObject);
v8 = CycledObject->m_linkedGroup > 0;
goto LABEL_8;
}
++v5;
}
while ( v6 != v5 );
}
v8 = 0;
}
else
{
v34 = 0;
v35 = 0;
v8 = 0;
while ( v34 < (unsigned int)cocos2d::CCArray::count(v4) )
{
v36 = (GameObject *)cocos2d::CCArray::objectAtIndex(v4, v34);
if ( EditorUI::shouldDeleteObject(a1, v36) )
{
if ( !v35 && v36->m_objectID == 747 )
{
v35 = 1;
EditorUI::deselectTargetPortals(a1);
}
cocos2d::CCArray::addObject(a1->m_deleteObjects, v36);
if ( !v8 )
v8 = v36->m_linkedGroup > 0;
}
++v34;
}
}
LABEL_8:
if ( a1->m_stickyControlsEnabled && !a1->m_linkControlsDisabled && v8 )
{
v9 = cocos2d::CCDictionary::create();
m_deleteObjects = a1->m_deleteObjects;
if ( m_deleteObjects )
{
data = m_deleteObjects->data;
if ( data->num )
{
arr = data->arr;
v13 = 8LL * data->num - 8;
v14 = (char *)arr + v13;
if ( arr <= (cocos2d::CCObject **)((char *)arr + v13) )
{
do
{
v15 = *arr;
if ( !*arr )
break;
m_nTag = v15[15].m_nTag;
if ( m_nTag > 0 && !cocos2d::CCDictionary::objectForKey(v9, m_nTag) )
cocos2d::CCDictionary::setObject(v9, v15, v15[15].m_nTag);
++arr;
}
while ( v14 >= (char *)arr );
}
}
}
v17 = v9;
v18 = 0;
v19 = cocos2d::CCDictionary::allKeys(v17);
if ( (unsigned int)cocos2d::CCArray::count(v19) )
{
do
{
v20 = 0;
v21 = cocos2d::CCArray::objectAtIndex(v19, v18);
StickyGroup = GJBaseGameLayer::getStickyGroup(a1->m_editorLayer, *(_DWORD *)(v21 + 56));
v23 = StickyGroup;
if ( StickyGroup && (unsigned int)cocos2d::CCArray::count(StickyGroup) )
{
do
{
v24 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(v23, v20++);
if ( !(unsigned __int8)cocos2d::CCArray::containsObject(a1->m_deleteObjects, v24) )
cocos2d::CCArray::addObject(a1->m_deleteObjects, v24);
}
while ( v20 < (unsigned int)cocos2d::CCArray::count(v23) );
}
++v18;
}
while ( v18 < (unsigned int)cocos2d::CCArray::count(v19) );
}
v25 = a1->m_deleteObjects;
if ( !v25 )
goto LABEL_34;
v26 = v25->data;
if ( !v26->num )
goto LABEL_34;
v27 = (GameObject **)v26->arr;
v28 = &v27[v26->num - 1];
if ( v27 > v28 )
goto LABEL_34;
}
else
{
v25 = a1->m_deleteObjects;
v31 = v25;
if ( !v25 )
goto LABEL_39;
v32 = v25->data;
if ( !v32->num || (v27 = (GameObject **)v32->arr, v8 = 0, v28 = &v27[v32->num - 1], v27 > v28) )
{
LABEL_38:
v31 = v25;
goto LABEL_39;
}
}
v29 = *v27;
if ( *v27 )
{
do
{
++v27;
EditorUI::deleteObject(a1, v29, v8);
if ( v28 < v27 )
break;
v29 = *v27;
}
while ( *v27 );
v25 = a1->m_deleteObjects;
}
if ( !v8 )
goto LABEL_38;
LABEL_34:
v30 = UndoObject::createWithArray(v25, DeleteMulti);
LevelEditorLayer::addToUndoList(a1->m_editorLayer, v30, 0);
v31 = a1->m_deleteObjects;
LABEL_39:
cocos2d::CCArray::removeAllObjects(v31);
EditorUI::updateSpecialUIElements(a1);
EditorUI::tryUpdateTimeMarkers(a1);
}