//
// GJBaseGameLayer::canBeActivatedByPlayer from 0x100127ce0 to 0x100127f3f (607 bytes)
//
// 20 xrefs:
// > GJBaseGameLayer::collisionCheckObjects @ 0x1001270bb
// > GJBaseGameLayer::collisionCheckObjects @ 0x10012717d
// > GJBaseGameLayer::collisionCheckObjects @ 0x1001271c3
// > GJBaseGameLayer::collisionCheckObjects @ 0x1001271fd
// > GJBaseGameLayer::collisionCheckObjects @ 0x1001272ae
// > GJBaseGameLayer::collisionCheckObjects @ 0x10012732b
// > GJBaseGameLayer::collisionCheckObjects @ 0x1001273d5
// > GJBaseGameLayer::collisionCheckObjects @ 0x10012741b
// > GJBaseGameLayer::collisionCheckObjects @ 0x1001274a2
// > GJBaseGameLayer::collisionCheckObjects @ 0x100127552
// > GJBaseGameLayer::collisionCheckObjects @ 0x1001275e0
// > GJBaseGameLayer::collisionCheckObjects @ 0x100127617
// > GJBaseGameLayer::collisionCheckObjects @ 0x1001276a1
// > GJBaseGameLayer::collisionCheckObjects @ 0x100127759
// > GJBaseGameLayer::collisionCheckObjects @ 0x100127790
// > GJBaseGameLayer::collisionCheckObjects @ 0x10012785b
// > GJBaseGameLayer::collisionCheckObjects @ 0x1001278f7
// > GJBaseGameLayer::collisionCheckObjects @ 0x100127933
// > GJBaseGameLayer::bumpPlayer @ 0x10012814a
// > GJBaseGameLayer::gravBumpPlayer @ 0x10012842b
//
// 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
//
bool __fastcall GJBaseGameLayer::canBeActivatedByPlayer(GJBaseGameLayer *a1, PlayerObject *a2, EffectGameObject *a3)
{
EffectGameObject *v3; // r15
char v4; // al
std::__tree_end_node *>::pointer left; // rcx
__int64 v6; // r13
__int64 m_uniqueID; // r14
std::__tree_end_node *>::pointer v8; // rax
int v9; // edx
int v10; // edx
__int64 v11; // r15
unsigned int v12; // edx
_QWORD *v13; // r12
int v14; // eax
int v15; // eax
unsigned int m_commandIndex; // edx
char *p_pair1; // r12
int v18; // eax
int v19; // eax
std::__compressed_pair *>> *v20; // r15
char *v21; // rbx
std::__tree_end_node *> *v22; // rax
char *v24; // r14
std::__tree_end_node *> *v25; // rax
unsigned int v26; // [rsp+10h] [rbp-40h]
EffectGameObject *v27; // [rsp+18h] [rbp-38h]
_QWORD *v28; // [rsp+18h] [rbp-38h]
unsigned int v29; // [rsp+24h] [rbp-2Ch]
v3 = a3;
v4 = ((__int64 (__fastcall *)(EffectGameObject *, bool))a3->canMultiActivate)(a3, a2->m_isPlatformer);
left = a1->m_gameState.m_activatedObjectIDs.__tree_.__pair1_.__value_.__left_;
v27 = v3;
if ( !v4 )
{
LODWORD(v6) = v3->m_uniqueID;
m_uniqueID = (unsigned int)a2->m_uniqueID;
LABEL_19:
m_commandIndex = a1->m_gameState.m_commandIndex;
v29 = m_commandIndex;
if ( !left )
{
LABEL_30:
p_pair1 = (char *)&a1->m_gameState.m_activatedObjectIDs.__tree_.__pair1_;
v20 = &a1->m_gameState.m_activatedObjectIDs.__tree_.__pair1_;
goto LABEL_31;
}
while ( 1 )
{
p_pair1 = (char *)left;
v18 = *((_DWORD *)left + 7);
if ( (int)v6 < v18 )
goto LABEL_21;
if ( (int)v6 > v18 )
{
LABEL_26:
left = *((std::__tree_end_node *>::pointer *)left + 1);
if ( !left )
{
v20 = (std::__compressed_pair *>> *)(p_pair1 + 8);
LABEL_31:
v21 = p_pair1;
p_pair1 = (char *)operator new(0x28u);
*(_QWORD *)(p_pair1 + 28) = (m_uniqueID << 32) | (unsigned int)v6;
*((_DWORD *)p_pair1 + 9) = 0;
*(_OWORD *)p_pair1 = 0;
*((_QWORD *)p_pair1 + 2) = v21;
v20->__value_.__left_ = (std::__tree_end_node *>::pointer)p_pair1;
v22 = (std::__tree_end_node *> *)a1->m_gameState.m_activatedObjectIDs.__tree_.__begin_node_->__left_;
if ( v22 )
a1->m_gameState.m_activatedObjectIDs.__tree_.__begin_node_ = v22;
sub_100054DD0(
(__int64 *)a1->m_gameState.m_activatedObjectIDs.__tree_.__pair1_.__value_.__left_,
(__int64 *)p_pair1);
++a1->m_gameState.m_activatedObjectIDs.__tree_.__pair3_.__value_;
v3 = v27;
m_commandIndex = v29;
LABEL_34:
*((_DWORD *)p_pair1 + 9) = m_commandIndex;
return ((__int64 (__fastcall *)(EffectGameObject *, PlayerObject *))v3->hasBeenActivatedByPlayer)(v3, a2) ^ 1;
}
}
else
{
v19 = *((_DWORD *)left + 8);
if ( (int)m_uniqueID >= v19 )
{
if ( (int)m_uniqueID <= v19 )
goto LABEL_34;
goto LABEL_26;
}
LABEL_21:
left = *(std::__tree_end_node *>::pointer *)left;
if ( !*(_QWORD *)p_pair1 )
{
v20 = (std::__compressed_pair *>> *)p_pair1;
goto LABEL_31;
}
}
}
}
v6 = (unsigned int)v3->m_uniqueID;
m_uniqueID = (unsigned int)a2->m_uniqueID;
if ( !left )
{
v29 = a1->m_gameState.m_commandIndex;
goto LABEL_30;
}
v8 = a1->m_gameState.m_activatedObjectIDs.__tree_.__pair1_.__value_.__left_;
while ( 1 )
{
v9 = *((_DWORD *)v8 + 7);
if ( (int)v6 < v9 )
goto LABEL_5;
if ( (int)v6 <= v9 )
{
v10 = *((_DWORD *)v8 + 8);
if ( (int)m_uniqueID < v10 )
goto LABEL_5;
if ( (int)m_uniqueID <= v10 )
break;
}
v8 = (std::__tree_end_node *>::pointer)((char *)v8 + 8);
LABEL_5:
v8 = *(std::__tree_end_node *>::pointer *)v8;
if ( !v8 )
goto LABEL_19;
}
v11 = m_uniqueID << 32;
v12 = a1->m_gameState.m_commandIndex;
do
{
while ( 1 )
{
v13 = left;
v14 = *((_DWORD *)left + 7);
if ( (int)v6 < v14 )
goto LABEL_11;
if ( (int)v6 <= v14 )
break;
LABEL_16:
left = *((std::__tree_end_node *>::pointer *)left + 1);
if ( !left )
{
v26 = a1->m_gameState.m_commandIndex;
v28 = v13 + 1;
goto LABEL_36;
}
}
v15 = *((_DWORD *)left + 8);
if ( (int)m_uniqueID >= v15 )
{
if ( (int)m_uniqueID <= v15 )
{
v24 = (char *)left;
goto LABEL_39;
}
goto LABEL_16;
}
LABEL_11:
left = *(std::__tree_end_node *>::pointer *)left;
}
while ( *v13 );
v26 = a1->m_gameState.m_commandIndex;
v28 = v13;
LABEL_36:
v24 = (char *)operator new(0x28u);
*(_QWORD *)(v24 + 28) = v6 | v11;
*((_DWORD *)v24 + 9) = 0;
*(_OWORD *)v24 = 0;
*((_QWORD *)v24 + 2) = v13;
*v28 = v24;
v25 = (std::__tree_end_node *> *)a1->m_gameState.m_activatedObjectIDs.__tree_.__begin_node_->__left_;
if ( v25 )
a1->m_gameState.m_activatedObjectIDs.__tree_.__begin_node_ = v25;
sub_100054DD0((__int64 *)a1->m_gameState.m_activatedObjectIDs.__tree_.__pair1_.__value_.__left_, (__int64 *)v24);
++a1->m_gameState.m_activatedObjectIDs.__tree_.__pair3_.__value_;
v12 = v26;
LABEL_39:
*((_DWORD *)v24 + 9) = v12;
return 0;
}