//
// GJBaseGameLayer::playerTouchedTrigger from 0x887514 to 0x8877e0 (716 bytes)
//
// 2 xrefs:
// > GJBaseGameLayer::collisionCheckObjects @ 0x88c1c0
// > ??> @ 0xa6fb0
//
// 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 GJBaseGameLayer::playerTouchedTrigger(GJBaseGameLayer *a1, PlayerObject *a2, EffectGameObject *a3)
{
int m_uniqueID; // w2
std::_rb_tree_base *p_m_header; // x25
std::_rb_tree_base *m_parent; // x0
int v9; // w1
std::_rb_tree_base *v10; // x5
int v11; // w2
int v12; // w4
std::_rb_tree_base *v13; // x24
int v14; // w0
__int64 insert_hint_unique_pos; // x0
__int64 v16; // x1
std::_rb_tree_base *v17; // x3
__int64 v18; // x2
int v19; // w3
_BOOL8 v20; // x0
int v21; // w1
std::_rb_tree_base *v22; // x0
__int64 v23; // [xsp+58h] [xbp+58h]
int v24[2]; // [xsp+68h] [xbp+68h] BYREF
std::vector p; // [xsp+70h] [xbp+70h] BYREF
if ( a3->m_objectID == 3640 )
a3->powerOnObject(a3, a1->m_gameState.m_commandIndex);
if ( a3->m_isTouchTriggered )
{
m_uniqueID = 0;
if ( !a3->m_isSinglePTouch )
m_uniqueID = a2->m_uniqueID;
p_m_header = &a1->m_gameState.m_activatedObjectIDs.m_header;
v24[0] = a3->m_uniqueID;
v24[1] = m_uniqueID;
if ( &a1->m_gameState.m_activatedObjectIDs.m_header == (std::_rb_tree_base *)std::_Rb_tree,std::pair const,int>,std::_Select1st const,int>>,std::less>,std::allocator const,int>>>::find(
(__int64)&a1->m_gameState.m_activatedObjectIDs,
v24) )
{
if ( a3->m_isMultiTriggered )
{
GJEffectManager::removeTriggeredID(a1->m_effectManager, v24[0], v24[1]);
LABEL_8:
m_parent = a1->m_gameState.m_activatedObjectIDs.m_header.m_parent;
if ( m_parent )
{
v9 = v24[0];
v10 = &a1->m_gameState.m_activatedObjectIDs.m_header;
v11 = v24[1];
do
{
while ( 1 )
{
v12 = *(_DWORD *)&m_parent[1].m_isblack;
if ( v12 < v24[0] || v12 <= v24[0] && *((_DWORD *)&m_parent[1].m_isblack + 1) < v24[1] )
break;
v10 = m_parent;
m_parent = m_parent->m_left;
if ( !m_parent )
goto LABEL_14;
}
m_parent = m_parent->m_right;
}
while ( m_parent );
LABEL_14:
v13 = v10;
if ( p_m_header != v10 )
{
v14 = *(_DWORD *)&v10[1].m_isblack;
if ( v14 <= v24[0] && (v14 < v24[0] || *((_DWORD *)&v10[1].m_isblack + 1) <= v24[1]) )
goto LABEL_24;
}
}
else
{
v13 = &a1->m_gameState.m_activatedObjectIDs.m_header;
}
v23 = (__int64)v13;
v13 = (std::_rb_tree_base *)operator new(0x30u);
*(_QWORD *)&v13[1].m_isblack = *(_QWORD *)v24;
LODWORD(v13[1].m_parent) = 0;
insert_hint_unique_pos = std::_Rb_tree,std::pair const,int>,std::_Select1st const,int>>,std::less>,std::allocator const,int>>>::_M_get_insert_hint_unique_pos(
&a1->m_gameState.m_activatedObjectIDs.compare.pad,
v23,
&v13[1].m_isblack);
v17 = (std::_rb_tree_base *)insert_hint_unique_pos;
v18 = v16;
if ( v16 )
{
if ( insert_hint_unique_pos || p_m_header == (std::_rb_tree_base *)v16 )
{
v20 = 1;
}
else
{
v19 = *(_DWORD *)&v13[1].m_isblack;
v20 = 1;
v21 = *(_DWORD *)(v16 + 32);
if ( v19 >= v21 )
{
v20 = 0;
if ( v19 <= v21 )
v20 = *((_DWORD *)&v13[1].m_isblack + 1) < *(_DWORD *)(v18 + 36);
}
}
sub_CFAD74(v20, v13, v18, &a1->m_gameState.m_activatedObjectIDs.m_header);
++a1->m_gameState.m_activatedObjectIDs.m_nodecount;
}
else
{
v22 = v13;
v13 = v17;
operator delete(v22);
}
v9 = v24[0];
v11 = v24[1];
LABEL_24:
LODWORD(v13[1].m_parent) = a1->m_gameState.m_commandIndex;
LABEL_27:
if ( !GJEffectManager::hasBeenTriggered(a1->m_effectManager, v9, v11) )
{
GJEffectManager::storeTriggeredID(a1->m_effectManager, v24[0], v24[1]);
if ( a3->m_objectID == 1268 )
{
memset(&p, 0, sizeof(p));
SpawnTriggerGameObject::updateRemapKeys((SpawnTriggerGameObject *)a3, &p);
if ( p.m_start )
operator delete(p.m_start);
}
a3->triggerObject(a3, a1, a2->m_uniqueID, nullptr);
}
a3->triggerActivated(a3, 0.0);
return;
}
}
else if ( a3->m_isMultiTriggered )
{
goto LABEL_8;
}
v9 = v24[0];
v11 = v24[1];
goto LABEL_27;
}
}