//
// GJBaseGameLayer::volumeForProximityEffect from 0x1402425f0 to 0x1402429bb (971 bytes)
//
// 6 xrefs:
// > GJBaseGameLayer::activateSFXTrigger @ 0x140241d25
// > GJBaseGameLayer::updateProximityVolumeEffects @ 0x140242372
// > GJBaseGameLayer::addProximityVolumeEffect @ 0x140242572
// > ??> @ 0x140682014
// > ??> @ 0x140682024
// > ??> @ 0x1406ce49c
//
// 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
//
float GJBaseGameLayer::volumeForProximityEffect(GJBaseGameLayer *a1, SFXTriggerInstance *a2)
{
cocos2d::CCDirector *v4; // rax
float m_cameraZoom; // xmm0_4
SFXTriggerGameObject *m_sfxTriggerGameObject; // rbx
cocos2d::CCArray *Group; // rbp
char v8; // si
bool m_isDualMode; // r15
const cocos2d::CCPoint *v10; // rax
PlayerObject *m_player2; // rcx
__int64 v12; // rax
GameObject *MainObject; // rax
__int64 v14; // rax
int m_proximityMode; // esi
float m_volumeFar; // xmm6_4
float m_volumeNear; // xmm11_4
float v18; // xmm7_4
float v19; // xmm10_4
float v20; // xmm8_4
cocos2d::CCPoint v21; // rax
GJBaseGameLayer *v22; // rcx
float MinDistance; // xmm0_4
float v24; // xmm9_4
cocos2d::CCPoint v25; // rax
GJBaseGameLayer *v26; // rcx
cocos2d::CCPoint v27; // rax
GJBaseGameLayer *v28; // rcx
float v29; // xmm0_4
cocos2d::CCPoint v31; // [rsp+30h] [rbp-A8h] BYREF
cocos2d::CCPoint v32; // [rsp+E0h] [rbp+8h] BYREF
float v33; // [rsp+E8h] [rbp+10h]
float v34; // [rsp+ECh] [rbp+14h]
char v35; // [rsp+F0h] [rbp+18h] BYREF
cocos2d::CCPoint v36; // [rsp+F8h] [rbp+20h] BYREF
v4 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(a1);
cocos2d::CCDirector::getWinSize(v4);
m_cameraZoom = a1->m_gameState.m_cameraZoom;
v33 = v33 / m_cameraZoom;
v34 = v34 / m_cameraZoom;
cocos2d::CCPoint::CCPoint(m_cameraZoom, v33 * 0.5);
cocos2d::CCPoint::operator+(&a1->m_gameState.m_cameraPosition, &v35);
m_sfxTriggerGameObject = a2->m_sfxTriggerGameObject;
Group = GJBaseGameLayer::getGroup(a1, a2->m_groupID1);
cocos2d::CCPoint::CCPoint(&v32);
v8 = 0;
m_isDualMode = 0;
if ( m_sfxTriggerGameObject->m_cameraDistance )
{
v8 = 1;
cocos2d::CCPoint::operator=(&v32, &v35);
}
else if ( m_sfxTriggerGameObject->m_targetPlayer1 )
{
v8 = 1;
v10 = a1->m_player1->getPosition_0(a1->m_player1);
cocos2d::CCPoint::operator=(&v32, v10);
if ( m_sfxTriggerGameObject->m_targetPlayer2 )
m_isDualMode = a1->m_gameState.m_isDualMode;
}
else if ( m_sfxTriggerGameObject->m_targetPlayer2 )
{
v8 = 1;
if ( a1->m_gameState.m_isDualMode )
m_player2 = a1->m_player2;
else
m_player2 = a1->m_player1;
v12 = (__int64)m_player2->getPosition_0(m_player2);
cocos2d::CCPoint::operator=(&v32, v12);
}
else
{
MainObject = GJBaseGameLayer::tryGetMainObject(a1, a2->m_groupID2);
if ( MainObject )
{
v14 = ((__int64 (__fastcall *)(GameObject *, cocos2d::CCPoint *))MainObject->getRealPosition)(MainObject, &v36);
cocos2d::CCPoint::operator=(&v32, v14);
v8 = 1;
}
}
if ( !Group || !cocos2d::CCArray::count(Group) || !v8 )
return 1.0;
m_proximityMode = m_sfxTriggerGameObject->m_proximityMode;
m_volumeFar = m_sfxTriggerGameObject->m_volumeFar;
m_volumeNear = m_sfxTriggerGameObject->m_volumeNear;
v18 = (float)(3 * m_sfxTriggerGameObject->m_minDistNear);
v19 = (float)(3 * m_sfxTriggerGameObject->m_minDistMedium) + v18;
v20 = (float)(3 * m_sfxTriggerGameObject->m_minDistFar) + v19;
cocos2d::CCPoint::CCPoint(&v36);
MinDistance = GJBaseGameLayer::getMinDistance(v22, v21, Group, v18, m_proximityMode);
v24 = MinDistance;
if ( m_isDualMode && MinDistance > v18 )
{
a1->m_player2->getPosition_0(a1->m_player2);
cocos2d::CCPoint::CCPoint(&v36);
if ( GJBaseGameLayer::getMinDistance(v26, v25, Group, v18, m_proximityMode) <= v24 )
{
a1->m_player2->getPosition_0(a1->m_player2);
cocos2d::CCPoint::CCPoint(&v31);
v24 = GJBaseGameLayer::getMinDistance(v28, v27, Group, v18, m_proximityMode);
}
}
if ( v18 < v24 )
{
if ( v24 < v20 )
{
v29 = 0.0;
if ( v19 > 0.0 )
{
if ( v24 < v19 )
{
m_volumeNear = m_sfxTriggerGameObject->m_volumeNear;
v20 = v19;
m_volumeFar = m_sfxTriggerGameObject->m_volumeMedium;
}
else
{
m_volumeNear = m_sfxTriggerGameObject->m_volumeMedium;
v18 = v19;
m_volumeFar = m_sfxTriggerGameObject->m_volumeFar;
}
}
if ( v18 != v20 )
v29 = (float)(v24 - v18) / (float)(v20 - v18);
}
else
{
v29 = 1.0;
}
}
else
{
v29 = 0.0;
}
return (float)((float)(m_volumeFar - m_volumeNear) * v29) + m_volumeNear;
}