//
// GJBaseGameLayer::addProximityVolumeEffect from 0x140242430 to 0x1402425e4 (436 bytes)
//
// 7 xrefs:
// > GJBaseGameLayer::processQueuedAudioTriggers @ 0x14023bbe8
// > GJBaseGameLayer::activateSongEditTrigger @ 0x1402419f1
// > GJBaseGameLayer::activateSFXTrigger @ 0x140241e39
// > GJBaseGameLayer::activateSFXEditTrigger @ 0x140242005
// > GJBaseGameLayer::activateSFXEditTrigger @ 0x14024209f
// > ??> @ 0x1406ce484
// > ??> @ 0x1406ce490
//
// 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::addProximityVolumeEffect(GJBaseGameLayer *a1, int a2, int a3, SFXTriggerGameObject *a4)
{
std::map,SFXTriggerInstance> *p_m_proximityVolumeRelated; // r14
__int64 v9; // rcx
int m_controlID; // r11d
int m_centerGroupID; // r10d
int m_targetGroupID; // eax
std::_Tree_val, SFXTriggerInstance>>>::_Nodeptr Myhead; // rbx
std::_Tree_node, SFXTriggerInstance>, void *>::_Nodeptr Parent; // rax
__int64 v15; // rdx
char *v16; // rax
float v17; // xmm0_4
FMODAudioEngine *v18; // rcx
__int128 v19; // [rsp+20h] [rbp-68h] BYREF
__int128 v20; // [rsp+30h] [rbp-58h]
SFXTriggerGameObject *v21; // [rsp+40h] [rbp-48h]
__int128 v22; // [rsp+48h] [rbp-40h]
FMODAudioEngine *v23; // [rsp+90h] [rbp+8h] BYREF
LODWORD(v23) = a2;
HIDWORD(v23) = a3;
p_m_proximityVolumeRelated = &a1->m_gameState.m_proximityVolumeRelated;
sub_140249E30(&a1->m_gameState.m_proximityVolumeRelated, &v23);
m_controlID = a4->m_controlID;
m_centerGroupID = a4->m_centerGroupID;
m_targetGroupID = a4->m_targetGroupID;
v21 = a4;
*(_QWORD *)&v20 = __PAIR64__(m_centerGroupID, m_targetGroupID);
DWORD2(v20) = m_controlID;
Myhead = p_m_proximityVolumeRelated->_Mypair._Myval2._Myval2._Myhead;
Parent = p_m_proximityVolumeRelated->_Mypair._Myval2._Myval2._Myhead->_Parent;
*(_QWORD *)&v22 = Parent;
DWORD2(v22) = 0;
v15 = (__int64)Myhead;
while ( !Parent->_Isnil )
{
*(_QWORD *)&v22 = Parent;
if ( Parent->_Myval.first.first < a2 || Parent->_Myval.first.first <= a2 && Parent->_Myval.first.second < a3 )
{
DWORD2(v22) = 0;
Parent = Parent->_Right;
}
else
{
DWORD2(v22) = 1;
v15 = (__int64)Parent;
Parent = Parent->_Left;
}
}
if ( *(_BYTE *)(v15 + 25) || a2 < *(_DWORD *)(v15 + 32) || a2 <= *(_DWORD *)(v15 + 32) && a3 < *(_DWORD *)(v15 + 36) )
{
if ( p_m_proximityVolumeRelated->_Mypair._Myval2._Myval2._Mysize == 0x3FFFFFFFFFFFFFFLL )
sub_140052E40(v9, v15, 0);
v16 = (char *)operator new(0x40u);
*((_QWORD *)v16 + 4) = v23;
*(_OWORD *)(v16 + 40) = v20;
*((_QWORD *)v16 + 7) = v21;
*(_QWORD *)v16 = Myhead;
*((_QWORD *)v16 + 1) = Myhead;
*((_QWORD *)v16 + 2) = Myhead;
*((_WORD *)v16 + 12) = 0;
v19 = v22;
v15 = sub_1400636D0(p_m_proximityVolumeRelated, (__int64)&v19, (__int64)v16);
}
v17 = GJBaseGameLayer::volumeForProximityEffect(a1, (SFXTriggerInstance *)(v15 + 40));
v18 = (FMODAudioEngine *)qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v23 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v23);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v18 = (FMODAudioEngine *)qword_1406C2E88;
}
FMODAudioEngine::setChannelVolumeMod(v18, a2, (AudioTargetType)a3, v17);
}