//
// CreatorLayer::onTreasureRoom from 0x6cb2a8 to 0x6cb9d0 (1832 bytes)
//
// 3 xrefs:
// > ??> @ 0x4b660
// > CreatorLayer::init @ 0x6cc958
// > ??> @ 0x122a6a8
//
// 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 CreatorLayer::onTreasureRoom(CreatorLayer *a1, cocos2d::CCObject *a2)
{
GameStatsManager *v3; // x0
int Stat; // w19
GameManager *v5; // x0
_BOOL8 UGV; // x0
const char *v7; // x1
char *v8; // x2
cocos2d::CCString *v9; // x0
size_t v10; // x0
DialogObject *v11; // x0
DialogLayer *v12; // x22
void *v13; // x0
void *v14; // x0
void *v15; // x0
cocos2d::CCArray *v16; // x24
cocos2d::CCObject *v17; // x0
void *v18; // x0
void *v19; // x0
cocos2d::CCObject *v20; // x0
void *v21; // x0
void *v22; // x0
cocos2d::CCObject *v23; // x0
void *v24; // x0
void *v25; // x0
DialogLayer *v26; // x0
DialogLayer_vtbl *v27; // x2
DialogLayer *v28; // x19
cocos2d::CCDirector *v29; // x19
cocos2d::CCScene *v30; // x0
cocos2d::CCTransitionFade *v31; // x0
unsigned int *v32; // x1
int v33; // w2
unsigned int *v34; // x1
int v35; // w2
unsigned int *v36; // x1
int v37; // w2
unsigned int *v38; // x1
int v39; // w2
unsigned int *v40; // x1
int v41; // w2
unsigned int *v42; // x1
int v43; // w2
unsigned int *v44; // x1
int v45; // w2
unsigned int *v46; // x1
int v47; // w2
unsigned int *v48; // x1
int v49; // w2
_QWORD v50[2]; // [xsp+0h] [xbp+0h] BYREF
const char *CString; // [xsp+68h] [xbp+68h]
__int64 v52; // [xsp+80h] [xbp+80h] BYREF
__int64 v53; // [xsp+88h] [xbp+88h] BYREF
__int64 v54; // [xsp+90h] [xbp+90h] BYREF
cocos2d::_ccColor3B v55; // 0:w5.3
cocos2d::_ccColor3B v56; // 0:w5.3
cocos2d::_ccColor3B v57; // 0:w5.3
cocos2d::_ccColor3B v58; // 0:w5.3
v3 = GameStatsManager::sharedState();
Stat = GameStatsManager::getStat(v3, "21");
v5 = GameManager::sharedState();
UGV = GameManager::getUGV(v5, "5");
if ( UGV )
{
v29 = cocos2d::CCDirector::sharedDirector();
v30 = SecretRewardsLayer::scene(0);
v31 = cocos2d::CCTransitionFade::create(0.5, v30);
cocos2d::CCDirector::replaceScene(v29, v31);
}
else if ( Stat > 4 )
{
v16 = (cocos2d::CCArray *)cocos2d::CCArray::create((cocos2d::CCArray *)UGV);
sub_D153B8((int)&v53, "The Keymaster");
sub_D153B8((unsigned int)v50 + 144, "Well, well, well.\nLook who it is.");
v17 = (cocos2d::CCObject *)DialogObject::create(
(DialogObject *)&v53,
(std::string)&v54,
(std::string)2LL,
0,
1.0,
(bool)&unk_FFFFFF,
v56);
cocos2d::CCArray::addObject(v16, v17);
v18 = (void *)(v54 - 24);
if ( (__int64 *)(v54 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v46 = (unsigned int *)(v54 - 8);
do
v47 = __ldaxr(v46);
while ( __stlxr(v47 - 1, v46) );
}
else
{
v47 = *(_DWORD *)(v54 - 8);
*(_DWORD *)(v54 - 8) = v47 - 1;
}
if ( v47 <= 0 )
operator delete(v18);
}
v19 = (void *)(v53 - 24);
if ( (__int64 *)(v53 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v36 = (unsigned int *)(v53 - 8);
do
v37 = __ldaxr(v36);
while ( __stlxr(v37 - 1, v36) );
}
else
{
v37 = *(_DWORD *)(v53 - 8);
*(_DWORD *)(v53 - 8) = v37 - 1;
}
if ( v37 <= 0 )
operator delete(v19);
}
sub_D153B8((unsigned int)v50 + 136, "The Keymaster");
sub_D153B8((unsigned int)v50 + 144, "I see you have the keys.\nBut what comes next?");
v20 = (cocos2d::CCObject *)DialogObject::create(
(DialogObject *)&v53,
(std::string)&v54,
(std::string)2LL,
0,
1.0,
(bool)&unk_FFFFFF,
v57);
cocos2d::CCArray::addObject(v16, v20);
v21 = (void *)(v54 - 24);
if ( (__int64 *)(v54 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v44 = (unsigned int *)(v54 - 8);
do
v45 = __ldaxr(v44);
while ( __stlxr(v45 - 1, v44) );
}
else
{
v45 = *(_DWORD *)(v54 - 8);
*(_DWORD *)(v54 - 8) = v45 - 1;
}
if ( v45 <= 0 )
operator delete(v21);
}
v22 = (void *)(v53 - 24);
if ( (__int64 *)(v53 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v40 = (unsigned int *)(v53 - 8);
do
v41 = __ldaxr(v40);
while ( __stlxr(v41 - 1, v40) );
}
else
{
v41 = *(_DWORD *)(v53 - 8);
*(_DWORD *)(v53 - 8) = v41 - 1;
}
if ( v41 <= 0 )
operator delete(v22);
}
sub_D153B8((unsigned int)v50 + 136, "The Keymaster");
sub_D153B8((unsigned int)v50 + 144, "The door is open.\nTime to find out...");
v23 = (cocos2d::CCObject *)DialogObject::create(
(DialogObject *)&v53,
(std::string)&v54,
(std::string)2LL,
0,
1.0,
(bool)&unk_FFFFFF,
v58);
cocos2d::CCArray::addObject(v16, v23);
v24 = (void *)(v54 - 24);
if ( (__int64 *)(v54 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v48 = (unsigned int *)(v54 - 8);
do
v49 = __ldaxr(v48);
while ( __stlxr(v49 - 1, v48) );
}
else
{
v49 = *(_DWORD *)(v54 - 8);
*(_DWORD *)(v54 - 8) = v49 - 1;
}
if ( v49 <= 0 )
operator delete(v24);
}
v25 = (void *)(v53 - 24);
if ( (__int64 *)(v53 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v32 = (unsigned int *)(v53 - 8);
do
v33 = __ldaxr(v32);
while ( __stlxr(v33 - 1, v32) );
}
else
{
v33 = *(_DWORD *)(v53 - 8);
*(_DWORD *)(v53 - 8) = v33 - 1;
}
if ( v33 <= 0 )
operator delete(v25);
}
v26 = DialogLayer::createWithObjects(v16, (int)&dword_0 + 2);
v27 = v26->cocos2d::CCLayerColor::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v26->m_delegate = &a1->DialogDelegate;
v28 = v26;
v27->setTag(v26, 0);
a1->addChild_0(a1, v28, 100);
DialogLayer::updateChatPlacement(v28, Center);
DialogLayer::animateIn(v28, FromLeft);
}
else
{
sub_D153B8((int)&v52, "Bring me 5 keys,\nand I will let you pass.");
v7 = (const char *)(unsigned int)(5 - Stat);
if ( Stat > 0 )
{
if ( (_DWORD)v7 == 1 )
v8 = &byte_F288A0;
else
v8 = "s";
v9 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Collect %i more key%s,\n"
"and I will let you pass.",
v7,
v8);
CString = cocos2d::CCString::getCString(v9);
v10 = strlen(CString);
sub_D1798C(&v52, CString, v10);
}
sub_D153B8((int)&v53, "The Keymaster");
sub_D18D28(&v54, &v52);
v11 = (DialogObject *)DialogObject::create(
(DialogObject *)&v53,
(std::string)&v54,
(std::string)2LL,
0,
1.0,
(bool)&unk_FFFFFF,
v55);
v12 = DialogLayer::create(v11, (int)&dword_0 + 2);
v13 = (void *)(v54 - 24);
if ( (__int64 *)(v54 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v34 = (unsigned int *)(v54 - 8);
do
v35 = __ldaxr(v34);
while ( __stlxr(v35 - 1, v34) );
}
else
{
v35 = *(_DWORD *)(v54 - 8);
*(_DWORD *)(v54 - 8) = v35 - 1;
}
if ( v35 <= 0 )
operator delete(v13);
}
v14 = (void *)(v53 - 24);
if ( (__int64 *)(v53 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v42 = (unsigned int *)(v53 - 8);
do
v43 = __ldaxr(v42);
while ( __stlxr(v43 - 1, v42) );
}
else
{
v43 = *(_DWORD *)(v53 - 8);
*(_DWORD *)(v53 - 8) = v43 - 1;
}
if ( v43 <= 0 )
operator delete(v14);
}
a1->addChild_0(a1, v12, 100);
DialogLayer::updateChatPlacement(v12, Center);
DialogLayer::animateInRandomSide(v12);
v15 = (void *)(v52 - 24);
if ( (__int64 *)(v52 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v38 = (unsigned int *)(v52 - 8);
do
v39 = __ldaxr(v38);
while ( __stlxr(v39 - 1, v38) );
}
else
{
v39 = *(_DWORD *)(v52 - 8);
*(_DWORD *)(v52 - 8) = v39 - 1;
}
if ( v39 <= 0 )
operator delete(v15);
}
}
}