//
// GJBaseGameLayer::spawnGroup from 0x10012caa0 to 0x10012cdb5 (789 bytes)
//
// 4 xrefs:
// > sub_10012CF00 @ 0x10012cf0c
// > ??> @ 0x1008b7320
// > ??> @ 0x1008c0670
// > ??> @ 0x1008c18a0
//
// 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::spawnGroup(
GJBaseGameLayer *a1,
int a2,
bool a3,
double a4,
std::vector *const a5,
int a6,
int a7)
{
GJEffectManager *m_effectManager; // rdi
int *end; // rax
__int64 v12; // r12
unsigned __int64 v13; // rsi
std::__tree_end_node *>::pointer left; // rax
std::__tree_end_node *>::pointer v15; // rcx
int v16; // edx
int v17; // edx
std::__compressed_pair *>> *p_pair1; // r13
std::__compressed_pair *>> *v19; // rbx
int v20; // eax
int left_high; // eax
char *v22; // rax
std::__tree_end_node *> *v23; // rcx
int v24; // eax
intptr_t v25; // r12
cocos2d::CCArray *v26; // r15
cocos2d::ccArray *v27; // rax
GameObject **v28; // r12
unsigned __int64 v29; // r13
char v30; // bl
GameObject *v31; // r15
float v32; // xmm0_4
float v33; // xmm0_4
cocos2d::ccArray *data; // rax
cocos2d::CCObject **arr; // rbx
unsigned __int64 v36; // r15
bool v41; // [rsp+24h] [rbp-2Ch]
float v42; // [rsp+24h] [rbp-2Ch]
m_effectManager = a1->m_effectManager;
if ( !GJEffectManager::isGroupEnabled(m_effectManager, a2) )
return;
end = a5->__end_;
v12 = 0;
v13 = 0;
if ( a5->__begin_ != end )
v13 = (unsigned int)-*(end - 1);
if ( a1->m_enable22Changes )
v12 = (unsigned int)a6;
left = a1->m_spawnTuples.__tree_.__pair1_.__value_.__left_;
v41 = a3;
if ( !left )
{
p_pair1 = &a1->m_spawnTuples.__tree_.__pair1_;
v19 = &a1->m_spawnTuples.__tree_.__pair1_;
goto LABEL_28;
}
v15 = a1->m_spawnTuples.__tree_.__pair1_.__value_.__left_;
do
{
if ( *((_DWORD *)v15 + 7) <= a2 )
{
if ( *((_DWORD *)v15 + 7) < a2 )
goto LABEL_8;
v16 = *((_DWORD *)v15 + 8);
if ( (int)v12 >= v16 )
{
if ( (int)v12 > v16 )
goto LABEL_8;
v17 = *((_DWORD *)v15 + 9);
if ( (int)v13 >= v17 )
{
if ( (int)v13 <= v17 )
return;
LABEL_8:
v15 = (std::__tree_end_node *>::pointer)((char *)v15 + 8);
}
}
}
v15 = *(std::__tree_end_node *>::pointer *)v15;
}
while ( v15 );
do
{
while ( 1 )
{
v19 = (std::__compressed_pair *>> *)left;
if ( *((_DWORD *)left + 7) <= a2 )
break;
LABEL_17:
left = v19->__value_.__left_;
p_pair1 = v19;
if ( !v19->__value_.__left_ )
goto LABEL_28;
}
if ( *((_DWORD *)left + 7) >= a2 )
{
v20 = *((_DWORD *)left + 8);
if ( (int)v12 < v20 )
goto LABEL_17;
if ( (int)v12 <= v20 )
{
left_high = HIDWORD(v19[4].__value_.__left_);
if ( (int)v13 < left_high )
goto LABEL_17;
if ( (int)v13 <= left_high )
goto LABEL_31;
}
}
left = v19[1].__value_.__left_;
}
while ( left );
p_pair1 = v19 + 1;
LABEL_28:
v22 = (char *)operator new(0x28u);
*(_QWORD *)(v22 + 28) = (v12 << 32) | (unsigned int)a2;
*((_DWORD *)v22 + 9) = v13;
*(_OWORD *)v22 = 0;
*((_QWORD *)v22 + 2) = v19;
p_pair1->__value_.__left_ = (std::__tree_end_node *>::pointer)v22;
v23 = (std::__tree_end_node *> *)a1->m_spawnTuples.__tree_.__begin_node_->__left_;
if ( v23 )
a1->m_spawnTuples.__tree_.__begin_node_ = v23;
m_effectManager = (GJEffectManager *)a1->m_spawnTuples.__tree_.__pair1_.__value_.__left_;
v13 = (unsigned __int64)v22;
sub_100054DD0((__int64 *)m_effectManager, (__int64 *)v22);
++a1->m_spawnTuples.__tree_.__pair3_.__value_;
LABEL_31:
v24 = 9999;
if ( a2 < 9999 )
v24 = a2;
v25 = 0;
if ( v24 > 0 )
v25 = (unsigned int)v24;
v26 = a1->m_groups.__begin_[v25];
if ( !v26 )
{
v26 = (cocos2d::CCArray *)sub_10071F9E0(m_effectManager, v13);
cocos2d::CCDictionary::setObject(a1->m_groupDict, v26, v25);
a1->m_groups.__begin_[v25] = v26;
if ( v41 )
goto LABEL_37;
goto LABEL_54;
}
if ( !v41 )
{
LABEL_54:
if ( v26 )
{
data = v26->data;
if ( data->num )
{
arr = data->arr;
v36 = (unsigned __int64)&arr[data->num - 1];
do
{
if ( !*arr )
break;
((void (__fastcall *)(GJBaseGameLayer *, _QWORD, std::vector *const, double))a1->spawnObject)(
a1,
*arr++,
a5,
a4);
}
while ( (unsigned __int64)arr <= v36 );
}
}
return;
}
LABEL_37:
if ( v26 )
{
v27 = v26->data;
if ( v27->num )
{
v28 = (GameObject **)v27->arr;
v29 = (unsigned __int64)&v28[v27->num - 1];
v30 = 0;
v42 = 0.0;
do
{
v31 = *v28;
if ( !*v28 )
return;
if ( v31->m_classType == Effect )
{
if ( !GameObject::isSpawnableTrigger(*v28) )
goto LABEL_43;
}
else if ( v31->m_objectID != 2065 || BYTE1(v31[1].m_fScaleX) != 1 )
{
goto LABEL_43;
}
v32 = *(float *)((__int64 (__fastcall *)(GameObject *))v31->getPosition)(v31);
if ( (v30 & 1) != 0 )
{
v33 = (float)(v32 - v42) / 311.5801086425781 - a4;
if ( v33 > 0.0 )
{
GJEffectManager::spawnObject(a1->m_effectManager, v31, v33, a5, a6, a7);
goto LABEL_42;
}
}
else
{
v42 = v32;
}
((void (__fastcall *)(GJBaseGameLayer *, GameObject *, std::vector *const, double))a1->spawnObject)(
a1,
v31,
a5,
0.0);
LABEL_42:
v30 = 1;
LABEL_43:
++v28;
}
while ( (unsigned __int64)v28 <= v29 );
}
}
}