//
// SecretRewardsLayer::onGoldChest from 0x1002e9cf8 to 0x1002e9ef4 (508 bytes)
//
// 1 xrefs:
// > SecretRewardsLayer::init @ 0x1002e8fd4
//
// 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 SecretRewardsLayer::onGoldChest(SecretRewardsLayer *a1, cocos2d::CCObject *a2)
{
GameStatsManager *v3; // x0
int Stat; // w20
GameStatsManager *v5; // x0
int NextGoldChestID; // w0
int v7; // w21
std::string *v9; // x0
const std::string::value_type *v10; // x1
int v11; // w10
int v12; // w9
int v13; // w19
GameStatsManager *v14; // x0
GJRewardItem *v15; // x0
GJRewardItem *v16; // x20
RewardUnlockLayer *v17; // x21
cocos2d::CCLabelBMFont *m_goldKeysLabel; // x20
GameStatsManager *v19; // x0
int v20; // w0
cocos2d::CCString *v21; // x0
const char *CString; // x0
char *v23; // x0
DialogLayer *v24; // x19
void *__p[2]; // [xsp+10h] [xbp-70h] BYREF
__int64 v26; // [xsp+20h] [xbp-60h]
void *v27[2]; // [xsp+30h] [xbp-50h] BYREF
char v28; // [xsp+47h] [xbp-39h]
__int128 v29; // [xsp+48h] [xbp-38h] BYREF
__int64 v30; // [xsp+58h] [xbp-28h]
v3 = GameStatsManager::sharedState();
Stat = GameStatsManager::getStat(v3, "43");
v5 = GameStatsManager::sharedState();
NextGoldChestID = GameStatsManager::getNextGoldChestID(v5);
v7 = NextGoldChestID;
if ( Stat < 1 || NextGoldChestID == 0 )
{
v9 = (std::string *)sub_100009900(&v29, "");
if ( v7 )
v10 = "You need a Gold Key to unlock this chest.";
else
v10 = "All out of Gold Chests right now. Come back later.";
std::string::assign(v9, v10);
if ( Stat >= -9 )
v11 = 2;
else
v11 = 4;
if ( Stat >= -24 )
v12 = v11;
else
v12 = 17;
if ( Stat >= -49 )
v13 = v12;
else
v13 = 18;
sub_100009900(v27, "The Keymaster");
if ( SHIBYTE(v30) < 0 )
{
sub_1000097D0(__p, (void *)v29, *((unsigned __int64 *)&v29 + 1));
}
else
{
*(_OWORD *)__p = v29;
v26 = v30;
}
v23 = DialogObject::create((__int64)v27, (__int64)__p, v13, 0, 0xFFFFFF, 1.0);
v24 = DialogLayer::create((DialogObject *)v23, 2);
if ( SHIBYTE(v26) < 0 )
operator delete(__p[0]);
if ( v28 < 0 )
operator delete(v27[0]);
DialogLayer::addToMainScene(v24);
DialogLayer::updateChatPlacement(v24, Center);
DialogLayer::animateInRandomSide(v24);
if ( SHIBYTE(v30) < 0 )
operator delete((void *)v29);
}
else
{
v14 = GameStatsManager::sharedState();
v15 = GameStatsManager::unlockGoldChest(v14, v7);
if ( v15 )
{
v16 = v15;
v17 = RewardUnlockLayer::create(v15->m_rewardType, nullptr);
((void (__fastcall *)(SecretRewardsLayer *, RewardUnlockLayer *, __int64))a1->addChild_0)(a1, v17, 100);
RewardUnlockLayer::showCollectReward(v17, v16);
m_goldKeysLabel = a1->m_goldKeysLabel;
v19 = GameStatsManager::sharedState();
v20 = GameStatsManager::getStat(v19, "43");
v21 = (cocos2d::CCString *)sub_100268F4C("%i", v20);
CString = cocos2d::CCString::getCString(v21);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, const char *))m_goldKeysLabel->setString)(
m_goldKeysLabel,
CString);
SecretRewardsLayer::updateUnlockedGoldLabel(a1);
SecretRewardsLayer::fadeInMusic(a1);
}
}
}