//
// GJBaseGameLayer::activateSFXEditTrigger from 0x100203110 to 0x10020338c (636 bytes)
//
// 4 xrefs:
// > GJBaseGameLayer::processQueuedAudioTriggers @ 0x100202d60
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x100206dd4
// > LevelEditorLayer::activateTriggerEffect @ 0x100360fcc
// > EffectGameObject::triggerObject @ 0x1003857ac
//
// 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 __fastcall GJBaseGameLayer::activateSFXEditTrigger(GJBaseGameLayer *a1, SFXTriggerGameObject *a2)
{
int m_groupID; // w1
cocos2d::CCArray *Group; // x0
cocos2d::CCArray *v6; // x21
cocos2d::ccArray *data; // x9
__int64 num; // x8
cocos2d::CCObject **arr; // x24
unsigned __int64 v10; // x25
cocos2d::CCObject *v11; // x8
_QWORD *v12; // x0
int *v13; // x22
int *v14; // x27
_QWORD **v15; // x21
_QWORD *v16; // x9
_QWORD **v17; // x8
bool v18; // zf
int m_sfxGroup; // w1
FMODAudioEngine *v20; // x0
int v21; // w0
unsigned int m_uReference; // [xsp+Ch] [xbp-84h] BYREF
_QWORD **v23; // [xsp+10h] [xbp-80h] BYREF
_QWORD *v24[2]; // [xsp+18h] [xbp-78h] BYREF
SFXTriggerGameObject *v25; // [xsp+28h] [xbp-68h] BYREF
int *p_m_uReference; // [xsp+38h] [xbp-58h] BYREF
v25 = a2;
if ( a1->m_practiceMusicSync || !a1->m_isPracticeMode )
{
if ( a1->m_loadingStartPosition )
{
((void (__fastcall *)(GJBaseGameLayer *, SFXTriggerGameObject *))a1->activatedAudioTrigger)(a1, a2);
}
else if ( a1->m_startingFromBeginning )
{
sub_1000115B8((__int64)&a1->m_activeSfxTriggers, &v25);
}
else
{
m_groupID = a2->m_groupID;
if ( m_groupID >= 1 )
{
Group = GJBaseGameLayer::getGroup(a1, m_groupID);
if ( Group )
{
v6 = Group;
if ( (unsigned int)sub_10024A36C(Group) )
{
v24[0] = nullptr;
v24[1] = nullptr;
v23 = v24;
data = v6->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
v10 = (unsigned __int64)&arr[num - 1];
do
{
v11 = *arr;
if ( !*arr )
break;
if ( v11[18].m_uReference == 3602 )
{
m_uReference = v11[16].m_uReference;
p_m_uReference = (int *)&m_uReference;
v12 = sub_10001A284(
(unsigned __int64)&a1->m_gameState.m_unkUMap8,
(int *)&m_uReference,
(__int64)&unk_10063A31C,
&p_m_uReference);
v13 = (int *)v12[3];
v14 = (int *)v12[4];
while ( v13 != v14 )
{
sub_1000B4D20((__int64)&v23, v13, v13);
++v13;
}
}
++arr;
}
while ( (unsigned __int64)arr <= v10 );
v15 = v23;
if ( v23 != v24 )
{
do
{
if ( !a2->m_applyDisabled )
GJBaseGameLayer::applySFXEditTrigger(a1, *((_DWORD *)v15 + 7), 0, a2);
if ( a2->m_targetGroupID >= 1 )
GJBaseGameLayer::addProximityVolumeEffect(a1, *((_DWORD *)v15 + 7), 0, a2);
v16 = v15[1];
if ( v16 )
{
do
{
v17 = (_QWORD **)v16;
v16 = (_QWORD *)*v16;
}
while ( v16 );
}
else
{
do
{
v17 = (_QWORD **)v15[2];
v18 = *v17 == v15;
v15 = v17;
}
while ( !v18 );
}
v15 = v17;
}
while ( v17 != v24 );
}
}
sub_100017D70((__int64)&v23, v24[0]);
}
}
}
m_sfxGroup = a2->m_sfxGroup;
if ( m_sfxGroup >= 1 )
{
if ( !a2->m_applyDisabled )
GJBaseGameLayer::applySFXEditTrigger(a1, m_sfxGroup, 1, a2);
if ( a2->m_targetGroupID >= 1 )
GJBaseGameLayer::addProximityVolumeEffect(a1, a2->m_sfxGroup, 1, a2);
}
if ( a2->m_sfxUniqueID >= 1 )
{
v20 = FMODAudioEngine::sharedEngine();
v21 = FMODAudioEngine::channelIDForUniqueID(v20, a2->m_sfxUniqueID);
if ( !a2->m_applyDisabled )
GJBaseGameLayer::applySFXEditTrigger(a1, v21, 0, a2);
}
}
}
}