//
// GJBaseGameLayer::checkSpawnObjects from 0x10012c770 to 0x10012ca08 (664 bytes)
//
// 6 xrefs:
// > PlayLayer::setupHasCompleted @ 0x1000ae8f6
// > PlayLayer::resetLevel @ 0x1000bec36
// > LevelEditorLayer::onPlaytest @ 0x1000f2829
// > GJBaseGameLayer::loadUpToPosition @ 0x10014e945
// > GJBaseGameLayer::loadUpToPosition @ 0x10014e959
// > GJBaseGameLayer::update @ 0x1001524e6
//
// 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::checkSpawnObjects(GJBaseGameLayer *a1)
{
__m128 v1; // xmm0
GJBaseGameLayer *v2; // rbx
PlayerObject *m_player1; // rdi
float *p_m_spawnChannelRelated0; // r14
_QWORD *v5; // rax
cocos2d::CCDictionary *m_spawnObjects; // rdi
intptr_t m_currentChannel; // rsi
__int64 v8; // r13
unsigned int v9; // r15d
char v10; // r14
__int64 v11; // rax
SpawnTriggerGameObject *v12; // r13
std::unordered_map *p_m_spawnChannelRelated1; // [rsp+0h] [rbp-70h]
float *v14; // [rsp+8h] [rbp-68h]
GJBaseGameLayer *i; // [rsp+10h] [rbp-60h]
int v16; // [rsp+1Ch] [rbp-54h] BYREF
std::vector __p; // [rsp+20h] [rbp-50h] BYREF
float v18; // [rsp+38h] [rbp-38h] BYREF
float v19; // [rsp+3Ch] [rbp-34h]
float v20; // [rsp+40h] [rbp-30h] BYREF
float v21; // [rsp+44h] [rbp-2Ch]
v2 = a1;
m_player1 = a1->m_player1;
if ( m_player1->m_isPlatformer )
{
v1 = (__m128)*(unsigned __int64 *)&v2->m_gameState.m_levelTime;
v1.f32[0] = *(double *)v1.i64;
((void (__fastcall *)(float *, GJBaseGameLayer *, float))v2->posForTime)(&v18, v2, v1.f32[0]);
}
else
{
((void (__fastcall *)(PlayerObject *))m_player1->getPosition)(m_player1);
*(double *)v1.i64 = sub_10028CC60(&v18);
}
p_m_spawnChannelRelated0 = (float *)&v2->m_gameState.m_spawnChannelRelated0;
p_m_spawnChannelRelated1 = &v2->m_gameState.m_spawnChannelRelated1;
v14 = (float *)&v2->m_gameState.m_spawnChannelRelated0;
for ( i = v2; ; v2 = i )
{
m_spawnObjects = v2->m_spawnObjects;
m_currentChannel = v2->m_gameState.m_currentChannel;
v8 = (__int64)cocos2d::CCDictionary::objectForKey(m_spawnObjects, m_currentChannel);
if ( !v8 )
v8 = sub_10071F9E0(m_spawnObjects, m_currentChannel);
v16 = v2->m_gameState.m_currentChannel;
__p.__begin_ = &v16;
v9 = *((_DWORD *)sub_100055BA0(p_m_spawnChannelRelated0, &v16, v1, (__int64)&unk_100816AE0, &__p.__begin_) + 5);
__p.__begin_ = &v16;
v10 = *(_BYTE *)(sub_100167FF0(p_m_spawnChannelRelated1, &v16, &unk_100816AE0, &__p, &v20) + 20);
if ( (unsigned int)sub_100720070(v8) <= v9 )
break;
v11 = sub_1007200C0(v8, v9);
v12 = (SpawnTriggerGameObject *)v11;
if ( !*(_BYTE *)(v11 + 1472) )
{
if ( i->m_isPlatformer )
{
LABEL_12:
sub_10028CC60(&__p);
v1 = (__m128)LODWORD(v18);
if ( v18 < *(float *)&__p.__begin_ )
break;
}
else if ( i->m_player1->m_isSideways )
{
if ( v10 )
{
sub_10028CC60(&v20);
v1 = (__m128)LODWORD(v21);
if ( v21 < v19 )
break;
}
else
{
sub_10028CC60(&__p);
v1 = (__m128)LODWORD(v19);
if ( v19 < *((float *)&__p.__begin_ + 1) )
break;
}
}
else
{
if ( !v10 )
goto LABEL_12;
sub_10028CC60(&v20);
v1 = (__m128)LODWORD(v20);
if ( v20 < v18 )
break;
}
if ( !v12->m_isGroupDisabled )
{
if ( v12->m_objectID == 1268 )
{
v1 = 0;
memset(&__p, 0, sizeof(__p));
SpawnTriggerGameObject::updateRemapKeys(v12, &__p);
if ( __p.__begin_ )
{
__p.__end_ = __p.__begin_;
operator delete(__p.__begin_);
}
}
((void (__fastcall *)(SpawnTriggerGameObject *, GJBaseGameLayer *, _QWORD, _QWORD))v12->triggerObject)(
v12,
i,
0,
0);
}
goto LABEL_6;
}
if ( !*(_BYTE *)(v11 + 1443) )
break;
LABEL_6:
__p.__begin_ = &v16;
p_m_spawnChannelRelated0 = v14;
v5 = sub_100055BA0(v14, &v16, v1, (__int64)&unk_100816AE0, &__p.__begin_);
++*((_DWORD *)v5 + 5);
}
((void (__fastcall *)(GJBaseGameLayer *, float))i->applyTimeWarp)(i, i->m_gameState.m_timeWarp);
}