//
// EditorUI::onDelete from 0x1003e6850 to 0x1003e6b84 (820 bytes)
//
// 1 xrefs:
// > EditorUI::clickOnPosition @ 0x1003e6758
//
// 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::onDelete(EditorUI *a1, cocos2d::CCObject *a2)
{
LevelEditorLayer *m_editorLayer; // x20
cocos2d::CCArray *v4; // x20
cocos2d::CCDirector *v5; // x0
int v6; // w0
int v7; // w21
GameObject *CycledObject; // x0
GameObject *v9; // x22
_BOOL4 v10; // w25
char v11; // w23
unsigned int v12; // w21
__int64 v13; // x22
bool v14; // w20
cocos2d::CCDictionary *v15; // x20
cocos2d::CCArray *m_deleteObjects; // x8
cocos2d::ccArray *data; // x9
__int64 num; // x8
cocos2d::CCObject **arr; // x22
unsigned __int64 v20; // x23
cocos2d::CCObject *v21; // x21
intptr_t m_uIndexInArray; // x1
cocos2d::CCArray *v23; // x20
unsigned int v24; // w21
__int64 v25; // x0
cocos2d::CCArray *StickyGroup; // x0
__int64 v27; // x22
unsigned int v28; // w23
__int64 v29; // x0
cocos2d::CCArray *v30; // x0
cocos2d::ccArray *v31; // x9
__int64 v32; // x8
GameObject **v33; // x21
unsigned __int64 v34; // x22
UndoObject *v35; // x0
__int64 v36; // [xsp+8h] [xbp-48h] BYREF
cocos2d::CCPoint v37; // 0:s0.4,4:s1.4
m_editorLayer = a1->m_editorLayer;
v37.x = sub_1000229B8(&v36, (__int64 *)&a1->m_clickAtPosition);
v4 = LevelEditorLayer::objectsAtPosition(m_editorLayer, v37);
if ( !a1->m_swipeEnabled
|| (v5 = cocos2d::CCDirector::sharedDirector(),
(*(_BYTE *)(((__int64 (__fastcall *)(cocos2d::CCDirector *))v5->getKeyboardDispatcher)(v5) + 88) & 1) != 0) )
{
v6 = sub_10024A36C((__int64)v4);
if ( v6 >= 1 )
{
v7 = v6;
while ( 1 )
{
CycledObject = EditorUI::getCycledObject(a1, v4, 1);
if ( !CycledObject )
break;
v9 = CycledObject;
if ( EditorUI::shouldDeleteObject((EditorUI *)CycledObject, CycledObject) )
{
if ( v9->m_objectID == 747 )
EditorUI::deselectTargetPortals(a1);
sub_10024A2D0((__int64)a1->m_deleteObjects);
v10 = v9->m_linkedGroup > 0;
goto LABEL_23;
}
if ( !--v7 )
goto LABEL_22;
}
}
goto LABEL_22;
}
if ( (unsigned int)sub_10024A36C((__int64)v4) )
{
v10 = 0;
v11 = 0;
v12 = 0;
while ( 1 )
{
v13 = sub_10024A388((__int64)v4, v12);
if ( EditorUI::shouldDeleteObject((EditorUI *)v13, (GameObject *)v13) )
break;
LABEL_20:
if ( ++v12 >= (unsigned int)sub_10024A36C((__int64)v4) )
goto LABEL_23;
}
if ( (v11 & 1) == 0 )
{
if ( *(_DWORD *)(v13 + 1028) != 747 )
{
v11 = 0;
LABEL_17:
sub_10024A2D0((__int64)a1->m_deleteObjects);
v10 = v10 || *(_DWORD *)(v13 + 872) > 0;
goto LABEL_20;
}
EditorUI::deselectTargetPortals(a1);
}
v11 = 1;
goto LABEL_17;
}
LABEL_22:
v10 = 0;
LABEL_23:
if ( a1->m_stickyControlsEnabled )
{
v14 = 0;
if ( !a1->m_linkControlsDisabled && v10 )
{
v15 = cocos2d::CCDictionary::create();
m_deleteObjects = a1->m_deleteObjects;
if ( m_deleteObjects )
{
data = m_deleteObjects->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
v20 = (unsigned __int64)&arr[num - 1];
do
{
v21 = *arr;
if ( !*arr )
break;
m_uIndexInArray = (unsigned int)v21[15].m_uIndexInArray;
if ( (int)m_uIndexInArray >= 1 && !cocos2d::CCDictionary::objectForKey(v15, m_uIndexInArray) )
cocos2d::CCDictionary::setObject(v15, v21, v21[15].m_uIndexInArray);
++arr;
}
while ( (unsigned __int64)arr <= v20 );
}
}
v23 = cocos2d::CCDictionary::allKeys(v15);
if ( (unsigned int)sub_10024A36C((__int64)v23) )
{
v24 = 0;
do
{
v25 = sub_10024A388((__int64)v23, v24);
StickyGroup = GJBaseGameLayer::getStickyGroup(a1->m_editorLayer, *(_DWORD *)(v25 + 56));
if ( StickyGroup )
{
v27 = (__int64)StickyGroup;
if ( (unsigned int)sub_10024A36C((__int64)StickyGroup) )
{
v28 = 0;
do
{
v29 = sub_10024A388(v27, v28);
if ( (sub_10024A420((__int64)a1->m_deleteObjects, v29) & 1) == 0 )
sub_10024A2D0((__int64)a1->m_deleteObjects);
++v28;
}
while ( v28 < (unsigned int)sub_10024A36C(v27) );
}
}
++v24;
}
while ( v24 < (unsigned int)sub_10024A36C((__int64)v23) );
}
v14 = v10;
}
}
else
{
v14 = 0;
}
v30 = a1->m_deleteObjects;
if ( v30 )
{
v31 = v30->data;
v32 = v31->num;
if ( (_DWORD)v32 )
{
v33 = (GameObject **)v31->arr;
v34 = (unsigned __int64)&v33[v32 - 1];
do
{
if ( !*v33 )
break;
EditorUI::deleteObject(a1, *v33++, v14);
}
while ( (unsigned __int64)v33 <= v34 );
v30 = a1->m_deleteObjects;
}
}
if ( v14 )
{
v35 = UndoObject::createWithArray(v30, DeleteMulti);
LevelEditorLayer::addToUndoList(a1->m_editorLayer, v35, 0);
v30 = a1->m_deleteObjects;
}
sub_10024A45C((__int64)v30);
EditorUI::updateObjectInfoLabel(a1);
((void (__fastcall *)(EditorUI *))a1->updateScaleControl)(a1);
}