//
// SecretLayer3::onChest01 from 0x93abc8 to 0x93ad3c (372 bytes)
//
// 3 xrefs:
// > ??> @ 0xb4d50
// > SecretLayer3::init @ 0x945844
// > ??> @ 0x122e478
//
// 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 SecretLayer3::onChest01(SecretLayer3 *a1, cocos2d::CCObject *a2)
{
GameStatsManager *v4; // x21
GJRewardItem *v5; // x21
CCMenuItemSpriteExtra **p_m_rightChest; // x0
RewardUnlockLayer *v7; // x22
unsigned int *p_m_openLayer; // x2
int m_openLayer; // w1
RewardsPage *v10; // [xsp+40h] [xbp+40h] BYREF
if ( !a1->m_lockInput )
{
a2->__vftable[13].copyWithZone(a2, nullptr);
((void (__fastcall *)(cocos2d::CCObject *, _QWORD))a2->__vftable[4].~CCObject)(a2, 0);
v4 = GameStatsManager::sharedState();
sub_D153B8((int)&v10, "0001");
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);
}
}
}