//
// GJBaseGameLayer::volumeForProximityEffect from 0x100205444 to 0x100205728 (740 bytes)
//
// 3 xrefs:
// > GJBaseGameLayer::updateProximityVolumeEffects @ 0x1002010c0
// > GJBaseGameLayer::activateSFXTrigger @ 0x10020305c
// > GJBaseGameLayer::addProximityVolumeEffect @ 0x100205410
//
// 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 __fastcall GJBaseGameLayer::volumeForProximityEffect(GJBaseGameLayer *a1, SFXTriggerInstance *a2)
{
cocos2d::CCDirector *v4; // x0
__n128 v5; // q0
__n128 v6; // q1
SFXTriggerGameObject *m_sfxTriggerGameObject; // x22
cocos2d::CCArray *Group; // x20
int *p_m_nTag; // x1
bool m_isDualMode; // w25
char v11; // w21
float v12; // s8
char v13; // w8
float m_volumeNear; // s10
float m_volumeFar; // s11
float v16; // s8
int m_minDistMedium; // w24
int m_minDistFar; // w23
GJBaseGameLayer *v19; // x0
float v20; // s2
float MinDistance; // s9
__int64 *v22; // x0
GJBaseGameLayer *v23; // x0
float v24; // s2
__int64 *v25; // x0
GJBaseGameLayer *v26; // x0
float v27; // s2
float v28; // s0
float v29; // s2
float v30; // s1
double *v31; // x0
__int64 v32; // x8
GameObject *MainObject; // x0
cocos2d::CCArray v35; // [xsp+0h] [xbp-80h] BYREF
cocos2d::CCPoint v36; // 0:s0.4,4:s1.4
cocos2d::CCPoint v37; // 0:s0.4,4:s1.4
cocos2d::CCPoint v38; // 0:s0.4,4:s1.4
v4 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v4);
v5.n128_u64[0] = (unsigned __int64)vld1_dup_f32(&a1->m_gameState.m_cameraZoom);
v6.n128_u64[0] = (unsigned __int64)vdiv_f32(*(float32x2_t *)&v35.m_uAutoReleaseCount, (float32x2_t)v5.n128_u64[0]);
*(_QWORD *)&v35.m_uAutoReleaseCount = v6.n128_u64[0];
v5.n128_f32[0] = 0.5 * v6.n128_f32[0];
v6.n128_f32[0] = vmuls_lane_f32(0.5, (float32x2_t)v6.n128_u64[0], 1);
sub_100022980(v5, v6, &v35.m_uID);
sub_1000229DC((float32x2_t *)&a1->m_gameState.m_cameraPosition, (float32x2_t *)&v35.m_uID, (float32x2_t *)&v35.m_nTag);
m_sfxTriggerGameObject = a2->m_sfxTriggerGameObject;
Group = GJBaseGameLayer::getGroup(a1, a2->m_groupID1);
sub_1000229B0(&v35.m_uID);
if ( m_sfxTriggerGameObject->m_cameraDistance )
{
p_m_nTag = &v35.m_nTag;
LABEL_3:
sub_1000229D0(&v35.m_uID, (double *)p_m_nTag);
goto LABEL_4;
}
if ( !m_sfxTriggerGameObject->m_targetPlayer1 )
{
if ( m_sfxTriggerGameObject->m_targetPlayer2 )
{
v32 = 3272;
if ( a1->m_gameState.m_isDualMode )
v32 = 3280;
p_m_nTag = (int *)(*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)((char *)&a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable
+ v32)
+ 192LL))(*(GJBaseGameLayer_vtbl **)((char *)&a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable
+ v32));
}
else
{
MainObject = GJBaseGameLayer::tryGetMainObject(a1, a2->m_groupID2);
if ( !MainObject )
{
m_isDualMode = 0;
v11 = 1;
goto LABEL_5;
}
((void (__fastcall *)(cocos2d::CCArray *__return_ptr))MainObject->getRealPosition)(&v35);
p_m_nTag = (int *)&v35;
}
goto LABEL_3;
}
v31 = (double *)((__int64 (__fastcall *)(PlayerObject *))a1->m_player1->getPosition)(a1->m_player1);
sub_1000229D0(&v35.m_uID, v31);
if ( m_sfxTriggerGameObject->m_targetPlayer2 )
{
v11 = 0;
m_isDualMode = a1->m_gameState.m_isDualMode;
goto LABEL_5;
}
LABEL_4:
m_isDualMode = 0;
v11 = 0;
LABEL_5:
v12 = 1.0;
if ( Group )
{
v13 = (unsigned int)sub_10024A36C(Group) ? v11 : 1;
if ( (v13 & 1) == 0 )
{
m_volumeNear = m_sfxTriggerGameObject->m_volumeNear;
m_volumeFar = m_sfxTriggerGameObject->m_volumeFar;
v16 = (float)(3 * m_sfxTriggerGameObject->m_minDistNear);
m_minDistMedium = m_sfxTriggerGameObject->m_minDistMedium;
m_minDistFar = m_sfxTriggerGameObject->m_minDistFar;
sub_1000229B8((__int64 *)&v35, (__int64 *)&v35.m_uID);
v36.x = v16;
MinDistance = GJBaseGameLayer::getMinDistance(v19, v36, &v35, v20, (int)Group);
if ( m_isDualMode && MinDistance > v16 )
{
v22 = (__int64 *)((__int64 (__fastcall *)(PlayerObject *))a1->m_player2->getPosition)(a1->m_player2);
sub_1000229B8((__int64 *)&v35, v22);
v37.x = v16;
if ( MinDistance > GJBaseGameLayer::getMinDistance(v23, v37, &v35, v24, (int)Group) )
{
v25 = (__int64 *)((__int64 (__fastcall *)(PlayerObject *))a1->m_player2->getPosition)(a1->m_player2);
sub_1000229B8((__int64 *)&v35, v25);
v38.x = v16;
MinDistance = GJBaseGameLayer::getMinDistance(v26, v38, &v35, v27, (int)Group);
}
}
v28 = 0.0;
if ( MinDistance > v16 )
{
v29 = v16 + (float)(3 * m_minDistMedium);
v30 = v29 + (float)(3 * m_minDistFar);
if ( MinDistance >= v30 )
{
v28 = 1.0;
}
else
{
if ( v29 > 0.0 )
{
if ( MinDistance >= v29 )
{
m_volumeNear = m_sfxTriggerGameObject->m_volumeMedium;
m_volumeFar = m_sfxTriggerGameObject->m_volumeFar;
v16 = v16 + (float)(3 * m_minDistMedium);
}
else
{
m_volumeNear = m_sfxTriggerGameObject->m_volumeNear;
m_volumeFar = m_sfxTriggerGameObject->m_volumeMedium;
v30 = v16 + (float)(3 * m_minDistMedium);
}
}
if ( v16 != v30 )
v28 = (float)(MinDistance - v16) / (float)(v30 - v16);
}
}
return m_volumeNear + (float)((float)(m_volumeFar - m_volumeNear) * v28);
}
}
return v12;
}