//
// CreatorLayer::onTreasureRoom from 0x14009eda0 to 0x14009f612 (2162 bytes)
//
// 2 xrefs:
// > CreatorLayer::init @ 0x14009d015
// > ??> @ 0x1406c7638
//
// 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
//
// Hidden C++ exception states: #wind=5
void CreatorLayer::onTreasureRoom(CreatorLayer *a1, cocos2d::CCObject *a2)
{
GameStatsManager *v3; // rcx
int Stat; // ebx
GameManager *v5; // rcx
__int64 v6; // rcx
struct cocos2d::CCScene *v7; // rax
struct cocos2d::CCTransitionFade *v8; // rbx
__int64 v9; // rcx
cocos2d::CCDirector *v10; // rax
cocos2d::CCArray *v11; // rbx
int v12; // r9d
struct cocos2d::CCObject *v13; // rax
int v14; // r9d
struct cocos2d::CCObject *v15; // rax
int v16; // r9d
struct cocos2d::CCObject *v17; // rax
DialogLayer *v18; // rax
DialogLayer *v19; // rdi
DialogDelegate *v20; // rdx
__int64 v21; // rcx
cocos2d::CCDirector *v22; // rax
cocos2d::CCLayer_vtbl *v23; // rbx
const cocos2d::CCPoint *v24; // rax
_BOOL8 v25; // rdx
float v26; // xmm1_4
const struct cocos2d::CCPoint *v27; // rax
cocos2d::CCLayer_vtbl *v28; // rbx
const cocos2d::CCPoint *v29; // rax
struct cocos2d::CCMoveTo *v30; // rax
struct cocos2d::CCEaseElasticOut *v31; // rax
cocos2d::ccColor3B *v32; // r8
float v33; // xmm6_4
struct cocos2d::CCFadeTo *v34; // rax
cocos2d::ccColor3B *v35; // r8
__int64 v36; // rcx
char *v37; // rsi
__int64 v38; // r8
__int64 v39; // r9
unsigned __int64 v40; // rdi
unsigned __int64 v41; // r14
__int64 v42; // rdx
const char *v43; // r8
cocos2d::CCString *v44; // rax
char *CString; // rax
size_t v46; // r8
char *v47; // r15
__int64 v48; // rbx
DialogObject *v49; // rax
DialogLayer *DialogLayer; // rdi
__int64 v51; // rcx
cocos2d::CCDirector *v52; // rax
cocos2d::CCLayer_vtbl *v53; // rbx
const cocos2d::CCPoint *v54; // rax
char *v55; // rax
float v56; // [rsp+28h] [rbp-79h]
float v57; // [rsp+28h] [rbp-79h]
__int16 v58; // [rsp+38h] [rbp-69h] BYREF
char v59; // [rsp+3Ah] [rbp-67h]
__int128 *v60; // [rsp+48h] [rbp-59h] BYREF
__int128 v61; // [rsp+50h] [rbp-51h] BYREF
__int64 v62; // [rsp+60h] [rbp-41h]
__int64 v63; // [rsp+68h] [rbp-39h]
__int128 v64; // [rsp+70h] [rbp-31h] BYREF
__int64 v65; // [rsp+80h] [rbp-21h]
__int64 v66; // [rsp+88h] [rbp-19h]
__int128 *v67; // [rsp+90h] [rbp-11h] BYREF
__int128 v68; // [rsp+98h] [rbp-9h] BYREF
__int64 v69; // [rsp+A8h] [rbp+7h]
__int64 v70; // [rsp+B0h] [rbp+Fh]
v3 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v60 = (__int128 *)operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0(v60);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v3 = (GameStatsManager *)qword_1406C2EE8;
}
Stat = GameStatsManager::getStat(v3, (const char *)&word_140543238);
v5 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v60 = (__int128 *)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v60);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v5 = (GameManager *)qword_1406C2ED8;
}
if ( GameManager::getUGV(v5, (const char *)&word_140531E90) )
{
v7 = SecretRewardsLayer::scene(0);
v8 = cocos2d::CCTransitionFade::create(0.5, v7);
v10 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v9);
cocos2d::CCDirector::replaceScene(v10, v8);
}
else if ( Stat < 5 )
{
v68 = 0;
v37 = (char *)sub_14003AA10(0x40u);
*(_QWORD *)&v68 = v37;
v40 = 63;
v69 = 63;
v41 = 63;
v70 = 63;
strcpy(v37, "Bring me 5 keys,\nand I will let you pass.");
v42 = (unsigned int)(5 - Stat);
if ( Stat > 0 )
{
v43 = byte_140518980;
if ( (int)v42 > 1 )
v43 = "s";
v44 = cocos2d::CCString::createWithFormat(
"Collect %i more key%s,\nand I will let you pass.",
v42,
v43);
CString = (char *)cocos2d::CCString::getCString(v44);
v46 = -1;
do
++v46;
while ( CString[v46] );
sub_14003CCE0((void **)&v68, CString, v46);
v41 = v70;
v40 = v69;
v37 = (char *)v68;
}
v67 = &v61;
v58 = -1;
v59 = -1;
v61 = 0;
v62 = 0;
v63 = 0;
v47 = (char *)&v68;
if ( v41 > 0xF )
v47 = v37;
v48 = 0x7FFFFFFFFFFFFFFFLL;
if ( v40 > 0x7FFFFFFFFFFFFFFFLL )
sub_140007B50(v36, v42, v38, v39);
v63 = 15;
if ( v40 > 0xF )
{
if ( (v40 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
v48 = v40 | 0xF;
if ( (v40 | 0xF) < 0x16 )
v48 = 22;
}
*(_QWORD *)&v61 = sub_14003AA10(v48 + 1);
v62 = v40;
v63 = v48;
memcpy((void *)v61, v47, v40 + 1);
}
else
{
v62 = v40;
v61 = *(_OWORD *)v47;
}
v65 = 13;
v66 = 15;
strcpy((char *)&v64, "The Keymaster");
HIWORD(v64) = 0;
v49 = (DialogObject *)DialogObject::create((unsigned int)&v64, (unsigned int)&v61, 2, v39, 0, (__int64)&v58);
DialogLayer = DialogLayer::createDialogLayer(v49, nullptr, 2);
a1->addChild_0(a1, DialogLayer, 100);
v52 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v51);
cocos2d::CCDirector::getWinSize(v52);
v53 = DialogLayer->m_mainLayer->__vftable;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v67, *(float *)&v60 * 0.5, *((float *)&v60 + 1) * 0.5);
v53->setPosition_0(DialogLayer->m_mainLayer, v54);
DialogLayer::animateInRandomSide(DialogLayer);
if ( v41 > 0xF )
{
v55 = v37;
if ( v41 + 1 >= 0x1000 )
{
v37 = *((char **)v37 - 1);
if ( (unsigned __int64)(v55 - v37 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v37);
}
}
else
{
v11 = (cocos2d::CCArray *)cocos2d::CCArray::create(v6);
v60 = &v64;
v58 = -1;
v59 = -1;
v64 = 0;
v65 = 0;
v66 = 15;
*(_QWORD *)&v64 = sub_14003AA10(0x30u);
v65 = 39;
v66 = 47;
strcpy((char *)v64, "Well, well, well.\nLook who it is.");
v62 = 13;
v63 = 15;
strcpy((char *)&v61, "The Keymaster");
HIWORD(v61) = 0;
v13 = (struct cocos2d::CCObject *)DialogObject::create(
(unsigned int)&v61,
(unsigned int)&v64,
2,
v12,
0,
(__int64)&v58);
cocos2d::CCArray::addObject(v11, v13);
v60 = &v64;
v58 = -1;
v59 = -1;
v64 = 0;
v65 = 0;
v66 = 15;
*(_QWORD *)&v64 = sub_14003AA10(0x40u);
v65 = 59;
v66 = 63;
strcpy((char *)v64, "I see you have the keys.\nBut what comes next?");
v62 = 13;
v63 = 15;
strcpy((char *)&v61, "The Keymaster");
HIWORD(v61) = 0;
v15 = (struct cocos2d::CCObject *)DialogObject::create(
(unsigned int)&v61,
(unsigned int)&v64,
2,
v14,
0,
(__int64)&v58);
cocos2d::CCArray::addObject(v11, v15);
v60 = &v64;
v58 = -1;
v59 = -1;
v64 = 0;
v65 = 0;
v66 = 15;
*(_QWORD *)&v64 = sub_14003AA10(0x50u);
v65 = 69;
v66 = 79;
strcpy((char *)v64, "The door is open.\nTime to find out...");
v62 = 13;
v63 = 15;
strcpy((char *)&v61, "The Keymaster");
HIWORD(v61) = 0;
v17 = (struct cocos2d::CCObject *)DialogObject::create(
(unsigned int)&v61,
(unsigned int)&v64,
2,
v16,
0,
(__int64)&v58);
cocos2d::CCArray::addObject(v11, v17);
v18 = DialogLayer::createDialogLayer(nullptr, v11, 2);
v19 = v18;
v20 = &a1->DialogDelegate;
if ( !a1 )
v20 = nullptr;
v18->m_delegate = v20;
v18->setTag(v18, 0);
a1->addChild_0(a1, v19, 100);
v22 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v21);
cocos2d::CCDirector::getWinSize(v22);
v23 = v19->m_mainLayer->__vftable;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v67, *(float *)&v60 * 0.5, *((float *)&v60 + 1) * 0.5);
v23->setPosition_0(v19->m_mainLayer, v24);
LOBYTE(v25) = 1;
v19->setVisible(v19, v25);
v26 = sub_14003CF30();
v19->m_animateTime = v26;
v27 = v19->m_mainLayer->getPosition_0(v19->m_mainLayer);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v60, v27);
v28 = v19->m_mainLayer->__vftable;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v67, -191.0, *((float *)&v60 + 1));
v28->setPosition_0(v19->m_mainLayer, v29);
v30 = cocos2d::CCMoveTo::create(0.5, (const struct cocos2d::CCPoint *)&v60);
v31 = cocos2d::CCEaseElasticOut::create(v30, 0.60000002);
cocos2d::CCNode::runAction((CCLightFlash *)v19->m_mainLayer, (cocos2d::CCPoint)v31, v32, 1.0, v56);
v33 = (float)v19->getOpacity(&v19->cocos2d::CCRGBAProtocol);
if ( v33 > 0.0 )
{
v19->setOpacity(&v19->cocos2d::CCRGBAProtocol, 0);
v34 = cocos2d::CCFadeTo::create(0.14, (int)v33);
cocos2d::CCNode::runAction((CCLightFlash *)v19, (cocos2d::CCPoint)v34, v35, 1.0, v57);
}
}
}