//
// EditorUI::onDelete from 0x1401aff90 to 0x1401b0521 (1425 bytes)
//
// 2 xrefs:
// > EditorUI::clickOnPosition @ 0x1401ada6a
// > ??> @ 0x140919e8c
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:27:55 +0000
//
// Hidden C++ exception states: #wind=2
__int64 __fastcall EditorUI::onDelete(__int64 a1, cocos2d::CCObject **a2)
{
__int64 v3; // rax
__int64 v4; // rcx
cocos2d::CCArray *v5; // r14
bool v6; // r13
__int64 v7; // rax
char v8; // bp
unsigned int j; // esi
struct cocos2d::CCObject *v10; // rbx
__int64 v11; // rcx
signed int v12; // r12d
signed int i; // r15d
struct cocos2d::CCObject *v14; // rbx
unsigned int v15; // esi
struct cocos2d::CCObject *v16; // rax
__int64 v17; // rcx
struct cocos2d::CCObject *v18; // rbp
__int64 v19; // rcx
cocos2d::CCDictionary *v20; // rbp
__int64 v21; // rax
unsigned int *v22; // rbx
__int64 v23; // rax
int **v24; // rbx
int **k; // r14
int *v26; // rsi
cocos2d::CCArray *v27; // r15
unsigned int m; // r14d
struct cocos2d::CCObject *v29; // rax
cocos2d::CCArray *v30; // rax
cocos2d::CCArray *v31; // rbp
unsigned int v32; // ebx
struct cocos2d::CCObject *v33; // rsi
__int64 v34; // rbx
__int64 v35; // rax
_BYTE *v36; // rcx
__int64 v37; // r8
int v38; // r9d
int v39; // eax
int v40; // ecx
unsigned int *v41; // rsi
__int64 v42; // rax
__int64 *v43; // rsi
__int64 *n; // rbp
__int64 v45; // rbx
struct cocos2d::CCArray *v46; // rbx
cocos2d::CCObject **v47; // rsi
__int64 v48; // rcx
cocos2d::CCArray *v49; // rax
__int64 v50; // rbp
unsigned int v51; // ebx
cocos2d::CCObject **v53; // [rsp+58h] [rbp+10h] BYREF
v53 = a2;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v53, (const struct cocos2d::CCPoint *)(a1 + 1560));
v5 = (cocos2d::CCArray *)LevelEditorLayer::objectsAtPosition(*(_QWORD *)(a1 + 1512), v3);
v6 = 0;
if ( !*(_BYTE *)(a1 + 908)
|| (v7 = cocos2d::CCDirector::sharedDirector(v4),
*(_BYTE *)((*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v7 + 176LL))(v7) + 152)) )
{
v12 = cocos2d::CCArray::count(v5);
for ( i = 0; i < v12; ++i )
{
v14 = nullptr;
v15 = 0;
if ( !cocos2d::CCArray::count(v5) )
break;
do
{
v16 = cocos2d::CCArray::objectAtIndex(v5, v15);
v18 = v16;
if ( !v14 || (v17 = *((unsigned int *)v14 + 286), *((_DWORD *)v16 + 286) < (int)v17) )
{
if ( (unsigned __int8)EditorUI::canSelectObject(v17, v16) )
v14 = v18;
}
++v15;
}
while ( v15 < cocos2d::CCArray::count(v5) );
if ( !v14 )
break;
*((_DWORD *)v14 + 286) = *(_DWORD *)(a1 + 1612);
if ( (unsigned __int8)EditorUI::shouldDeleteObject(v19, v14) )
{
if ( *((_DWORD *)v14 + 259) == 747 )
EditorUI::deselectTargetPortals(a1);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 1416), v14);
v6 = *((_DWORD *)v14 + 220) > 0;
break;
}
}
}
else
{
v8 = 0;
for ( j = 0; j < cocos2d::CCArray::count(v5); ++j )
{
v10 = cocos2d::CCArray::objectAtIndex(v5, j);
if ( (unsigned __int8)EditorUI::shouldDeleteObject(v11, v10) )
{
if ( !v8 && *((_DWORD *)v10 + 259) == 747 )
{
v8 = 1;
EditorUI::deselectTargetPortals(a1);
}
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 1416), v10);
if ( !v6 )
v6 = *((_DWORD *)v10 + 220) > 0;
}
}
}
if ( !*(_BYTE *)(a1 + 915) || *(_BYTE *)(a1 + 916) )
{
v6 = 0;
}
else if ( v6 )
{
v20 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create();
v21 = *(_QWORD *)(a1 + 1416);
if ( v21 )
{
v22 = *(unsigned int **)(v21 + 56);
v23 = *v22;
if ( (_DWORD)v23 )
{
v24 = *((int ***)v22 + 2);
for ( k = &v24[v23 - 1]; v24 <= k; ++v24 )
{
v26 = *v24;
if ( !*v24 )
break;
if ( v26[220] > 0 && !cocos2d::CCDictionary::objectForKey(v20, v26[220]) )
cocos2d::CCDictionary::setObject(v20, (struct cocos2d::CCObject *)v26, v26[220]);
}
}
}
v27 = cocos2d::CCDictionary::allKeys(v20);
for ( m = 0; m < cocos2d::CCArray::count(v27); ++m )
{
v29 = cocos2d::CCArray::objectAtIndex(v27, m);
v30 = cocos2d::CCDictionary::objectForKey(
*(cocos2d::CCDictionary **)(*(_QWORD *)(a1 + 1512) + 4256LL),
*((int *)v29 + 14));
v31 = v30;
if ( v30 )
{
v32 = 0;
if ( cocos2d::CCArray::count(v30) )
{
do
{
v33 = cocos2d::CCArray::objectAtIndex(v31, v32);
if ( !cocos2d::CCArray::containsObject(*(cocos2d::CCArray **)(a1 + 1416), v33) )
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 1416), v33);
++v32;
}
while ( v32 < cocos2d::CCArray::count(v31) );
}
}
}
}
v34 = a1 + 1416;
if ( cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 1416)) )
{
v35 = EditorSFXManager::sharedState();
EditorSFXManager::playAction(v35, 101);
v36 = (_BYTE *)(a1 + 756);
if ( !*(_BYTE *)(a1 + 756) )
{
v37 = *(_QWORD *)(a1 + 1512) + 15408LL;
v38 = *(_DWORD *)(*(_QWORD *)(a1 + 1512) + 15504LL);
if ( v38 >= 0 )
{
v39 = *(_DWORD *)(*(_QWORD *)(a1 + 1512) + 15440LL) - v38;
v40 = 0;
if ( v39 > 1 )
{
do
{
if ( v40 >= 7 )
break;
v39 = (unsigned int)v39 >> 1;
++v40;
}
while ( (unsigned int)v39 > 1 );
}
++*(_DWORD *)(v37 + 4LL * v40 + 64);
v36 = (_BYTE *)(a1 + 756);
v34 = a1 + 1416;
}
*(_DWORD *)(v37 + 96) = *(_DWORD *)(v37 + 32);
}
*v36 = 1;
}
if ( *(_QWORD *)v34 )
{
v41 = *(unsigned int **)(*(_QWORD *)v34 + 56LL);
v42 = *v41;
if ( (_DWORD)v42 )
{
v43 = *((__int64 **)v41 + 2);
for ( n = &v43[v42 - 1]; v43 <= n; ++v43 )
{
v45 = *v43;
if ( !*v43 )
break;
*(_BYTE *)(v45 + 1140) = *(_BYTE *)(v45 + 1141);
EditorUI::deselectObject(a1, v45);
LevelEditorLayer::removeObject(*(_QWORD *)(a1 + 1512), v45, v6);
EditorUI::deactivateRotationControl(a1);
EditorUI::deactivateScaleControl(a1);
EditorUI::deactivateTransformControl(a1);
}
}
}
if ( v6 )
{
*(_DWORD *)(*(_QWORD *)(a1 + 1512) + 15416LL) += cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 1416));
v46 = *(struct cocos2d::CCArray **)(a1 + 1416);
v47 = (cocos2d::CCObject **)operator new(0xA0u);
v53 = v47;
cocos2d::CCObject::CCObject((cocos2d::CCObject *)v47);
*v47 = (cocos2d::CCObject *)&UndoObject::`vftable';
v47[7] = nullptr;
*((_DWORD *)v47 + 16) = 0;
v47[9] = nullptr;
*((_WORD *)v47 + 40) = 0;
GJTransformState::GJTransformState((__int64)v47 + 84);
if ( v46 )
{
v49 = (cocos2d::CCArray *)cocos2d::CCArray::create(v48);
v47[9] = v49;
cocos2d::CCArray::addObjectsFromArray(v49, v46);
cocos2d::CCObject::retain(v47[9]);
}
*((_DWORD *)v47 + 16) = 4;
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v47);
v50 = *(_QWORD *)(a1 + 1512);
cocos2d::CCArray::removeAllObjects(*(cocos2d::CCArray **)(v50 + 14920));
v51 = 1000;
if ( !*(_BYTE *)(v50 + 14663) )
v51 = 200;
if ( cocos2d::CCArray::count(*(cocos2d::CCArray **)(v50 + 14912)) >= v51 )
cocos2d::CCArray::removeObjectAtIndex(*(cocos2d::CCArray **)(v50 + 14912), 0, 1);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(v50 + 14912), (struct cocos2d::CCObject *)v47);
}
cocos2d::CCArray::removeAllObjects(*(cocos2d::CCArray **)(a1 + 1416));
if ( !*(_QWORD *)(a1 + 1568) && !cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 944)) )
{
EditorUI::deactivateRotationControl(a1);
EditorUI::deactivateScaleControl(a1);
EditorUI::deactivateTransformControl(a1);
}
EditorUI::updateObjectInfoLabel(a1);
return (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)(a1 + 432) + 40LL))(a1 + 432);
}