//
// SecretRewardsLayer::onGoldChest from 0x10070f0c0 to 0x10070f326 (614 bytes)
//
// 1 xrefs:
// > SecretRewardsLayer::init @ 0x10070e082
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:36:05 +0000
//
void __fastcall SecretRewardsLayer::onGoldChest(_QWORD *a1, __m128 a2)
{
__int64 v2; // rax
int Stat; // r14d
__int64 v4; // rax
int NextGoldChestID; // r15d
const std::string::value_type *v6; // rsi
int v7; // ebx
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // r14
char *v11; // r15
__int64 v12; // r14
__int64 v13; // rax
__int64 v14; // rax
__int64 CString; // rax
__int64 v16; // rax
_OWORD *v17; // r14
__int64 v18; // rax
__int64 v19; // rax
char *v20; // rax
__int64 v21; // rbx
std::string v22; // [rsp+0h] [rbp-60h] BYREF
std::string v23; // [rsp+18h] [rbp-48h] BYREF
std::string v24; // [rsp+30h] [rbp-30h] BYREF
v2 = GameStatsManager::sharedState();
Stat = GameStatsManager::getStat(v2, "43", a2);
v4 = GameStatsManager::sharedState();
NextGoldChestID = GameStatsManager::getNextGoldChestID(v4);
if ( Stat <= 0 || NextGoldChestID == 0 )
{
*(_WORD *)&v24.__r_.__value_.__l.0 = 0;
v6 = "You need a Gold Key to unlock this chest.";
if ( !NextGoldChestID )
v6 = "All out of Gold Chests right now. Come back later.";
std::string::assign(&v24, v6);
v7 = 18;
if ( Stat >= -49 )
{
v7 = 17;
if ( Stat >= -24 )
v7 = 2 * (Stat < -9) + 2;
}
v23.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)26;
strcpy(v23.__r_.__value_.__s.__data_, "The Keymaster");
if ( (*(_BYTE *)&v24.__r_.__value_.__s.0 & 1) != 0 )
sub_10001AD30(&v22, v24.__r_.__value_.__l.__data_, v24.__r_.__value_.__l.__size_);
else
v22 = v24;
v20 = DialogObject::create(&v23, &v22, v7, 0, 0xFFFFFF, 1.0);
v21 = DialogLayer::create((__int64)v20, 2u);
if ( (*(_BYTE *)&v22.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v22.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&v23.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v23.__r_.__value_.__l.__data_);
DialogLayer::addToMainScene(v21, 2);
DialogLayer::updateChatPlacement(v21, 0);
DialogLayer::animateInRandomSide(v21);
if ( (*(_BYTE *)&v24.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v24.__r_.__value_.__l.__data_);
}
else
{
v8 = GameStatsManager::sharedState();
v9 = GameStatsManager::unlockGoldChest(v8, a2);
if ( v9 )
{
v10 = v9;
v11 = RewardUnlockLayer::create(*(_DWORD *)(v9 + 64), 0);
(*(void (__fastcall **)(_QWORD *, char *, __int64))(*a1 + 464LL))(a1, v11, 100);
RewardUnlockLayer::showCollectReward((__int64)v11, v10);
v12 = a1[60];
v13 = GameStatsManager::sharedState();
GameStatsManager::getStat(v13, "43", a2);
v14 = sub_10088E820("%i", *(_BYTE *)&v22.__r_.__value_.__l.0);
CString = cocos2d::CCString::getCString(v14);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v12 + 928LL))(v12, CString);
SecretRewardsLayer::updateUnlockedGoldLabel(a1);
v16 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::fadeMusic(v16, 0, 1.0, 1.0, 0.2);
v17 = cocos2d::CCDelayTime::create((__m128)0x404CCCCDu);
v18 = cocos2d::CCCallFunc::create(a1, SecretRewardsLayer::fadeInOutMusic, 0);
v19 = sub_10039EB60((__int64)v17, v18, 0);
cocos2d::CCNode::runAction((__int64)a1, v19);
}
}
}