//
// GameObject::claimParticle from 0x1005bcb60 to 0x1005bd0d5 (1397 bytes)
//
// 46 xrefs:
// > ??> @ 0x1008c45d0
// > ??> @ 0x1008c4e08
// > ??> @ 0x1008c5600
// > ??> @ 0x1008c5df8
// > ??> @ 0x1008c65f0
// > ??> @ 0x1008c6de8
// > ??> @ 0x1008c75e0
// > ??> @ 0x1008c7dd8
// > ??> @ 0x1008c8dd0
// > ??> @ 0x1008c9648
// > ??> @ 0x1008c9e58
// > ??> @ 0x1008ca668
// > ??> @ 0x1008cae78
// > ??> @ 0x1008cb688
// > ??> @ 0x1008cbe98
// > ??> @ 0x1008cc6a8
// > ??> @ 0x1008cceb8
// > ??> @ 0x1008cd6c8
// > ??> @ 0x1008cded8
// > ??> @ 0x1008ce700
// > ??> @ 0x1008cef58
// > ??> @ 0x1008cf780
// > ??> @ 0x1008cffa8
// > ??> @ 0x1008d07d0
// > ??> @ 0x1008d0ff8
// > ??> @ 0x1008d1808
// > ??> @ 0x1008d2018
// > ??> @ 0x1008d2828
// > ??> @ 0x1008d3038
// > ??> @ 0x1008d3848
// > ??> @ 0x1008d4058
// > ??> @ 0x1008d4868
// > ??> @ 0x1008d5078
// > ??> @ 0x1008d5888
// > ??> @ 0x1008d6098
// > ??> @ 0x1008d68a8
// > ??> @ 0x1008d70b8
// > ??> @ 0x1008d78c8
// > ??> @ 0x1008d80d8
// > ??> @ 0x1008d88e8
// > ??> @ 0x1008d90f8
// > ??> @ 0x1009238a0
// > ??> @ 0x100933c68
// > ??> @ 0x100971950
// > ??> @ 0x100972138
// > ??> @ 0x100972948
//
// 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
//
void __fastcall GameObject::claimParticle(GameObject *a1)
{
__m128 v1; // xmm0
__m128 v2; // xmm1
ZLayer m_zLayer; // r14d
int ParentMode; // r15d
_BOOL8 m_editorEnabled; // r12
GameManager *v7; // rax
cocos2d::CCNode *v8; // rax
GameManager *v9; // rax
std::uint8_t sizex2; // cl
std::array *p_shortStorage; // r12
std::array *longStorage; // r12
LevelEditorLayer *m_levelEditorLayer; // r15
size_t v14; // rax
size_t v15; // r13
char *v16; // r15
PlayLayer *m_playLayer; // r15
size_t v18; // rax
size_t v19; // r13
char *v20; // r15
size_t v21; // r12
void **v22; // r12
size_t v23; // r12
__int64 v24; // rax
cocos2d::CCParticleSystemQuad *m_particle; // r14
cocos2d::CCParticleSystemQuad *v26; // r14
cocos2d::CCParticleSystemQuad *v27; // r14
int m_objectID; // eax
__int64 v29; // rax
cocos2d::CCSprite *v30; // rdi
unsigned __int16 *v31; // rax
__int64 v32; // rax
cocos2d::CCSprite *m_colorSprite; // rdi
unsigned __int16 *v34; // rax
GameObject *v35; // rdi
__int64 v36; // rax
cocos2d::CCParticleSystemQuad *v37; // rdi
cocos2d::CCParticleSystemQuad *v38; // rdi
__m128 v39; // xmm1
int v40; // r15d
cocos2d::CCParticleSystemQuad *v41; // r14
__int64 v42; // rax
cocos2d::CCParticleSystemQuad *v43; // rdi
__m128 v44; // xmm1
__int128 __dst; // [rsp+10h] [rbp-90h] BYREF
char *v46; // [rsp+20h] [rbp-80h] BYREF
__int128 v47; // [rsp+28h] [rbp-78h] BYREF
char *v48; // [rsp+38h] [rbp-68h] BYREF
__m128i v49; // [rsp+40h] [rbp-60h]
__m128 v50; // [rsp+50h] [rbp-50h]
__m128 inserted; // [rsp+60h] [rbp-40h] BYREF
unsigned __int16 v52; // [rsp+74h] [rbp-2Ch] BYREF
unsigned __int8 v53; // [rsp+76h] [rbp-2Ah]
m_zLayer = a1->m_zLayer;
if ( !m_zLayer )
m_zLayer = a1->m_defaultZLayer;
ParentMode = GameObject::getParentMode(a1);
m_editorEnabled = a1->m_editorEnabled;
v7 = GameManager::sharedState();
v8 = GJBaseGameLayer::parentForZLayer(
*((GJBaseGameLayer **)&v7->m_playLayer + m_editorEnabled),
m_zLayer,
1,
ParentMode,
a1->m_isUIObject);
((__int64 (__fastcall *)(cocos2d::CCNode *))v8->getZOrder)(v8);
LOBYTE(ParentMode) = a1->m_editorEnabled;
v9 = GameManager::sharedState();
sizex2 = a1->m_particleString.m_data.m_short.sizex2;
if ( (_BYTE)ParentMode != 1 )
{
if ( (sizex2 & 1) != 0 )
longStorage = (std::array *)a1->m_particleString.m_data.m_long.longStorage;
else
longStorage = &a1->m_particleString.m_data.m_short.shortStorage;
m_playLayer = v9->m_playLayer;
v18 = strlen(longStorage->__elems_);
if ( v18 >= 0xFFFFFFFFFFFFFFF8LL )
LABEL_56:
sub_100006BF0(*(double *)v1.i64);
v19 = v18;
v49.i64[0] = (__int64)m_playLayer;
if ( v18 >= 0x17 )
{
v50.i64[0] = (__int64)longStorage;
v23 = 26;
if ( (v18 | 7) != 0x17 )
v23 = (v18 | 7) + 1;
v20 = (char *)operator new(v23);
v48 = v20;
*(_QWORD *)&v47 = v23 + 1;
longStorage = (std::array *)v50.i64[0];
*((_QWORD *)&v47 + 1) = v19;
}
else
{
LOBYTE(v47) = 2 * v18;
v20 = (char *)&v47 + 1;
if ( !v18 )
{
LABEL_28:
v22 = (void **)&v48;
v20[v19] = 0;
a1->m_particle = (cocos2d::CCParticleSystemQuad *)GJBaseGameLayer::claimParticle(v49.i64[0], &v47, v1);
if ( (v47 & 1) == 0 )
goto LABEL_30;
goto LABEL_29;
}
}
memmove(v20, longStorage, v19);
goto LABEL_28;
}
if ( (sizex2 & 1) != 0 )
p_shortStorage = (std::array *)a1->m_particleString.m_data.m_long.longStorage;
else
p_shortStorage = &a1->m_particleString.m_data.m_short.shortStorage;
m_levelEditorLayer = v9->m_levelEditorLayer;
v14 = strlen(p_shortStorage->__elems_);
if ( v14 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_56;
v15 = v14;
v49.i64[0] = (__int64)m_levelEditorLayer;
if ( v14 >= 0x17 )
{
v50.i64[0] = (__int64)p_shortStorage;
v21 = 26;
if ( (v14 | 7) != 0x17 )
v21 = (v14 | 7) + 1;
v16 = (char *)operator new(v21);
v46 = v16;
*(_QWORD *)&__dst = v21 + 1;
p_shortStorage = (std::array *)v50.i64[0];
*((_QWORD *)&__dst + 1) = v15;
goto LABEL_21;
}
LOBYTE(__dst) = 2 * v14;
v16 = (char *)&__dst + 1;
if ( v14 )
LABEL_21:
memmove(v16, p_shortStorage, v15);
v22 = (void **)&v46;
v16[v15] = 0;
a1->m_particle = (cocos2d::CCParticleSystemQuad *)GJBaseGameLayer::claimParticle(v49.i64[0], &__dst, v1);
if ( (__dst & 1) != 0 )
LABEL_29:
operator delete(*v22);
LABEL_30:
v24 = ((__int64 (__fastcall *)(GameObject *))a1->getPosition)(a1);
((void (__fastcall *)(GameObject *, __int64))a1->setPosition)(a1, v24);
m_particle = a1->m_particle;
if ( !m_particle )
return;
if ( !a1->m_isParticleSpriteLocked )
{
((void (__fastcall *)(GameObject *))a1->getScaleX)(a1);
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *))m_particle->setScaleX)(m_particle);
v27 = a1->m_particle;
((void (__fastcall *)(GameObject *))a1->getScaleY)(a1);
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *))v27->setScaleY)(v27);
v26 = a1->m_particle;
if ( a1->m_particleLocked )
goto LABEL_36;
goto LABEL_35;
}
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *, float))m_particle->setScale)(a1->m_particle, 1.0);
v26 = a1->m_particle;
if ( !a1->m_particleLocked )
LABEL_35:
((void (__fastcall *)(GameObject *, double))a1->getRotation)(a1, 0.0);
LABEL_36:
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *, double))v26->setRotation)(v26, 0.0);
if ( !a1->m_particleUseObjectColor )
return;
m_objectID = a1->m_objectID;
switch ( m_objectID )
{
case 1583:
goto LABEL_40;
case 1700:
if ( a1->m_particle )
{
v32 = ((__int64 (__fastcall *)(GameObject *))a1->getColor)(a1);
v53 = *(_BYTE *)(v32 + 2);
v52 = *(_WORD *)v32;
m_colorSprite = a1->m_colorSprite;
if ( m_colorSprite )
v34 = (unsigned __int16 *)((__int64 (__fastcall *)(cocos2d::CCSprite *))m_colorSprite->getColor)(m_colorSprite);
else
v34 = &v52;
v40 = *((unsigned __int8 *)v34 + 2);
v41 = a1->m_particle;
v49 = _mm_cvtsi32_si128(*v34);
v50 = _mm_div_ps(_mm_cvtepi32_ps(_mm_cvtepu8_epi32(_mm_cvtsi32_si128(v52))), (__m128)xmmword_100815DB0);
v2.f32[0] = (float)v53 / 255.0;
v42 = ((__int64 (__fastcall *)(cocos2d::CCParticleSystemQuad *))v41->getStartColor)(v41);
inserted = _mm_movelh_ps(v50, _mm_insert_ps(v2, (__m128)*(unsigned int *)(v42 + 12), 16));
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *, __m128 *))v41->setStartColor)(v41, &inserted);
v43 = a1->m_particle;
v44 = 0;
v44.f32[0] = (float)v40 / 255.0;
inserted = _mm_insert_ps(
_mm_div_ps(_mm_cvtepi32_ps(_mm_cvtepu8_epi32(v49.i32[0])), (__m128)xmmword_100815DB0),
v44,
40);
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *, __m128 *))v43->setEndColor)(v43, &inserted);
}
break;
case 1586:
LABEL_40:
if ( a1->m_particle )
{
v29 = ((__int64 (__fastcall *)(GameObject *))a1->getColor)(a1);
v53 = *(_BYTE *)(v29 + 2);
v52 = *(_WORD *)v29;
v30 = a1->m_colorSprite;
if ( v30 )
v31 = (unsigned __int16 *)((__int64 (__fastcall *)(cocos2d::CCSprite *))v30->getColor)(v30);
else
v31 = &v52;
v37 = a1->m_particle;
v2.f32[0] = (float)*((unsigned __int8 *)v31 + 2) / 255.0;
inserted = _mm_movelh_ps(
_mm_div_ps(_mm_cvtepi32_ps(_mm_cvtepu8_epi32(_mm_cvtsi32_si128(*v31))), (__m128)xmmword_100815DB0),
_mm_blend_ps(v2, (__m128)xmmword_1008150D0, 14));
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *, __m128 *))v37->setStartColor)(v37, &inserted);
v38 = a1->m_particle;
v39 = 0;
v39.f32[0] = (float)v53 / 255.0;
inserted = _mm_insert_ps(
_mm_div_ps(_mm_cvtepi32_ps(_mm_cvtepu8_epi32(_mm_cvtsi32_si128(v52))), (__m128)xmmword_100815DB0),
v39,
40);
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *, __m128 *))v38->setEndColor)(v38, &inserted);
if ( a1->m_objectID == 1586 )
cocos2d::CCParticleSystem::loadScaledDefaults(a1->m_particle, a1->m_scaleX);
}
return;
default:
if ( !a1->m_hasColorSprite || (v35 = (GameObject *)a1->m_colorSprite) == nullptr )
v35 = a1;
v36 = ((__int64 (__fastcall *)(GameObject *))v35->getColor)(v35);
((void (__fastcall *)(GameObject *, __int64))a1->updateParticleColor)(a1, v36);
break;
}
}