//
// EditorUI::alignObjectsOnAxis from 0x140201300 to 0x140201794 (1172 bytes)
//
// 5 xrefs:
// > EditorCommandsPopup::onCommand @ 0x14017db9d
// > EditorCommandsPopup::onCommand @ 0x14017dbc4
// > EditorUI::handleEditorAction @ 0x1401c33e4
// > EditorUI::handleEditorAction @ 0x1401c3409
// > ??> @ 0x14091ae34
//
// 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:28:13 +0000
//
// Hidden C++ exception states: #wind=1
void __fastcall EditorUI::alignObjectsOnAxis(__int64 a1, cocos2d::CCArray *a2, char a3)
{
unsigned int v6; // eax
cocos2d::CCArray *v7; // rax
cocos2d::CCDictionary *v8; // r14
unsigned int v9; // edi
struct cocos2d::CCObject *v10; // rbx
__int64 v11; // rbx
struct cocos2d::CCObject *v12; // rax
cocos2d::CCArray *v13; // r12
unsigned int i; // r14d
int v15; // ebx
struct cocos2d::CCObject *v16; // rax
__int64 v17; // rcx
__int64 v18; // r9
cocos2d::CCSprite *v19; // rax
cocos2d::CCSprite *v20; // rdi
__int64 v21; // rbx
__int64 v22; // rax
char v23; // di
unsigned int *v24; // rbx
__int64 v25; // rax
_QWORD *v26; // rbx
_QWORD *j; // r14
const struct cocos2d::CCPoint *v28; // rax
bool v29; // zf
__int64 v30; // rax
__int64 v31; // rdx
unsigned int *v32; // r14
__int64 v33; // rax
int **v34; // r14
int **k; // r12
int *v36; // rbx
const struct cocos2d::CCPoint *v37; // rax
cocos2d::CCArray *v38; // rax
cocos2d::CCArray *v39; // rsi
unsigned int v40; // edi
struct cocos2d::CCObject *v41; // rbx
__int64 v42; // rax
__int64 v43; // rax
float v44; // [rsp+20h] [rbp-30h] BYREF
float v45; // [rsp+24h] [rbp-2Ch]
_DWORD v46[2]; // [rsp+28h] [rbp-28h] BYREF
void *v47; // [rsp+30h] [rbp-20h] BYREF
char v48[8]; // [rsp+38h] [rbp-18h] BYREF
char v49[8]; // [rsp+40h] [rbp-10h] BYREF
char v50[8]; // [rsp+48h] [rbp-8h] BYREF
float v51; // [rsp+98h] [rbp+48h] BYREF
float v52; // [rsp+9Ch] [rbp+4Ch]
float v53; // [rsp+A8h] [rbp+58h] BYREF
float v54; // [rsp+ACh] [rbp+5Ch]
if ( a2 && cocos2d::CCArray::count(a2) >= 2 )
{
v6 = cocos2d::CCArray::count(a2);
v7 = cocos2d::CCArray::createWithCapacity(v6);
cocos2d::CCArray::addObjectsFromArray(v7, a2);
v8 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create();
if ( *(_BYTE *)(a1 + 915) && !*(_BYTE *)(a1 + 916) )
{
v9 = 0;
while ( v9 < cocos2d::CCArray::count(a2) )
{
v10 = cocos2d::CCArray::objectAtIndex(a2, v9);
if ( *((int *)v10 + 220) <= 0 )
{
++v9;
}
else
{
cocos2d::CCArray::removeObjectAtIndex(a2, v9, 1);
if ( !cocos2d::CCDictionary::objectForKey(v8, *((int *)v10 + 220)) )
{
v11 = *((int *)v10 + 220);
v12 = (struct cocos2d::CCObject *)cocos2d::CCNode::create();
cocos2d::CCDictionary::setObject(v8, v12, v11);
}
}
}
v13 = cocos2d::CCDictionary::allKeys(v8);
for ( i = 0; i < cocos2d::CCArray::count(v13); ++i )
{
v15 = *((_DWORD *)cocos2d::CCArray::objectAtIndex(v13, i) + 14);
v16 = cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(*(_QWORD *)(a1 + 1512) + 4256LL), v15);
if ( v16 )
{
LOBYTE(v18) = 1;
EditorUI::getGroupCenter(v17, v48, v16, v18);
v47 = operator new(0x550u);
v19 = (cocos2d::CCSprite *)GameObject::GameObject(v47);
v20 = v19;
if ( v19 )
{
*((_DWORD *)v19 + 7) = 13;
if ( cocos2d::CCSprite::initWithSpriteFrameName(v19, "checkpoint_01_001.png") )
{
GameObject::commonSetup(v20);
*((_BYTE *)v20 + 313) = 1;
cocos2d::CCObject::autorelease(v20);
}
else
{
(*(void (__fastcall **)(cocos2d::CCSprite *, __int64))(*(_QWORD *)v20 + 8LL))(v20, 1);
v20 = nullptr;
}
}
*((_DWORD *)v20 + 259) = 44;
*((_DWORD *)v20 + 220) = v15;
v21 = *(_QWORD *)v20;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v44, (const struct cocos2d::CCPoint *)v48);
(*(void (__fastcall **)(cocos2d::CCSprite *, __int64))(v21 + 1216))(v20, v22);
cocos2d::CCArray::addObject(a2, v20);
}
}
}
if ( cocos2d::CCArray::count(a2) >= 2 )
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v53);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v51);
v23 = 1;
v24 = *((unsigned int **)a2 + 7);
v25 = *v24;
if ( (_DWORD)v25 )
{
v26 = *((_QWORD **)v24 + 2);
for ( j = &v26[v25 - 1]; v26 <= j; ++v26 )
{
if ( !*v26 )
break;
v28 = (const struct cocos2d::CCPoint *)(*(__int64 (__fastcall **)(_QWORD))(*(_QWORD *)*v26 + 200LL))(*v26);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v44, v28);
if ( v23 )
{
v23 = 0;
cocos2d::CCPoint::operator=(&v53, &v44);
cocos2d::CCPoint::operator=(&v51, &v44);
}
else
{
if ( v53 > v44 )
v53 = v44;
if ( v44 > v51 )
v51 = v44;
if ( v54 > v45 )
v54 = v45;
if ( v45 > v52 )
v52 = v45;
}
}
}
if ( a3 )
v29 = v54 == v52;
else
v29 = v53 == v51;
if ( !v29 )
{
cocos2d::CCPoint::operator+(&v53, v48, &v51);
cocos2d::CCPoint::operator/(v30, v46);
EditorUI::createUndoObject(a1, v31, 0);
v32 = *((unsigned int **)a2 + 7);
v33 = *v32;
if ( (_DWORD)v33 )
{
v34 = *((int ***)v32 + 2);
for ( k = &v34[v33 - 1]; v34 <= k; ++v34 )
{
v36 = *v34;
if ( !*v34 )
break;
v37 = (const struct cocos2d::CCPoint *)(*(__int64 (__fastcall **)(int *))(*(_QWORD *)v36 + 200LL))(*v34);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v47, v37);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v44, (const struct cocos2d::CCPoint *)&v47);
if ( a3 )
v45 = *(float *)&v46[1];
else
v44 = *(float *)v46;
cocos2d::CCPoint::operator-(&v44, v48, &v47);
if ( v36[259] == 44 )
{
v38 = cocos2d::CCDictionary::objectForKey(
*(cocos2d::CCDictionary **)(*(_QWORD *)(a1 + 1512) + 4256LL),
v36[220]);
v39 = v38;
if ( v38 )
{
v40 = 0;
if ( cocos2d::CCArray::count(v38) )
{
do
{
v41 = cocos2d::CCArray::objectAtIndex(v39, v40);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v49, (const struct cocos2d::CCPoint *)v48);
EditorUI::moveObject(a1, (__int64)v41, v42);
++v40;
}
while ( v40 < cocos2d::CCArray::count(v39) );
}
}
}
else
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v50, (const struct cocos2d::CCPoint *)v48);
EditorUI::moveObject(a1, (__int64)v36, v43);
}
}
}
EditorUI::updateControlsAfterAlign(a1);
}
}
}
}