//
// GJBaseGameLayer::volumeForProximityEffect from 0x10015e910 to 0x10015ed64 (1108 bytes)
//
// 4 xrefs:
// > GJBaseGameLayer::update @ 0x1001530d5
// > GJBaseGameLayer::updateProximityVolumeEffects @ 0x1001563d8
// > GJBaseGameLayer::activateSFXTrigger @ 0x10015a7fc
// > GJBaseGameLayer::addProximityVolumeEffect @ 0x10015e8dd
//
// 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)
{
__m128 v3; // xmm0
float v4; // xmm1_4
int m_groupID1; // ecx
intptr_t v6; // r12
SFXTriggerGameObject *m_sfxTriggerGameObject; // r13
cocos2d::CCArray *v8; // r14
bool m_isDualMode; // r15
char v10; // r12
float result; // xmm0_4
float MinDistance; // xmm0_4
float v13; // xmm5_4
float v14; // xmm6_4
PlayerObject *m_player2; // rdi
PlayerObject_vtbl *v16; // rax
float v17; // xmm0_4
float v18; // xmm0_4
float v19; // xmm3_4
float v20; // xmm2_4
float v21; // xmm1_4
int m_nLuaID; // xmm0_4
int m_nTag; // xmm4_4
__int64 v24; // rdi
intptr_t m_groupID2; // r15
cocos2d::CCDictionary *m_parentGroupsDict; // rdi
__int64 v27; // rsi
cocos2d::CCObject *v28; // rax
__int64 v29; // rcx
cocos2d::CCArray *v30; // r15
cocos2d::CCArray *v31; // rdi
_BYTE v32[8]; // [rsp+8h] [rbp-78h] BYREF
float *v33; // [rsp+10h] [rbp-70h]
__int64 m_minDistFar; // [rsp+18h] [rbp-68h]
__int64 m_minDistMedium; // [rsp+20h] [rbp-60h]
unsigned __int64 v36; // [rsp+28h] [rbp-58h] BYREF
cocos2d::CCArray v37; // [rsp+34h] [rbp-4Ch] BYREF
cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v36);
v3 = _mm_div_ps((__m128)v36, _mm_moveldup_ps((__m128)LODWORD(a1->m_gameState.m_cameraZoom)));
_mm_storel_ps((double *)&v36, v3);
v4 = _mm_movehdup_ps(v3).f32[0] * 0.5;
sub_10028CBE0(&v37.m_uReference, v3.f32[0] * 0.5, v4);
sub_10028CCE0(v32, &a1->m_gameState.m_cameraPosition);
m_groupID1 = 9999;
if ( a2->m_groupID1 < 9999 )
m_groupID1 = a2->m_groupID1;
v6 = 0;
if ( m_groupID1 > 0 )
v6 = (unsigned int)m_groupID1;
m_sfxTriggerGameObject = a2->m_sfxTriggerGameObject;
v8 = a1->m_groups.__begin_[v6];
if ( v8 )
{
sub_10028CC30(&v37.m_uReference);
if ( m_sfxTriggerGameObject->m_cameraDistance )
{
LABEL_7:
sub_10028CC90();
goto LABEL_8;
}
}
else
{
v8 = (cocos2d::CCArray *)sub_10071F9E0(v32, &a1->m_gameState.m_cameraPosition);
cocos2d::CCDictionary::setObject(a1->m_groupDict, v8, v6);
a1->m_groups.__begin_[v6] = v8;
sub_10028CC30(&v37.m_uReference);
if ( m_sfxTriggerGameObject->m_cameraDistance )
goto LABEL_7;
}
if ( !m_sfxTriggerGameObject->m_targetPlayer1 )
{
if ( m_sfxTriggerGameObject->m_targetPlayer2 )
{
v24 = *((_QWORD *)&a1->m_player1 + a1->m_gameState.m_isDualMode);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v24 + 192LL))(v24);
goto LABEL_7;
}
m_groupID2 = a2->m_groupID2;
v10 = 1;
if ( m_groupID2 > 0 )
{
m_parentGroupsDict = a1->m_parentGroupsDict;
v27 = a2->m_groupID2;
v28 = cocos2d::CCDictionary::objectForKey(m_parentGroupsDict, m_groupID2);
if ( v28 )
{
LABEL_29:
((void (__fastcall *)(cocos2d::CCArray *, cocos2d::CCObject *))v28->__vftable[16].getTag)(&v37, v28);
goto LABEL_7;
}
v29 = 9999;
if ( (unsigned int)m_groupID2 < 0x270F )
v29 = (unsigned int)m_groupID2;
v30 = a1->m_groups.__begin_[v29];
if ( v30
|| (*(_QWORD *)&v37.m_eObjType = v29,
v30 = (cocos2d::CCArray *)sub_10071F9E0(m_parentGroupsDict, v27),
cocos2d::CCDictionary::setObject(a1->m_groupDict, v30, *(intptr_t *)&v37.m_eObjType),
(a1->m_groups.__begin_[*(_QWORD *)&v37.m_eObjType] = v30) != nullptr) )
{
if ( (unsigned int)sub_100720070(v30) == 1 )
{
v31 = v30;
m_isDualMode = 0;
v28 = (cocos2d::CCObject *)sub_1007200C0(v31, 0);
if ( !v28 )
goto LABEL_10;
goto LABEL_29;
}
}
}
m_isDualMode = 0;
goto LABEL_10;
}
((void (__fastcall *)(PlayerObject *))a1->m_player1->getPosition)(a1->m_player1);
sub_10028CC90();
if ( m_sfxTriggerGameObject->m_targetPlayer2 )
{
m_isDualMode = a1->m_gameState.m_isDualMode;
goto LABEL_9;
}
LABEL_8:
m_isDualMode = 0;
LABEL_9:
v10 = 0;
LABEL_10:
result = 1.0;
if ( v8 )
{
result = 1.0;
if ( !(((unsigned int)sub_100720070(v8) == 0) | (unsigned __int8)v10) )
{
*(float *)&v37.m_eObjType = (float)(3 * m_sfxTriggerGameObject->m_minDistNear);
v37.m_nTag = LODWORD(m_sfxTriggerGameObject->m_volumeNear);
v37.m_nLuaID = LODWORD(m_sfxTriggerGameObject->m_volumeFar);
m_minDistMedium = (unsigned int)m_sfxTriggerGameObject->m_minDistMedium;
v33 = (float *)m_sfxTriggerGameObject;
m_minDistFar = (unsigned int)m_sfxTriggerGameObject->m_minDistFar;
sub_10028CC60(&v37);
MinDistance = GJBaseGameLayer::getMinDistance(
(GJBaseGameLayer *)&v37,
(cocos2d::CCPoint)(unsigned int)v37.m_eObjType,
&v37,
v4,
(int)v8);
v13 = *(float *)&v37.m_eObjType;
v14 = MinDistance;
if ( MinDistance > *(float *)&v37.m_eObjType && m_isDualMode )
{
m_player2 = a1->m_player2;
v16 = m_player2->GameObject::CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
*(float *)&v37.m_uID = MinDistance;
((void (__fastcall *)(PlayerObject *))v16->getPosition)(m_player2);
sub_10028CC60(&v37);
v17 = GJBaseGameLayer::getMinDistance(
(GJBaseGameLayer *)&v37,
(cocos2d::CCPoint)(unsigned int)v37.m_eObjType,
&v37,
v4,
(int)v8);
v14 = *(float *)&v37.m_uID;
v13 = *(float *)&v37.m_eObjType;
if ( *(float *)&v37.m_uID > v17 )
{
((void (__fastcall *)(PlayerObject *))a1->m_player2->getPosition)(a1->m_player2);
sub_10028CC60(&v37);
v18 = GJBaseGameLayer::getMinDistance(
(GJBaseGameLayer *)&v37,
(cocos2d::CCPoint)(unsigned int)v37.m_eObjType,
&v37,
v4,
(int)v8);
v13 = *(float *)&v37.m_eObjType;
v14 = v18;
}
}
v19 = 0.0;
if ( v13 >= v14 )
{
m_nLuaID = v37.m_nLuaID;
m_nTag = v37.m_nTag;
}
else
{
v20 = v13 + (float)(3 * m_minDistMedium);
v21 = (float)(3 * m_minDistFar) + v20;
m_nLuaID = v37.m_nLuaID;
m_nTag = v37.m_nTag;
if ( v14 >= v21 )
{
v19 = 1.0;
}
else
{
if ( v20 > 0.0 )
{
if ( v14 >= v20 )
{
m_nTag = *((int *)v33 + 479);
m_nLuaID = *((int *)v33 + 480);
v13 = v13 + (float)(3 * m_minDistMedium);
}
else
{
m_nTag = *((int *)v33 + 478);
m_nLuaID = *((int *)v33 + 479);
v21 = v13 + (float)(3 * m_minDistMedium);
}
}
if ( v13 != v21 )
v19 = (float)(v14 - v13) / (float)(v21 - v13);
}
}
return (float)((float)(*(float *)&m_nLuaID - *(float *)&m_nTag) * v19) + *(float *)&m_nTag;
}
}
return result;
}