//
// GJBaseGameLayer::checkSpawnObjects from 0x14021a8f0 to 0x14021ab80 (656 bytes)
//
// 7 xrefs:
// > GJBaseGameLayer::loadUpToPosition @ 0x140235bfa
// > GJBaseGameLayer::loadUpToPosition @ 0x140235c10
// > GJBaseGameLayer::update @ 0x14023861f
// > LevelEditorLayer::onPlaytest @ 0x1402e0406
// > PlayLayer::setupHasCompleted @ 0x1403a7753
// > PlayLayer::resetLevel @ 0x1403b96fa
// > ??> @ 0x1406cd38c
//
// 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
//
// Hidden C++ exception states: #wind=1
void GJBaseGameLayer::checkSpawnObjects(GJBaseGameLayer *a1)
{
PlayerObject *m_player1; // rcx
__int64 v3; // rcx
cocos2d::CCArray *v4; // rbx
unsigned int v5; // r14d
char v6; // si
struct cocos2d::CCObject *v7; // rax
SpawnTriggerGameObject *v8; // rbx
char v9; // r14
std::_Vector_val>::pointer Myfirst; // rcx
__int64 v11; // rax
cocos2d::CCPoint v12; // [rsp+20h] [rbp-49h] BYREF
cocos2d::CCPoint v13; // [rsp+28h] [rbp-41h] BYREF
cocos2d::CCPoint v14; // [rsp+30h] [rbp-39h] BYREF
_BYTE v15[16]; // [rsp+38h] [rbp-31h] BYREF
_BYTE v16[16]; // [rsp+48h] [rbp-21h] BYREF
_BYTE v17[16]; // [rsp+58h] [rbp-11h] BYREF
std::vector v18[3]; // [rsp+68h] [rbp-1h] BYREF
int m_currentChannel; // [rsp+D0h] [rbp+67h] BYREF
cocos2d::CCPoint v20; // [rsp+D8h] [rbp+6Fh] BYREF
cocos2d::CCPoint v21; // [rsp+E0h] [rbp+77h] BYREF
cocos2d::CCPoint v22; // [rsp+E8h] [rbp+7Fh] BYREF
m_player1 = a1->m_player1;
if ( m_player1->m_isPlatformer )
{
((void (__fastcall *)(GJBaseGameLayer *, int *))a1->posForTime)(a1, &m_currentChannel);
}
else
{
m_player1->getPosition_0(m_player1);
cocos2d::CCPoint::CCPoint(&v21);
}
cocos2d::CCPoint::CCPoint(&v20);
while ( 1 )
{
v4 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(a1->m_spawnObjects, a1->m_gameState.m_currentChannel);
if ( !v4 )
v4 = (cocos2d::CCArray *)cocos2d::CCArray::create(v3);
m_currentChannel = a1->m_gameState.m_currentChannel;
v5 = *(_DWORD *)(*(_QWORD *)sub_140060B20(
&a1->m_gameState.m_spawnChannelRelated0._Traitsobj._Mypair._Myval2._Myval2,
(__int64)v15,
(unsigned __int8 *)&m_currentChannel)
+ 20LL);
v6 = *(_BYTE *)(*(_QWORD *)sub_140250920(&a1->m_gameState.m_spawnChannelRelated1, v16) + 20LL);
if ( cocos2d::CCArray::count(v4) <= v5 )
break;
v7 = cocos2d::CCArray::objectAtIndex(v4, v5);
v8 = (SpawnTriggerGameObject *)v7;
v9 = 0;
if ( LOBYTE(v7[26].m_uIndexInArray) )
{
if ( !BYTE3(v7[26].__vftable) )
break;
v9 = 1;
}
else if ( a1->m_isPlatformer )
{
cocos2d::CCPoint::CCPoint(&v21);
if ( v20.x < v21.x )
break;
}
else if ( a1->m_player1->m_isSideways )
{
if ( v6 )
{
cocos2d::CCPoint::CCPoint(&v12);
if ( v12.y < v20.y )
break;
}
else
{
cocos2d::CCPoint::CCPoint(&v22);
if ( v20.y < v22.y )
break;
}
}
else if ( v6 )
{
cocos2d::CCPoint::CCPoint(&v14);
if ( v14.x < v20.x )
break;
}
else
{
cocos2d::CCPoint::CCPoint(&v13);
if ( v20.x < v13.x )
break;
}
if ( !v8->m_isGroupDisabled && !v9 )
{
if ( v8->m_objectID == 1268 )
{
memset(v18, 0, 24);
SpawnTriggerGameObject::updateRemapKeys(v8, v18);
Myfirst = v18[0]._Mypair._Myval2._Myfirst;
if ( v18[0]._Mypair._Myval2._Myfirst )
{
if ( (((char *)v18[0]._Mypair._Myval2._Myend - (char *)v18[0]._Mypair._Myval2._Myfirst) & 0xFFFFFFFFFFFFFFFCuLL) >= 0x1000 )
{
Myfirst = *((std::_Vector_val>::pointer *)v18[0]._Mypair._Myval2._Myfirst - 1);
if ( (unsigned __int64)((char *)v18[0]._Mypair._Myval2._Myfirst - (char *)Myfirst - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(Myfirst);
}
}
v8->triggerObject(v8, a1, 0, nullptr);
}
v11 = sub_140060B20(
&a1->m_gameState.m_spawnChannelRelated0._Traitsobj._Mypair._Myval2._Myval2,
(__int64)v17,
(unsigned __int8 *)&m_currentChannel);
++*(_DWORD *)(*(_QWORD *)v11 + 20LL);
}
((void (__fastcall *)(GJBaseGameLayer *))a1->applyTimeWarp)(a1);
}