//
// GJDifficultySprite::updateFeatureState from 0x8da124 to 0x8da494 (880 bytes)
//
// 8 xrefs:
// > GJRateLevelLayer::onFeature @ 0x82026c
// > RateStarsLayer::onFeature @ 0x8243a4
// > GJDifficultySprite::updateFeatureStateFromLevel @ 0x8da4d0
// > GJDifficultySprite::updateFeatureStateFromLevel @ 0x8da4e0
// > GJDifficultySprite::updateFeatureStateFromLevel @ 0x8da4e8
// > GJDifficultySprite::updateFeatureStateFromLevel @ 0x8da4f0
// > GJDifficultySprite::updateFeatureStateFromLevel @ 0x8da4fc
// > ??> @ 0x7ca58
//
// 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 GJDifficultySprite::updateFeatureState(GJDifficultySprite *a1, GJFeatureState a2)
{
GJDifficultySprite_vtbl *v3; // x2
GJFeatureState m_featureState; // w0
cocos2d::CCSprite *v5; // x22
void (__fastcall *setPosition)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x23
float v7; // s8
const cocos2d::CCSize *v8; // x0
char *p_m_fBrVertexMod; // x0
unsigned int *p_m_fTextureTop; // x1
int m_fTextureTop_low; // w2
cocos2d::CCParticleSystemQuad *v12; // x22
void (__fastcall *v13)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x23
float v14; // s8
const cocos2d::CCSize *v15; // x0
int v16; // w20
void *v17; // x0
unsigned int *v18; // x1
int v19; // w2
cocos2d::CCSprite *v20; // [xsp+40h] [xbp+40h] BYREF
__int64 v21; // [xsp+48h] [xbp+48h] BYREF
cocos2d::CCPoint v22; // [xsp+50h] [xbp+50h] BYREF
if ( a1->m_featureState != a2 )
{
v3 = a1->cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_featureState = a2;
((void (*)(void))v3->removeAllChildren)();
if ( a1->m_featureState )
{
sub_D153B8((int)&v20, "GJ_featuredCoin_001.png");
m_featureState = a1->m_featureState;
switch ( m_featureState )
{
case Mythic:
sub_D1798C(&v20, "GJ_epicCoin3_001.png", 20);
break;
case Legendary:
sub_D1798C(&v20, "GJ_epicCoin2_001.png", 20);
break;
case Epic:
sub_D1798C(&v20, "GJ_epicCoin_001.png", 19);
break;
}
v5 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v20);
a1->addChild_0(a1, v5, -2);
setPosition = v5->setPosition;
v7 = a1->getContentSize(a1)->width * 0.5;
v8 = a1->getContentSize(a1);
cocos2d::CCPoint::CCPoint(&v22, v7, v8->height * 0.5);
setPosition(v5, &v22);
if ( a1->m_featureState == Mythic )
{
sub_D153B8(
(int)&v21,
"30a-1a1.3a0.2a20a90a0a10a5a20a20a0a0a8a0a0a0a4a1a0a0a0a0a1a0a1a0a1a0a1a1a0a0a0a0a0.784314a0a1a0a1a0a0.27a0a0.2"
"7a0a0a0a0a0a0a0a0a2a1a0a0a0a0a0a0a0.25a0a0a0a0a0a0a0a0a0a0a0");
v12 = GameToolbox::particleFromString(&v21, nullptr, 0);
a1->addChild_0(a1, v12, -1);
v12->setScale(v12, 0.9);
cocos2d::CCParticleSystem::resetSystem(v12);
v13 = v12->setPosition;
v14 = a1->getContentSize(a1)->width * 0.5;
v15 = a1->getContentSize(a1);
cocos2d::CCPoint::CCPoint(&v22, v14, v15->height * 0.5);
v13(v12, &v22);
v16 = 5;
do
{
v12->update(v12, 0.15);
--v16;
}
while ( v16 );
v17 = (void *)(v21 - 24);
if ( (__int64 *)(v21 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v18 = (unsigned int *)(v21 - 8);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *(_DWORD *)(v21 - 8);
*(_DWORD *)(v21 - 8) = v19 - 1;
}
if ( v19 <= 0 )
operator delete(v17);
}
}
p_m_fBrVertexMod = (char *)&v20[-1].m_fBrVertexMod;
if ( (__int64 *)&v20[-1].m_fBrVertexMod != &qword_124B6B0 )
{
if ( &pthread_create )
{
p_m_fTextureTop = (unsigned int *)&v20[-1].m_fTextureTop;
do
m_fTextureTop_low = __ldaxr(p_m_fTextureTop);
while ( __stlxr(m_fTextureTop_low - 1, p_m_fTextureTop) );
}
else
{
m_fTextureTop_low = LODWORD(v20[-1].m_fTextureTop);
LODWORD(v20[-1].m_fTextureTop) = m_fTextureTop_low - 1;
}
if ( m_fTextureTop_low <= 0 )
operator delete(p_m_fBrVertexMod);
}
}
}
}