//
// GJBaseGameLayer::volumeForProximityEffect from 0x10013e170 to 0x10013e542 (978 bytes)
//
// 4 xrefs:
// > GJBaseGameLayer::update @ 0x100130dd5
// > GJBaseGameLayer::updateProximityVolumeEffects @ 0x1001342e8
// > GJBaseGameLayer::activateSFXTrigger @ 0x100139d06
// > GJBaseGameLayer::addProximityVolumeEffect @ 0x10013e13d
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:24:53 +0000
//
float __fastcall GJBaseGameLayer::volumeForProximityEffect(__int64 a1, __int64 a2)
{
__int64 v3; // rax
__m128 v4; // xmm0
int v5; // ecx
__int64 v6; // r12
__int64 v7; // r13
__int64 v8; // r14
_BYTE *v9; // rsi
unsigned __int8 v10; // r15
char v11; // r12
float result; // xmm0_4
unsigned int v13; // r12d
double MinDistance; // xmm0_8
float v15; // xmm5_4
float v16; // xmm6_4
__int64 *v17; // rdi
__int64 v18; // rax
__int64 v19; // rax
unsigned int v20; // r15d
double v21; // xmm0_8
__int64 v22; // rax
double v23; // xmm0_8
float v24; // xmm3_4
float v25; // xmm2_4
float v26; // xmm1_4
float v27; // xmm0_4
float v28; // xmm4_4
__int64 v29; // rax
__int64 v30; // rdi
__int64 MainObject; // rax
_BYTE v32[8]; // [rsp+0h] [rbp-70h] BYREF
__int64 v33; // [rsp+8h] [rbp-68h]
__int64 v34; // [rsp+10h] [rbp-60h]
unsigned __int64 v35; // [rsp+18h] [rbp-58h] BYREF
unsigned int v36; // [rsp+24h] [rbp-4Ch]
float v37; // [rsp+28h] [rbp-48h]
_BYTE v38[8]; // [rsp+2Ch] [rbp-44h] BYREF
float v39; // [rsp+34h] [rbp-3Ch]
float v40; // [rsp+38h] [rbp-38h]
_BYTE v41[8]; // [rsp+3Ch] [rbp-34h] BYREF
float v42; // [rsp+44h] [rbp-2Ch]
v3 = cocos2d::CCDirector::sharedDirector(a1, a2);
cocos2d::CCDirector::getWinSize(&v35, v3);
v4 = _mm_div_ps((__m128)v35, _mm_moveldup_ps((__m128)*(unsigned int *)(a1 + 424)));
_mm_storel_ps((double *)&v35, v4);
sub_100278250(v41, v4.f32[0] * 0.5, _mm_movehdup_ps(v4).f32[0] * 0.5);
sub_100278350(v32, a1 + 992, v41);
v5 = 9999;
if ( *(int *)a2 < 9999 )
v5 = *(_DWORD *)a2;
v6 = 0;
if ( v5 > 0 )
v6 = (unsigned int)v5;
v7 = *(_QWORD *)(a2 + 16);
v8 = *(_QWORD *)(*(_QWORD *)(a1 + 3616) + 8 * v6);
if ( v8 )
{
sub_1002782A0(v41);
if ( *(_BYTE *)(v7 + 1944) == 1 )
{
LABEL_7:
v9 = v32;
LABEL_8:
sub_100278300(v41, v9);
LABEL_9:
v10 = 0;
goto LABEL_10;
}
}
else
{
v8 = sub_1007FE900(v32);
cocos2d::CCDictionary::setObject_1(*(_QWORD *)(a1 + 3592), v8, v6);
*(_QWORD *)(*(_QWORD *)(a1 + 3616) + 8 * v6) = v8;
sub_1002782A0(v41);
if ( *(_BYTE *)(v7 + 1944) == 1 )
goto LABEL_7;
}
if ( *(_BYTE *)(v7 + 1684) != 1 )
{
if ( *(_BYTE *)(v7 + 1685) == 1 )
{
v30 = *(_QWORD *)(a1 + 8LL * *(unsigned __int8 *)(a1 + 1010) + 3256);
v9 = (_BYTE *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v30 + 192LL))(v30);
}
else
{
MainObject = GJBaseGameLayer::tryGetMainObject((_QWORD *)a1, *(_DWORD *)(a2 + 4));
if ( !MainObject )
{
v11 = 1;
v10 = 0;
result = 1.0;
if ( !v8 )
return result;
goto LABEL_11;
}
(*(void (__fastcall **)(_BYTE *, __int64))(*(_QWORD *)MainObject + 1360LL))(v38, MainObject);
v9 = v38;
}
goto LABEL_8;
}
v29 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 3256) + 192LL))(*(_QWORD *)(a1 + 3256));
sub_100278300(v41, v29);
if ( *(_BYTE *)(v7 + 1685) != 1 )
goto LABEL_9;
v10 = *(_BYTE *)(a1 + 1010);
LABEL_10:
v11 = 0;
result = 1.0;
if ( !v8 )
return result;
LABEL_11:
result = 1.0;
if ( !(((unsigned int)sub_1007FEF90(v8) == 0) | (unsigned __int8)v11) )
{
v13 = *(_DWORD *)(v7 + 1940);
v42 = (float)(3 * *(_DWORD *)(v7 + 1928));
v40 = *(float *)(v7 + 1916);
v39 = *(float *)(v7 + 1924);
v34 = *(unsigned int *)(v7 + 1932);
v33 = *(unsigned int *)(v7 + 1936);
sub_1002782D0(v38, v41);
v36 = v13;
MinDistance = GJBaseGameLayer::getMinDistance(v38, v38, v8, v13, v42);
v15 = v42;
v16 = *(float *)&MinDistance;
if ( ((*(float *)&MinDistance > v42) & v10) == 1 )
{
v17 = *(__int64 **)(a1 + 3264);
v18 = *v17;
v37 = *(float *)&MinDistance;
v19 = (*(__int64 (__fastcall **)(__int64 *))(v18 + 192))(v17);
sub_1002782D0(v38, v19);
v20 = v36;
v21 = GJBaseGameLayer::getMinDistance(v38, v38, v8, v36, v42);
v16 = v37;
v15 = v42;
if ( v37 > *(float *)&v21 )
{
v22 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 3264) + 192LL))(*(_QWORD *)(a1 + 3264));
sub_1002782D0(v38, v22);
v23 = GJBaseGameLayer::getMinDistance(v38, v38, v8, v20, v42);
v15 = v42;
v16 = *(float *)&v23;
}
}
v24 = 0.0;
if ( v15 >= v16 )
{
v27 = v39;
v28 = v40;
}
else
{
v25 = v15 + (float)(3 * v34);
v26 = (float)(3 * v33) + v25;
v27 = v39;
v28 = v40;
if ( v16 >= v26 )
{
v24 = 1.0;
}
else
{
if ( v25 > 0.0 )
{
if ( v16 >= v25 )
{
v28 = *(float *)(v7 + 1920);
v27 = *(float *)(v7 + 1924);
v15 = v15 + (float)(3 * v34);
}
else
{
v28 = *(float *)(v7 + 1916);
v27 = *(float *)(v7 + 1920);
v26 = v15 + (float)(3 * v34);
}
}
if ( v15 != v26 )
v24 = (float)(v16 - v15) / (float)(v26 - v15);
}
}
return (float)((float)(v27 - v28) * v24) + v28;
}
return result;
}