//
// GJBaseGameLayer::processFollowActions from 0x100146b00 to 0x100146f8e (1166 bytes)
//
// 2 xrefs:
// > GJBaseGameLayer::processMoveActionsStep @ 0x100144689
// > GJBaseGameLayer::update @ 0x1001522e6
//
// 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 GJBaseGameLayer::processFollowActions(GJBaseGameLayer *a1)
{
cocos2d::CCArray *v1; // rsi
GJEffectManager *m_effectManager; // rax
_QWORD *begin; // r15
__int64 v5; // r14
__int64 v6; // rdi
int v7; // eax
intptr_t v8; // r12
intptr_t v9; // r12
cocos2d::CCDictionary *m_parentGroupsDict; // rdi
cocos2d::CCObject *v11; // rax
unsigned int m_commandIndex; // ecx
cocos2d::CCObject *v13; // r12
__m128d v14; // xmm2
__m128d v15; // xmm1
char v16; // r13
__m128d *v17; // rax
GJEffectManager *v18; // r12
int v19; // eax
cocos2d::ccArray *data; // rax
cocos2d::CCObject **arr; // r13
cocos2d::CCObject *v22; // r12
unsigned int v23; // eax
cocos2d::CCObject *v24; // r12
unsigned int v25; // eax
cocos2d::CCArray *v26; // r13
GJEffectManager *v27; // r12
unsigned int v28; // eax
std::__vector_base::pointer i; // [rsp+18h] [rbp-48h]
unsigned __int64 v30; // [rsp+20h] [rbp-40h]
cocos2d::CCArray *v31; // [rsp+30h] [rbp-30h]
m_effectManager = a1->m_effectManager;
begin = m_effectManager->m_unkVector6d8.__begin_;
for ( i = m_effectManager->m_unkVector6d8.__end_; begin != i; ++begin )
{
v5 = *begin;
v6 = *begin;
v7 = (*(__int64 (__fastcall **)(_QWORD))(*(_QWORD *)*begin + 64LL))(*begin);
v8 = (unsigned int)v7;
if ( v7 >= 9999 )
v8 = 9999;
if ( (int)v8 <= 0 )
v8 = 0;
v31 = a1->m_groups.__begin_[v8];
if ( v31 )
{
v9 = *(int *)(v5 + 116);
if ( v9 > 0 )
goto LABEL_13;
}
else
{
v1 = (cocos2d::CCArray *)sub_10071F9E0(v6, v1);
cocos2d::CCDictionary::setObject(a1->m_groupDict, v1, v8);
v31 = v1;
a1->m_groups.__begin_[v8] = v1;
v9 = *(int *)(v5 + 116);
if ( v9 > 0 )
{
LABEL_13:
m_parentGroupsDict = a1->m_parentGroupsDict;
v1 = (cocos2d::CCArray *)v9;
v11 = cocos2d::CCDictionary::objectForKey(m_parentGroupsDict, v9);
if ( v11 )
goto LABEL_14;
if ( (unsigned int)v9 >= 0x270F )
v9 = 9999;
v26 = a1->m_groups.__begin_[v9];
if ( v26
|| (v26 = (cocos2d::CCArray *)sub_10071F9E0(m_parentGroupsDict, v1),
v1 = v26,
cocos2d::CCDictionary::setObject(a1->m_groupDict, v26, v9),
(a1->m_groups.__begin_[v9] = v26) != nullptr) )
{
if ( (unsigned int)sub_100720070(v26) == 1 )
{
v1 = nullptr;
v11 = (cocos2d::CCObject *)sub_1007200C0(v26, 0);
if ( v11 )
{
LABEL_14:
m_commandIndex = a1->m_gameState.m_commandIndex;
if ( HIDWORD(v11[22].__vftable) != m_commandIndex )
{
*(_QWORD *)&v11[21].m_uOrderOfArrival = *(_QWORD *)&v11[16].m_uOrderOfArrival;
HIDWORD(v11[22].__vftable) = m_commandIndex;
v13 = v11;
GameObject::dirtifyObjectRect((GameObject *)v11);
v11 = v13;
}
v14 = (__m128d)*(unsigned __int64 *)&v11[16].m_uOrderOfArrival;
v14.f64[0] = (v14.f64[0] - *(float *)&v11[21].m_uOrderOfArrival) * *(double *)(v5 + 128);
*(double *)(v5 + 56) = v14.f64[0];
v15 = (__m128d)(unsigned __int64)v11[17].__vftable;
v15.f64[0] = (v15.f64[0] - *(float *)&v11[21].m_unknown5) * *(double *)(v5 + 136);
*(double *)(v5 + 64) = v15.f64[0];
v16 = _mm_cvtsi128_si32((__m128i)_mm_or_pd(
_mm_cmpneq_pd(v15, (__m128d)0LL),
_mm_cmpneq_pd(v14, (__m128d)0LL)));
if ( (v16 & 1) != 0
|| *(_BYTE *)(v5 + 120)
|| BYTE3(v11[23].__vftable) == 1
&& (v27 = a1->m_effectManager,
v28 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v5 + 64LL))(v5),
v1 = (cocos2d::CCArray *)v28,
GJEffectManager::wasFollowing(v27, v28, *(_DWORD *)(v5 + 116))) )
{
v17 = *(__m128d **)(v5 + 200);
if ( v17 )
v17[3] = _mm_add_pd(v17[3], *(__m128d *)(v5 + 56));
v18 = a1->m_effectManager;
v19 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v5 + 64LL))(v5);
GJEffectManager::setFollowing(v18, v19, *(_DWORD *)(v5 + 116), v16 & 1);
a1->m_followedCount += sub_100720070(v31);
if ( v31 )
{
data = v31->data;
if ( data->num )
{
arr = data->arr;
v30 = (unsigned __int64)&arr[data->num - 1];
if ( v14.f64[0] == 0.0 )
{
do
{
v24 = *arr;
if ( !*arr )
break;
if ( !BYTE2(v24[23].__vftable) )
{
v25 = a1->m_gameState.m_commandIndex;
if ( HIDWORD(v24[22].__vftable) != v25 )
{
*(_QWORD *)&v24[21].m_uOrderOfArrival = *(_QWORD *)&v24[16].m_uOrderOfArrival;
HIDWORD(v24[22].__vftable) = v25;
GameObject::dirtifyObjectRect((GameObject *)v24);
}
}
if ( v15.f64[0] != 0.0 )
*(double *)&v24[17].__vftable = *(double *)(v5 + 64) + *(double *)&v24[17].__vftable;
GameObject::dirtifyObjectPos((GameObject *)v24);
((void (__fastcall *)(GJBaseGameLayer *, cocos2d::CCObject *))a1->updateObjectSection)(a1, v24);
++arr;
}
while ( (unsigned __int64)arr <= v30 );
}
else
{
do
{
v22 = *arr;
if ( !*arr )
break;
if ( !BYTE2(v22[23].__vftable) )
{
v23 = a1->m_gameState.m_commandIndex;
if ( HIDWORD(v22[22].__vftable) != v23 )
{
*(_QWORD *)&v22[21].m_uOrderOfArrival = *(_QWORD *)&v22[16].m_uOrderOfArrival;
HIDWORD(v22[22].__vftable) = v23;
GameObject::dirtifyObjectRect((GameObject *)v22);
}
}
if ( v15.f64[0] != 0.0 )
*(double *)&v22[17].__vftable = *(double *)(v5 + 64) + *(double *)&v22[17].__vftable;
GameObject::dirtifyObjectPos((GameObject *)v22);
if ( !LOBYTE(v22[12].m_uUnknown) )
*(double *)&v22[16].m_uOrderOfArrival = *(double *)(v5 + 56)
+ *(double *)&v22[16].m_uOrderOfArrival;
((void (__fastcall *)(GJBaseGameLayer *, cocos2d::CCObject *))a1->updateObjectSection)(a1, v22);
++arr;
}
while ( (unsigned __int64)arr <= v30 );
}
}
}
v1 = v31;
((void (__fastcall *)(GJBaseGameLayer *, cocos2d::CCArray *))a1->updateDisabledObjectsLastPos)(a1, v31);
}
}
}
}
}
}
}
}