//
// SecretRewardsLayer::createSecondaryLayer from 0x1403d52e0 to 0x1403d572a (1098 bytes)
//
// 2 xrefs:
// > SecretRewardsLayer::onChestType @ 0x1403d5118
// > ??> @ 0x1406d7d24
//
// 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::createSecondaryLayer(SecretRewardsLayer *a1, int a2)
{
cocos2d::CCLayer *m_secondaryLayer; // rcx
cocos2d::CCDirector *v5; // rax
cocos2d::CCLayer *v6; // rax
SecretRewardsLayer_vtbl *v7; // r8
struct cocos2d::CCRect *v8; // rax
struct cocos2d::extension::CCScale9Sprite *v9; // rax
__int64 v10; // rdx
_QWORD *v11; // rdi
float v12; // xmm0_4
__int64 v13; // rbx
__int64 v14; // rax
void (__fastcall **v15)(__int64, const cocos2d::ccColor3B *); // rbx
const cocos2d::ccColor3B *v16; // rax
int i; // esi
struct cocos2d::CCSprite *v18; // rdi
float v19; // xmm0_4
cocos2d::CCSprite_vtbl *v20; // rbx
const cocos2d::CCPoint *v21; // rax
cocos2d::CCSprite_vtbl *v22; // rbx
const cocos2d::CCPoint *v23; // rax
__int64 v24; // rdx
cocos2d::CCLabelBMFont *v25; // rax
cocos2d::CCLayer *v26; // rcx
cocos2d::CCLabelBMFont_vtbl *v27; // rbx
const cocos2d::CCPoint *v28; // rax
cocos2d::CCArray *ChestItems; // rax
int v30; // edx
BoomScrollLayer *v31; // rax
cocos2d::CCLayer *v32; // rcx
__int64 v33; // rcx
cocos2d::CCDirector *v34; // rax
float ScreenBottom; // xmm0_4
BoomScrollLayer *m_secondaryScrollLayer; // rbx
__int64 v37; // rax
__int64 v38; // rcx
cocos2d::CCDirector *v39; // rax
float ScreenTop; // xmm6_4
__int64 v41; // rcx
cocos2d::CCDirector *v42; // rax
float ScreenRight; // xmm0_4
__int64 v44; // rax
cocos2d::CCRect v45; // [rsp+30h] [rbp-68h] BYREF
float v46; // [rsp+A0h] [rbp+8h]
float v47; // [rsp+A4h] [rbp+Ch]
cocos2d::CCSize v48; // [rsp+B0h] [rbp+18h] BYREF
m_secondaryLayer = a1->m_secondaryLayer;
if ( m_secondaryLayer )
{
a1->m_secondaryScrollLayer = nullptr;
a1->m_chestCounter = nullptr;
m_secondaryLayer->removeFromParent(m_secondaryLayer);
a1->m_secondaryLayer = nullptr;
}
v5 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(m_secondaryLayer);
cocos2d::CCDirector::getWinSize(v5);
v6 = (cocos2d::CCLayer *)cocos2d::CCLayer::create();
v7 = a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_secondaryLayer = v6;
v7->addChild_1(a1, v6);
cocos2d::CCRect::CCRect(&v45, 0.0, 0.0, 80.0, 80.0);
v9 = cocos2d::extension::CCScale9Sprite::create("GJ_square05.png", v8);
LOBYTE(v10) = 75;
v11 = &v9->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v9->setOpacity(&v9->cocos2d::CCRGBAProtocol, v10);
cocos2d::CCSize::CCSize(&v48, 370.0, 255.0);
(*(void (__fastcall **)(_QWORD *, cocos2d::CCSize *))(*v11 + 296LL))(v11, &v48);
v12 = ((float (__fastcall *)(cocos2d::CCLayer *, _QWORD *, __int64))a1->m_secondaryLayer->addChild_0)(
a1->m_secondaryLayer,
v11,
0xFFFFFFFFLL);
v13 = *v11;
cocos2d::CCPoint::CCPoint(v12, v46 * 0.5);
(*(void (__fastcall **)(_QWORD *, __int64))(v13 + 184))(v11, v14);
v15 = (void (__fastcall **)(__int64, const cocos2d::ccColor3B *))v11[40];
v16 = a1->m_backgroundSprite->getColor(&a1->m_backgroundSprite->cocos2d::CCRGBAProtocol);
(*v15)((__int64)(v11 + 40), v16);
for ( i = 0; i < 2; ++i )
{
v18 = cocos2d::CCSprite::createWithSpriteFrameName("chain_01_001.png");
v19 = ((float (__fastcall *)(cocos2d::CCLayer *, struct cocos2d::CCSprite *, __int64))a1->m_secondaryLayer->addChild_0)(
a1->m_secondaryLayer,
v18,
0xFFFFFFFFLL);
v20 = v18->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v19, 0.5);
v20->setAnchorPoint(v18, v21);
v22 = v18->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(
(float)(v46 * 0.5) - 100.0,
(float)((float)((float)i * 100.0) + (float)((float)i * 100.0)) + (float)((float)(v46 * 0.5) - 100.0));
v22->setPosition_0(v18, v23);
v18->setColor(&v18->cocos2d::CCRGBAProtocol, &stru_140529BE8);
LOBYTE(v24) = 75;
v18->setOpacity(&v18->cocos2d::CCRGBAProtocol, v24);
}
v25 = cocos2d::CCLabelBMFont::create(" ", "goldFont.fnt");
v26 = a1->m_secondaryLayer;
a1->m_chestCounter = v25;
v26->addChild_1(v26, v25);
((void (__fastcall *)(cocos2d::CCLabelBMFont *))a1->m_chestCounter->setScale_0)(a1->m_chestCounter);
v27 = a1->m_chestCounter->__vftable;
cocos2d::CCPoint::CCPoint(v47 * 0.5, v46 * 0.5);
v27->setPosition_0(a1->m_chestCounter, v28);
SecretRewardsLayer::updateUnlockedLabel(a1);
ChestItems = SecretRewardsLayer::generateChestItems(a1, a2);
v31 = BoomScrollLayer::create(ChestItems, v30, a2 <= 5, nullptr, nullptr);
v32 = a1->m_secondaryLayer;
a1->m_secondaryScrollLayer = v31;
v32->addChild_1(v32, v31);
v34 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v33);
ScreenBottom = cocos2d::CCDirector::getScreenBottom(v34);
cocos2d::CCPoint::CCPoint(ScreenBottom + 10.0, v46 * 0.5);
m_secondaryScrollLayer = a1->m_secondaryScrollLayer;
cocos2d::CCPoint::operator=(&m_secondaryScrollLayer->m_dotPosition, v37);
BoomScrollLayer::updateDots(m_secondaryScrollLayer, 0.0);
a1->m_secondaryScrollLayer->m_unkFloat2 = 0.89999998;
a1->m_secondaryScrollLayer->m_doVisit = 1;
v39 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v38);
ScreenTop = cocos2d::CCDirector::getScreenTop(v39);
v42 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v41);
ScreenRight = cocos2d::CCDirector::getScreenRight(v42);
cocos2d::CCRect::CCRect(&v45, 0.0, 0.0, ScreenRight, ScreenTop);
cocos2d::CCRect::operator=(&a1->m_secondaryScrollLayer->m_clippingRect, v44);
}