//
// GJBaseGameLayer::activateEventTrigger from 0x140232110 to 0x140232380 (624 bytes)
//
// 4 xrefs:
// > EventLinkTrigger::triggerObject @ 0x1404b88fa
// > ??> @ 0x140681050
// > ??> @ 0x140681060
// > ??> @ 0x1406cdf20
//
// 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::activateEventTrigger(GJBaseGameLayer *a1, EventLinkTrigger *a2, std::vector *const a3)
{
std::vector *v3; // rbp
__int64 *j; // rdi
int v6; // r12d
std::map,std::vector> *p_m_unkMapPairGJGameEventIntVectorEventTriggerInstance; // rcx
bool v8; // zf
GJGameEvent v9; // edx
std::_Tree_val, std::vector>>>::_Nodeptr Myhead; // r8
std::_Tree_node, std::vector>, void *>::_Nodeptr Parent; // rax
__int64 v12; // r15
_DWORD *v13; // rbx
_DWORD *v14; // rbp
_DWORD *v15; // r14
_DWORD *v16; // rcx
_DWORD *v17; // rsi
__int64 **v18; // rax
__int64 *i; // rax
__int64 v20; // rax
__int64 v21; // rbx
__int64 v22; // r10
int m_uniqueID; // edx
int m_controlID; // r8d
__int64 *v25; // rcx
GJGameEvent v26; // [rsp+78h] [rbp+10h] BYREF
int v27; // [rsp+7Ch] [rbp+14h]
std::vector *v28; // [rsp+80h] [rbp+18h]
std::map,std::vector> *v29; // [rsp+88h] [rbp+20h]
v28 = a3;
v3 = a3;
j = *(__int64 **)a2->m_eventIDs._Mypair._Myval2._Myval2._Myhead;
v6 = a2->m_extraID2 + 10000 * a2->m_extraID;
if ( !*((_BYTE *)j + 25) )
{
p_m_unkMapPairGJGameEventIntVectorEventTriggerInstance = &a1->m_gameState.m_unkMapPairGJGameEventIntVectorEventTriggerInstance;
v29 = p_m_unkMapPairGJGameEventIntVectorEventTriggerInstance;
do
{
v8 = !a2->m_resetRemap;
v9 = *((_DWORD *)j + 7);
v26 = v9;
v27 = v6;
if ( v8 )
{
v20 = sub_14024A5E0(p_m_unkMapPairGJGameEventIntVectorEventTriggerInstance, &v26);
v21 = v20;
v22 = *(_QWORD *)(v20 + 8);
if ( v22 == *(_QWORD *)(v20 + 16) )
{
sub_1402526C0(v20, v22, (_DWORD)a2 + 1480, (_DWORD)v3, (__int64)&a2->m_uniqueID, (__int64)&a2->m_controlID);
}
else
{
m_uniqueID = a2->m_uniqueID;
m_controlID = a2->m_controlID;
*(_DWORD *)v22 = a2->m_targetGroupID;
*(_DWORD *)(v22 + 4) = m_uniqueID;
*(_DWORD *)(v22 + 8) = m_controlID;
*(_BYTE *)(v22 + 12) = 0;
sub_14024B270(v22 + 16, v3);
*(_QWORD *)(v21 + 8) += 40LL;
}
}
else
{
Myhead = p_m_unkMapPairGJGameEventIntVectorEventTriggerInstance->_Mypair._Myval2._Myval2._Myhead;
Parent = p_m_unkMapPairGJGameEventIntVectorEventTriggerInstance->_Mypair._Myval2._Myval2._Myhead->_Parent;
if ( !Parent->_Isnil )
{
do
{
if ( Parent->_Myval.first.first < v9 || Parent->_Myval.first.first <= v9 && Parent->_Myval.first.second < v6 )
{
Parent = Parent->_Right;
}
else
{
Myhead = Parent;
Parent = Parent->_Left;
}
}
while ( !Parent->_Isnil );
p_m_unkMapPairGJGameEventIntVectorEventTriggerInstance = v29;
}
if ( !Myhead->_Isnil
&& v9 >= Myhead->_Myval.first.first
&& (v9 > Myhead->_Myval.first.first || v6 >= Myhead->_Myval.first.second) )
{
v12 = sub_14024A5E0(p_m_unkMapPairGJGameEventIntVectorEventTriggerInstance, &v26);
v13 = *(_DWORD **)v12;
v14 = *(_DWORD **)(v12 + 8);
if ( *(_DWORD **)v12 != v14 )
{
do
{
v15 = v13 + 10;
if ( *v13 == a2->m_targetGroupID )
{
if ( v15 != v14 )
{
v16 = v13 + 2;
do
{
v17 = v16 + 10;
*(v16 - 2) = *v15;
*(v16 - 1) = v16[9];
*v16 = v16[10];
*((_BYTE *)v16 + 4) = *((_BYTE *)v16 + 44);
sub_14024B1D0(v16 + 2, v16 + 12);
v15 += 10;
v16 = v17;
}
while ( v15 != v14 );
}
sub_14005E430(*(_QWORD *)(v12 + 8) - 24LL);
*(_QWORD *)(v12 + 8) -= 40LL;
v14 = *(_DWORD **)(v12 + 8);
}
else
{
v13 += 10;
}
}
while ( v13 != v14 );
}
v3 = v28;
}
}
v18 = (__int64 **)j[2];
if ( *((_BYTE *)v18 + 25) )
{
for ( i = (__int64 *)j[1]; !*((_BYTE *)i + 25); i = (__int64 *)i[1] )
{
if ( j != (__int64 *)i[2] )
break;
j = i;
}
j = i;
}
else
{
v25 = *v18;
for ( j = (__int64 *)j[2]; !*((_BYTE *)v25 + 25); v25 = (__int64 *)*v25 )
j = v25;
}
p_m_unkMapPairGJGameEventIntVectorEventTriggerInstance = v29;
}
while ( !*((_BYTE *)j + 25) );
}
}