//
// SecretRewardsLayer::onSpecialItem from 0x5858bc to 0x585a56 (410 bytes)
//
// 1 xrefs:
// > SecretRewardsLayer::onChestType @ 0x58a2cc
//
// 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 SecretRewardsLayer::onSpecialItem(SecretRewardsLayer *a1, cocos2d::CCObject *a2)
{
int v4; // r0
int v5; // r0
int v6; // r5
GameStatsManager *v7; // r0
cocos2d::CCArray *v8; // r0
cocos2d::CCArray *v9; // r11
cocos2d::CCArray *v10; // r10
const char *v11; // r5
const char *v12; // r2
cocos2d::CCString *v13; // r0
char *CString; // r0
cocos2d::CCObject *v15; // r0
DialogLayer *v16; // r5
int *v17; // r5
GJRewardItem *v18; // r5
RewardUnlockLayer *v19; // r7
int v20; // [sp+4h] [bp-20h]
void *v21; // [sp+Ch] [bp-18h] BYREF
char v22; // [sp+10h] [bp-14h] BYREF
_BYTE v23[4]; // [sp+14h] [bp-10h] BYREF
_BYTE v24[4]; // [sp+18h] [bp-Ch] BYREF
v4 = a2->getTag(a2);
v21 = &unk_ACDDA8;
v5 = v4 - 5;
switch ( v5 )
{
case 2:
sub_7753D4((int)&v21, "0005");
v6 = 100;
break;
case 3:
sub_7753D4((int)&v21, "0006");
v6 = 200;
break;
case 1:
sub_7753D4((int)&v21, "0004");
v6 = 50;
break;
default:
goto LABEL_14;
}
v7 = GameStatsManager::sharedState();
v8 = (cocos2d::CCArray *)cocos2d::CCDictionary::count(v7->m_treasureRoomChests);
v9 = v8;
if ( (int)v8 >= v6 )
{
v17 = (int *)GameStatsManager::sharedState();
sub_775C20(v24);
v18 = GameStatsManager::unlockSpecialChest(v17, (stl::StringData::Internal *)v24);
sub_774008(v24);
if ( v18 )
{
SecretRewardsLayer::switchToOpenedState(a1, (CCMenuItemSpriteExtra *)a2);
v19 = RewardUnlockLayer::create(v18->m_rewardType, nullptr);
a1->addChild_0(a1, v19, 100);
RewardUnlockLayer::showCollectReward(v19, v18);
}
}
else
{
v10 = (cocos2d::CCArray *)cocos2d::CCArray::create(v8);
v11 = (const char *)(v6 - (_DWORD)v9);
sub_776584((int)&v22, "The Keymaster");
if ( v11 == (_BYTE *)&dword_0 + 1 )
v12 = "Chest";
else
v12 = "Chests";
v13 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Unlock %i more %s, and you can collect this bonus.",
v11,
v12);
CString = (char *)cocos2d::CCString::getCString(v13);
sub_776584((int)v23, CString);
LOWORD(v20) = -1;
BYTE2(v20) = -1;
v15 = (cocos2d::CCObject *)DialogObject::create(
(DialogObject *)&v22,
(std::string)v23,
(std::string)2,
1065353216,
0.0,
v20);
cocos2d::CCArray::addObject(v10, v15);
sub_774008(v23);
sub_774008(&v22);
v16 = DialogLayer::createWithObjects(v10, (int)&dword_0 + 2);
a1->addChild_0(a1, v16, 100);
DialogLayer::updateChatPlacement(v16, Center);
DialogLayer::animateInRandomSide(v16);
}
LABEL_14:
sub_774008(&v21);
}