//
// SecretLayer4::onChest01 from 0x946814 to 0x94697c (360 bytes)
//
// 3 xrefs:
// > ??> @ 0xae558
// > SecretLayer4::init @ 0x94afe0
// > ??> @ 0x122e068
//
// 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 SecretLayer4::onChest01(SecretLayer4 *a1, cocos2d::CCObject *a2)
{
GameStatsManager *v4; // x21
GJRewardItem *v5; // x20
CCMenuItemSpriteExtra **p_m_rightChest; // x0
RewardUnlockLayer *v7; // x21
unsigned int *p_m_openLayer; // x2
int m_openLayer; // w1
RewardsPage *v10; // [xsp+40h] [xbp+40h] BYREF
a2->__vftable[13].copyWithZone(a2, nullptr);
((void (__fastcall *)(cocos2d::CCObject *, _QWORD))a2->__vftable[4].~CCObject)(a2, 0);
v4 = GameStatsManager::sharedState();
sub_D153B8((int)&v10, "0003");
v5 = GameStatsManager::unlockSpecialChest(v4);
p_m_rightChest = &v10[-1].m_rightChest;
if ( &v10[-1].m_rightChest != (CCMenuItemSpriteExtra **)&qword_124B6B0 )
{
if ( &pthread_create )
{
p_m_openLayer = (unsigned int *)&v10[-1].m_openLayer;
do
m_openLayer = __ldaxr(p_m_openLayer);
while ( __stlxr(m_openLayer - 1, p_m_openLayer) );
}
else
{
m_openLayer = (int)v10[-1].m_openLayer;
LODWORD(v10[-1].m_openLayer) = m_openLayer - 1;
}
if ( m_openLayer <= 0 )
operator delete(p_m_rightChest);
}
if ( v5 )
{
v7 = RewardUnlockLayer::create(v5->m_rewardType, nullptr);
a1->addChild_0(a1, v7, 100);
RewardUnlockLayer::showCollectReward(v7, v5);
}
}