//
// GJBaseGameLayer::activateSFXEditTrigger from 0x484c04 to 0x484d94 (400 bytes)
//
// 4 xrefs:
// > LevelEditorLayer::activateTriggerEffect @ 0x36dece
// > EffectGameObject::triggerObject @ 0x3eddd0
// > GJBaseGameLayer::processQueuedAudioTriggers @ 0x484df4
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x48baea
//
// 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::activateSFXEditTrigger(GJBaseGameLayer *a1, SFXTriggerGameObject *a2)
{
int m_groupID; // r1
cocos2d::CCArray *Group; // r0
cocos2d::CCArray *v5; // r5
cocos2d::ccArray *data; // r2
cocos2d::CCObject **arr; // r5
unsigned int v8; // r5
int m_sfxGroup; // r1
FMODAudioEngine *v10; // r0
int v11; // r0
int v12; // r3
int v13; // t1
_DWORD *v14; // r0
_DWORD *v15; // r7
cocos2d::CCObject **v16; // [sp+4h] [bp-38h]
_DWORD *v17; // [sp+8h] [bp-34h]
SFXTriggerGameObject *v18; // [sp+Ch] [bp-30h] BYREF
unsigned int v19[2]; // [sp+14h] [bp-28h] BYREF
int v20; // [sp+1Ch] [bp-20h] BYREF
char v21; // [sp+20h] [bp-1Ch] BYREF
unsigned int v22; // [sp+28h] [bp-14h]
v18 = a2;
if ( a1->m_practiceMusicSync || !a1->m_isPracticeMode )
{
if ( a1->m_loadingStartPosition )
{
a1->activatedAudioTrigger(a1, v18);
}
else if ( a1->m_startingFromBeginning )
{
std::vector::push_back((const void **)&a1->m_activeSfxTriggers.m_start, &v18);
}
else
{
m_groupID = v18->m_groupID;
if ( m_groupID > 0 )
{
Group = GJBaseGameLayer::getGroup(a1, m_groupID);
v5 = Group;
if ( Group )
{
if ( cocos2d::CCArray::count(Group) )
{
std::_Rb_tree,std::less,std::allocator>::_Rb_tree_impl,true>::_Rb_tree_impl(&v20);
data = v5->data;
if ( data->num )
{
arr = data->arr;
v16 = &arr[data->num] + 0x3FFFFFFF;
while ( arr <= v16 )
{
v13 = (int)*arr++;
v12 = v13;
if ( !v13 )
break;
if ( *(_DWORD *)(v12 + 884) == 3602 )
{
v19[0] = *(_DWORD *)(v12 + 772);
v14 = std::__detail::_Map_base>,std::allocator>>,std::__detail::_Select1st,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits,true>::operator[](
&a1->m_gameState.m_unkUMap8._M_h._M_buckets,
v19);
v15 = (_DWORD *)*v14;
v17 = (_DWORD *)v14[1];
while ( v15 != v17 )
std::_Rb_tree,std::less,std::allocator>::_M_insert_unique(
(int)v19,
(int)&v20,
v15++);
}
}
}
v19[0] = v22;
while ( 1 )
{
v8 = v19[0];
if ( (char *)v19[0] == &v21 )
break;
if ( !v18->m_applyDisabled )
GJBaseGameLayer::applySFXEditTrigger(a1, *(_DWORD *)(v19[0] + 16), v18->m_applyDisabled, v18);
if ( v18->m_targetGroupID > 0 )
GJBaseGameLayer::addProximityVolumeEffect(a1, *(_DWORD *)(v8 + 16), 0, v18);
std::_Rb_tree_const_iterator::operator++(v19);
}
std::_Rb_tree,std::less,std::allocator>::~_Rb_tree((int)&v20);
}
}
}
m_sfxGroup = v18->m_sfxGroup;
if ( m_sfxGroup > 0 )
{
if ( !v18->m_applyDisabled )
GJBaseGameLayer::applySFXEditTrigger(a1, m_sfxGroup, 1, v18);
if ( v18->m_targetGroupID > 0 )
GJBaseGameLayer::addProximityVolumeEffect(a1, v18->m_sfxGroup, 1, v18);
}
if ( v18->m_sfxUniqueID > 0 )
{
v10 = FMODAudioEngine::sharedEngine();
v11 = FMODAudioEngine::channelIDForUniqueID(v10, v18->m_sfxUniqueID);
if ( !v18->m_applyDisabled )
GJBaseGameLayer::applySFXEditTrigger(a1, v11, v18->m_applyDisabled, v18);
}
}
}
}