//
// CreatorLayer::onTreasureRoom from 0x7dc61c to 0x7dcad4 (1208 bytes)
//
// 3 xrefs:
// > ??> @ 0x6a078
// > CreatorLayer::init @ 0x7dd1dc
// > ??> @ 0x15429c0
//
// This function is hookable on this platform (idp: arm, 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:54:24 +0000
//
__int64 __fastcall CreatorLayer::onTreasureRoom(CreatorLayer *this, cocos2d::CCObject *a2)
{
GameStatsManager *v3; // x0
GameManager *Stat; // x0
int v5; // w20
GameManager *v6; // x0
cocos2d::CCDirector *UGV; // x0
const char *v8; // x1
char *v9; // x2
cocos2d::CCString *v10; // x0
char *CString; // x0
DialogLayer *v12; // x0
int v13; // w2
DialogLayer *v14; // x20
cocos2d::CCArray *v16; // x23
cocos2d::CCObject *v17; // x0
cocos2d::CCObject *v18; // x0
cocos2d::CCObject *v19; // x0
int v20; // w2
_QWORD *v21; // x0
__int64 v22; // x2
_QWORD *v23; // x20
cocos2d::CCDirector *v24; // x20
bool v25; // w1
cocos2d::CCTransitionFade *v26; // x0
cocos2d::CCScene *v27; // x1
cocos2d::CCScene *v28; // x0
__int64 v29; // [xsp+50h] [xbp+50h] BYREF
size_t v30; // [xsp+58h] [xbp+58h]
void *v31; // [xsp+60h] [xbp+60h]
__int64 v32; // [xsp+68h] [xbp+68h] BYREF
__int64 v33; // [xsp+70h] [xbp+70h]
void *v34; // [xsp+78h] [xbp+78h]
__int64 v35; // [xsp+80h] [xbp+80h] BYREF
size_t v36; // [xsp+88h] [xbp+88h]
void *v37; // [xsp+90h] [xbp+90h]
v3 = (GameStatsManager *)GameStatsManager::sharedState(_stack_chk_guard);
Stat = (GameManager *)GameStatsManager::getStat(v3, "21");
v5 = (int)Stat;
v6 = (GameManager *)GameManager::sharedState(Stat);
UGV = (cocos2d::CCDirector *)(unsigned __int8)GameManager::getUGV(v6, "5");
if ( (_BYTE)UGV )
{
v24 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(UGV);
v26 = (cocos2d::CCTransitionFade *)SecretRewardsLayer::scene(nullptr, v25);
v28 = (cocos2d::CCScene *)cocos2d::CCTransitionFade::create(v26, 0.5, v27);
cocos2d::CCDirector::replaceScene(v24, v28);
}
else if ( v5 > 4 )
{
v16 = (cocos2d::CCArray *)cocos2d::CCArray::create(UGV);
v32 = 0;
v33 = 0;
v34 = nullptr;
std::string::__init(&v32, "The Keymaster", 0xDu);
v35 = 0;
v36 = 0;
v37 = nullptr;
std::string::__init(&v35, "Well, well, well.\nLook who it is.", 0x27u);
v17 = (cocos2d::CCObject *)DialogObject::create(&v32, &v35, 2, 0, 0xFFFFFF, 1.0);
cocos2d::CCArray::addObject(v16, v17);
if ( (v35 & 1) != 0 )
operator delete(v37);
if ( (v32 & 1) != 0 )
operator delete(v34);
v32 = 0;
v33 = 0;
v34 = nullptr;
std::string::__init(&v32, "The Keymaster", 0xDu);
v35 = 0;
v36 = 0;
v37 = nullptr;
std::string::__init(&v35, "I see you have the keys.\nBut what comes next?", 0x3Bu);
v18 = (cocos2d::CCObject *)DialogObject::create(&v32, &v35, 2, 0, 0xFFFFFF, 1.0);
cocos2d::CCArray::addObject(v16, v18);
if ( (v35 & 1) != 0 )
operator delete(v37);
if ( (v32 & 1) != 0 )
operator delete(v34);
v32 = 0;
v33 = 0;
v34 = nullptr;
std::string::__init(&v32, "The Keymaster", 0xDu);
v35 = 0;
v36 = 0;
v37 = nullptr;
std::string::__init(&v35, "The door is open.\nTime to find out...", 0x45u);
v19 = (cocos2d::CCObject *)DialogObject::create(&v32, &v35, 2, 0, 0xFFFFFF, 1.0);
cocos2d::CCArray::addObject(v16, v19);
if ( (v35 & 1) != 0 )
operator delete(v37);
if ( (v32 & 1) != 0 )
operator delete(v34);
v21 = (_QWORD *)DialogLayer::createWithObjects(v16, (cocos2d::CCArray *)((char *)&dword_0 + 2), v20);
v22 = *v21;
v21[78] = (char *)this + 416;
v23 = v21;
(*(void (__fastcall **)(_QWORD *, _QWORD))(v22 + 72))(v21, 0);
(*(void (__fastcall **)(CreatorLayer *, _QWORD *, __int64))(*(_QWORD *)this + 464LL))(this, v23, 100);
DialogLayer::updateChatPlacement(v23, 0);
DialogLayer::animateIn(v23, 2);
}
else
{
v29 = 0;
v30 = 0;
v31 = nullptr;
std::string::__init(&v29, "Bring me 5 keys,\nand I will let you pass.", 0x3Fu);
v8 = (const char *)(unsigned int)(5 - v5);
if ( v5 > 0 )
{
if ( (_DWORD)v8 == 1 )
v9 = &byte_11B8890;
else
v9 = "s";
v10 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Collect %i more key%s,\n"
"and I will let you pass.",
v8,
v9);
CString = (char *)cocos2d::CCString::getCString(v10);
std::string::assign(&v29, CString);
}
v32 = 0;
v33 = 0;
v34 = nullptr;
std::string::__init(&v32, "The Keymaster", 0xDu);
v35 = 0;
v36 = 0;
v37 = nullptr;
if ( (v29 & 1) != 0 )
{
std::string::__init(&v35, v31, v30);
}
else
{
v35 = v29;
v36 = v30;
v37 = v31;
}
v12 = (DialogLayer *)DialogObject::create(&v32, &v35, 2, 0, 0xFFFFFF, 1.0);
v14 = (DialogLayer *)DialogLayer::create(v12, (DialogObject *)((char *)&dword_0 + 2), v13);
if ( (v35 & 1) != 0 )
operator delete(v37);
if ( (v32 & 1) != 0 )
operator delete(v34);
(*(void (__fastcall **)(CreatorLayer *, DialogLayer *, __int64))(*(_QWORD *)this + 464LL))(this, v14, 100);
DialogLayer::updateChatPlacement(v14, 0);
DialogLayer::animateInRandomSide(v14);
if ( (v29 & 1) != 0 )
operator delete(v31);
}
return _stack_chk_guard;
}