//
// EditorUI::alignObjects from 0xc02f80 to 0xc03498 (1304 bytes)
//
// 5 xrefs:
// > EditorUI::handleEditorAction @ 0xbd7928
// > EditorUI::handleEditorAction @ 0xbd794c
// > EditorCommandsPopup::onCommand @ 0xcbc084
// > EditorCommandsPopup::onCommand @ 0xcbc0a8
// > ??> @ 0xba880
//
// This function is hookable on this platform (idp: arm, 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 13:03:50 +0000
//
__int64 __fastcall EditorUI::alignObjects(cocos2d::CCDictionary ***this, cocos2d::CCArray *a2, unsigned __int8 a3)
{
cocos2d::CCArray *v6; // x0
unsigned int v7; // w1
cocos2d::CCArray *v8; // x0
cocos2d::CCDictionary *v9; // x0
cocos2d::CCDictionary *v10; // x23
unsigned int v11; // w19
__int64 v12; // x20
cocos2d::CCObject *v13; // x0
unsigned int *v14; // x1
__int64 *v15; // x19
__int64 *v16; // x23
__int64 v17; // x0
int v18; // w24
const cocos2d::CCPoint *v19; // x0
signed int v20; // w24
long double v21; // q0
int v22; // w0
int *v23; // x23
const cocos2d::CCPoint *v24; // x0
long double v25; // q0
long double v26; // q0
long double v27; // q0
unsigned int v28; // w19
cocos2d::CCArray *v29; // x23
unsigned int v30; // w1
__int64 v31; // x27
unsigned int v32; // w19
cocos2d::CCArray *v33; // x23
int v34; // w20
cocos2d::CCArray *StickyGroup; // x0
const char *v36; // x1
cocos2d::CCObject *v37; // x28
__int64 v38; // x2
void (__fastcall *v39)(cocos2d::CCObject *, __int64 *); // x20
int v40; // [xsp+74h] [xbp+74h]
float v41; // [xsp+88h] [xbp+88h] BYREF
float v42; // [xsp+8Ch] [xbp+8Ch]
float v43; // [xsp+90h] [xbp+90h] BYREF
float v44; // [xsp+94h] [xbp+94h]
__int64 v45; // [xsp+98h] [xbp+98h] BYREF
float v46; // [xsp+A0h] [xbp+A0h]
float v47; // [xsp+A4h] [xbp+A4h]
float v48[2]; // [xsp+A8h] [xbp+A8h] BYREF
_BYTE v49[8]; // [xsp+B0h] [xbp+B0h] BYREF
__int64 v50; // [xsp+B8h] [xbp+B8h] BYREF
__int64 v51; // [xsp+C0h] [xbp+C0h] BYREF
v40 = a3;
if ( a2 && (unsigned int)cocos2d::CCArray::count(a2) > 2 )
{
v6 = (cocos2d::CCArray *)cocos2d::CCArray::count(a2);
v8 = (cocos2d::CCArray *)cocos2d::CCArray::createWithCapacity(v6, v7);
v9 = (cocos2d::CCDictionary *)cocos2d::CCArray::addObjectsFromArray(v8, a2);
v10 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create(v9);
if ( *((_BYTE *)this + 867) && !*((_BYTE *)this + 868) )
{
v11 = 0;
while ( v11 < (unsigned int)cocos2d::CCArray::count(a2) )
{
while ( 1 )
{
v12 = cocos2d::CCArray::objectAtIndex(a2, v11);
if ( *(int *)(v12 + 872) > 0 )
break;
if ( ++v11 >= (unsigned int)cocos2d::CCArray::count(a2) )
goto LABEL_45;
}
cocos2d::CCArray::removeObjectAtIndex(a2, v11, 1);
if ( !cocos2d::CCDictionary::objectForKey(v10, *(int *)(v12 + 872)) )
{
v13 = (cocos2d::CCObject *)cocos2d::CCNode::create(nullptr);
cocos2d::CCDictionary::setObject(v10, v13, *(int *)(v12 + 872));
}
}
LABEL_45:
v32 = 0;
v33 = (cocos2d::CCArray *)cocos2d::CCDictionary::allKeys(v10);
while ( v32 < (unsigned int)cocos2d::CCArray::count(v33) )
{
v34 = *(_DWORD *)(cocos2d::CCArray::objectAtIndex(v33, v32) + 56);
StickyGroup = (cocos2d::CCArray *)GJBaseGameLayer::getStickyGroup(*(this + 180), v34);
if ( StickyGroup )
{
EditorUI::getGroupCenter((cocos2d::CCPoint *)&v50, StickyGroup, 1u);
v37 = (cocos2d::CCObject *)GameObject::createWithFrame((GameObject *)"checkpoint_01_001.png", v36);
v38 = *(_QWORD *)v37;
*((_DWORD *)v37 + 257) = 44;
*((_DWORD *)v37 + 218) = v34;
v39 = *(void (__fastcall **)(cocos2d::CCObject *, __int64 *))(v38 + 1368);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v51, (const cocos2d::CCPoint *)&v50);
v39(v37, &v51);
cocos2d::CCArray::addObject(a2, v37);
}
++v32;
}
}
if ( v40 )
qsort(
*(void **)(*((_QWORD *)a2 + 7) + 16LL),
**((unsigned int **)a2 + 7),
8u,
(int (*)(const void *, const void *))alignYSort);
else
qsort(
*(void **)(*((_QWORD *)a2 + 7) + 16LL),
**((unsigned int **)a2 + 7),
8u,
(int (*)(const void *, const void *))alignXSort);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v41);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v43);
v14 = *((unsigned int **)a2 + 7);
if ( *v14 )
{
v15 = *((__int64 **)v14 + 2);
v16 = &v15[*v14 - 1];
if ( v15 <= v16 )
{
v17 = *v15;
if ( *v15 )
{
v18 = 1;
do
{
v19 = (const cocos2d::CCPoint *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v17 + 192LL))(v17);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v51, v19);
if ( v18 )
{
cocos2d::CCPoint::operator=(&v41, &v51);
cocos2d::CCPoint::operator=(&v43, &v51);
}
else
{
if ( *(float *)&v51 < v41 )
v41 = *(float *)&v51;
if ( *(float *)&v51 > v43 )
v43 = *(float *)&v51;
if ( *((float *)&v51 + 1) < v42 )
v42 = *((float *)&v51 + 1);
if ( *((float *)&v51 + 1) > v44 )
v44 = *((float *)&v51 + 1);
}
if ( v16 < ++v15 )
break;
v17 = *v15;
v18 = 0;
}
while ( *v15 );
}
}
}
if ( v41 != v43 || v42 != v44 )
{
EditorUI::createUndoObject((__int64)this, 5, 0);
v20 = 1;
cocos2d::CCPoint::operator-(&v45, &v43, &v41, v21);
v22 = cocos2d::CCArray::count(a2);
cocos2d::CCPoint::operator*(&v45, 1.0 / (float)(unsigned int)(v22 - 1));
if ( (unsigned int)cocos2d::CCArray::count(a2) - 1 > 1 )
{
do
{
v23 = (int *)cocos2d::CCArray::objectAtIndex(a2, v20);
v24 = (const cocos2d::CCPoint *)(*(__int64 (__fastcall **)(int *))(*(_QWORD *)v23 + 192LL))(v23);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v48, v24);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v49);
if ( v40 )
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v51, v48[0], v42 + (float)((float)v20 * v47));
*(__n128 *)&v25 = cocos2d::CCPoint::operator=(v49, &v51);
cocos2d::CCPoint::operator-(&v50, v49, v48, v25);
if ( v23[257] != 44 )
goto LABEL_33;
}
else
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v51, v41 + (float)((float)v20 * v46), v48[1]);
*(__n128 *)&v27 = cocos2d::CCPoint::operator=(v49, &v51);
cocos2d::CCPoint::operator-(&v50, v49, v48, v27);
if ( v23[257] != 44 )
{
LABEL_33:
cocos2d::CCPoint::operator-(&v51, v49, v48, v26);
EditorUI::moveObject((__int64)this, (__int64)v23);
goto LABEL_34;
}
}
v28 = 0;
v29 = (cocos2d::CCArray *)GJBaseGameLayer::getStickyGroup(*(this + 180), v23[218]);
if ( v29 )
{
while ( v28 < (unsigned int)cocos2d::CCArray::count(v29) )
{
v30 = v28++;
v31 = cocos2d::CCArray::objectAtIndex(v29, v30);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v51, (const cocos2d::CCPoint *)&v50);
EditorUI::moveObject((__int64)this, v31);
}
++v20;
continue;
}
LABEL_34:
++v20;
}
while ( v20 < (unsigned int)cocos2d::CCArray::count(a2) - 1 );
}
EditorUI::updateControlsAfterAlign((EditorUI *)this);
}
}
return _stack_chk_guard;
}