//
// GJBaseGameLayer::controlTriggersWithControlID from 0x14021e720 to 0x14021ea38 (792 bytes)
//
// 2 xrefs:
// > TriggerControlGameObject::triggerObject @ 0x1404c333a
// > ??> @ 0x1406cd404
//
// 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::controlTriggersWithControlID(GJBaseGameLayer *a1, int a2, GJActionCommand a3)
{
std::_Vector_val>::pointer Mylast; // rdx
std::_Vector_val>::pointer i; // rax
std::_Vector_val>::pointer v8; // rcx
std::_Vector_val>::pointer j; // rax
std::_Vector_val>::pointer v10; // rcx
std::_Vector_val>::pointer k; // rax
std::_List_val>>>::_Nodeptr Myhead; // r10
_QWORD *m; // rax
__int64 v14; // r9
__int64 n; // rcx
GradientTriggerObject **v16; // r14
cocos2d::CCDictionary **p_m_gradientLayers; // r15
cocos2d::CCDictionary *m_gradientLayers; // rax
GradientTriggerObject **v19; // rdi
cocos2d::CCDictElement *m_pElements; // rax
cocos2d::CCDictElement *ii; // rbp
unsigned int *p_m_uAutoReleaseCount; // r8
GradientTriggerObject *v23; // rax
char *v24; // rbp
GradientTriggerObject **v25; // rsi
int m_gradientID; // ecx
struct cocos2d::CCObject *v27; // rax
struct cocos2d::CCObject *v28; // rbx
char *v29; // rax
void *Block[2]; // [rsp+20h] [rbp-48h] BYREF
GradientTriggerObject **v31; // [rsp+30h] [rbp-38h]
GJEffectManager::controlActionsForControlID(a1->m_effectManager, a2, a3);
GJBaseGameLayer::controlAreaEffectWithID(a1, -1, a2, a3);
Mylast = a1->m_gameState.m_advanceFollowInstances._Mypair._Myval2._Mylast;
for ( i = a1->m_gameState.m_advanceFollowInstances._Mypair._Myval2._Myfirst; i != Mylast; ++i )
{
if ( a2 == -1 )
{
if ( i->m_gameObject )
continue;
}
else if ( i->m_controlId != a2 )
{
continue;
}
switch ( a3 )
{
case Stop:
i->m_started = 1;
LABEL_11:
*(_WORD *)&i->m_finished = 0;
continue;
case Pause:
*(_WORD *)&i->m_finished = 257;
break;
case Resume:
goto LABEL_11;
}
}
GJBaseGameLayer::controlEventLink(a1, -1, a2, a3);
v8 = a1->m_gameState.m_dynamicMoveActions._Mypair._Myval2._Mylast;
for ( j = a1->m_gameState.m_dynamicMoveActions._Mypair._Myval2._Myfirst; j != v8; ++j )
{
if ( a2 == -1 )
{
if ( !j->m_gameObject1 )
{
LABEL_18:
if ( a3 )
{
if ( a3 == Pause )
{
*(_WORD *)&j->m_unkBool3 = 257;
}
else if ( a3 == Resume )
{
*(_WORD *)&j->m_unkBool3 = 0;
}
}
else
{
j->m_unkBool2 = 1;
}
}
}
else if ( j->m_controlID == a2 )
{
goto LABEL_18;
}
}
v10 = a1->m_gameState.m_dynamicRotateActions._Mypair._Myval2._Mylast;
for ( k = a1->m_gameState.m_dynamicRotateActions._Mypair._Myval2._Myfirst; k != v10; ++k )
{
if ( a2 == -1 )
{
if ( !k->m_gameObject1 )
{
LABEL_30:
if ( a3 )
{
if ( a3 == Pause )
{
*(_WORD *)&k->m_unkBool3 = 257;
}
else if ( a3 == Resume )
{
*(_WORD *)&k->m_unkBool3 = 0;
}
}
else
{
k->m_unkBool2 = 1;
}
}
}
else if ( k->m_controlID == a2 )
{
goto LABEL_30;
}
}
GJGameState::controlTweenAction(&a1->m_gameState, -1, a2, a3);
Myhead = a1->m_labelObjects._List._Mypair._Myval2._Myhead;
for ( m = *(_QWORD **)Myhead; m != (_QWORD *)Myhead; m = (_QWORD *)*m )
{
v14 = m[4];
for ( n = m[3]; n != v14; n += 8 )
{
if ( *(_DWORD *)(*(_QWORD *)n + 1688LL) == a2 )
*(_BYTE *)(*(_QWORD *)n + 1928LL) = a3 != Resume;
}
}
*(_OWORD *)Block = 0;
v16 = nullptr;
v31 = nullptr;
p_m_gradientLayers = &a1->m_gradientLayers;
m_gradientLayers = a1->m_gradientLayers;
v19 = nullptr;
if ( m_gradientLayers )
{
m_pElements = m_gradientLayers->m_pElements;
if ( m_pElements )
{
for ( ii = (cocos2d::CCDictElement *)m_pElements->hh.next; ; ii = (cocos2d::CCDictElement *)ii->hh.next )
{
p_m_uAutoReleaseCount = &m_pElements->m_pObject[10].m_uAutoReleaseCount;
v23 = *(GradientTriggerObject **)p_m_uAutoReleaseCount;
if ( *(_QWORD *)p_m_uAutoReleaseCount && v23->m_controlID == a2 )
{
if ( v19 == v16 )
{
sub_140063110(Block, v19, p_m_uAutoReleaseCount);
v16 = v31;
v19 = (GradientTriggerObject **)Block[1];
}
else
{
*v19++ = v23;
Block[1] = v19;
}
}
m_pElements = ii;
if ( !ii )
break;
}
p_m_gradientLayers = &a1->m_gradientLayers;
}
}
v24 = (char *)Block[0];
v25 = (GradientTriggerObject **)Block[0];
if ( Block[0] != v19 )
{
if ( a3 == Resume )
{
do
GJBaseGameLayer::triggerGradientCommand(a1, *v25++);
while ( v25 != v19 );
}
else
{
do
{
m_gradientID = (*v25)->m_gradientID;
if ( m_gradientID > 999 )
m_gradientID = 999;
v27 = cocos2d::CCDictionary::objectForKey(*p_m_gradientLayers, m_gradientID);
v28 = v27;
if ( v27 )
{
v27->__vftable[7].copyWithZone(v27, nullptr);
*(_QWORD *)&v28[10].m_uAutoReleaseCount = 0;
}
++v25;
}
while ( v25 != v19 );
}
}
if ( v24 )
{
v29 = v24;
if ( (((char *)v16 - v24) & 0xFFFFFFFFFFFFFFF8uLL) >= 0x1000 )
{
v24 = *((char **)v24 - 1);
if ( (unsigned __int64)(v29 - v24 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v24);
}
}