//
// GJBaseGameLayer::activateSFXEditTrigger from 0x140241e50 to 0x140242123 (723 bytes)
//
// 5 xrefs:
// > GJBaseGameLayer::processQueuedAudioTriggers @ 0x14023bbf5
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x140244c80
// > LevelEditorLayer::activateTriggerEffect @ 0x1402dd6bb
// > EffectGameObject::triggerObject @ 0x1404a7fa4
// > ??> @ 0x1406ce46c
//
// 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=2
void GJBaseGameLayer::activateSFXEditTrigger(GJBaseGameLayer *a1, SFXTriggerGameObject *a2)
{
std::vector *p_m_activeSfxTriggers; // rcx
_BYTE *Mylast; // rdx
int m_groupID; // edx
cocos2d::CCArray *Group; // rax
cocos2d::CCArray *v8; // rsi
_QWORD *v9; // rbx
cocos2d::ccArray *data; // rsi
__int64 num; // rax
cocos2d::CCObject **arr; // rsi
cocos2d::CCObject **v13; // r15
cocos2d::CCObject *v14; // rax
__int64 v15; // rax
int *v16; // rbp
int *i; // rbx
__int64 *v18; // rbx
__int64 **v19; // rax
__int64 *j; // rax
__int64 *k; // rax
int m_sfxGroup; // edx
FMODAudioEngine *v23; // rcx
int v24; // eax
void *v25[2]; // [rsp+20h] [rbp-58h] BYREF
char v26[16]; // [rsp+30h] [rbp-48h] BYREF
char v27[56]; // [rsp+40h] [rbp-38h] BYREF
FMODAudioEngine *v28; // [rsp+80h] [rbp+8h] BYREF
SFXTriggerGameObject *v29; // [rsp+88h] [rbp+10h] BYREF
v29 = a2;
if ( a1->m_practiceMusicSync || !a1->m_isPracticeMode )
{
if ( a1->m_loadingStartPosition )
{
((void (__fastcall *)(GJBaseGameLayer *))a1->activatedAudioTrigger)(a1);
}
else if ( a1->m_startingFromBeginning )
{
p_m_activeSfxTriggers = &a1->m_activeSfxTriggers;
Mylast = p_m_activeSfxTriggers->_Mypair._Myval2._Mylast;
if ( Mylast == (_BYTE *)p_m_activeSfxTriggers->_Mypair._Myval2._Myend )
{
sub_14012D2A0((const void **)&p_m_activeSfxTriggers->_Mypair._Myval2._Myfirst, Mylast, &v29);
}
else
{
*(_QWORD *)Mylast = a2;
++p_m_activeSfxTriggers->_Mypair._Myval2._Mylast;
}
}
else
{
m_groupID = a2->m_groupID;
if ( m_groupID > 0 )
{
Group = GJBaseGameLayer::getGroup(a1, m_groupID);
v8 = Group;
if ( Group )
{
if ( cocos2d::CCArray::count(Group) )
{
v25[1] = nullptr;
v9 = operator new(0x20u);
*v9 = v9;
v9[1] = v9;
v9[2] = v9;
*((_WORD *)v9 + 12) = 257;
v25[0] = v9;
data = v8->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
v13 = &arr[num - 1];
if ( arr <= v13 )
{
do
{
v14 = *arr;
if ( !*arr )
break;
if ( v14[18].m_eObjType == 3602 )
{
LODWORD(v28) = v14[16].m_eObjType;
v15 = sub_140250040(&a1->m_gameState.m_unkUMap8, v26, &v28);
v16 = *(int **)(*(_QWORD *)v15 + 32LL);
for ( i = *(int **)(*(_QWORD *)v15 + 24LL); i != v16; ++i )
sub_1400CDF10((__int64 *)v25, (__int64)v27, i);
}
++arr;
}
while ( arr <= v13 );
v9 = v25[0];
}
}
v18 = (__int64 *)*v9;
while ( !*((_BYTE *)v18 + 25) )
{
if ( !a2->m_applyDisabled )
GJBaseGameLayer::applySFXEditTrigger(a1, *((_DWORD *)v18 + 7), 0, a2);
if ( a2->m_targetGroupID > 0 )
GJBaseGameLayer::addProximityVolumeEffect(a1, *((_DWORD *)v18 + 7), 0, a2);
v19 = (__int64 **)v18[2];
if ( *((_BYTE *)v19 + 25) )
{
for ( j = (__int64 *)v18[1]; !*((_BYTE *)j + 25); j = (__int64 *)j[1] )
{
if ( v18 != (__int64 *)j[2] )
break;
v18 = j;
}
v18 = j;
}
else
{
v18 = (__int64 *)v18[2];
for ( k = *v19; !*((_BYTE *)k + 25); k = (__int64 *)*k )
v18 = k;
}
}
sub_1400CDB90(v25);
}
}
}
m_sfxGroup = a2->m_sfxGroup;
if ( m_sfxGroup > 0 )
{
if ( !a2->m_applyDisabled )
GJBaseGameLayer::applySFXEditTrigger(a1, m_sfxGroup, 1, a2);
if ( a2->m_targetGroupID > 0 )
GJBaseGameLayer::addProximityVolumeEffect(a1, a2->m_sfxGroup, 1, a2);
}
if ( a2->m_sfxUniqueID > 0 )
{
v23 = (FMODAudioEngine *)qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v28 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v28);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v23 = (FMODAudioEngine *)qword_1406C2E88;
}
v24 = FMODAudioEngine::channelIDForUniqueID(v23, a2->m_sfxUniqueID);
if ( !a2->m_applyDisabled )
GJBaseGameLayer::applySFXEditTrigger(a1, v24, 0, a2);
}
}
}
}