//
// CreatorLayer::onTreasureRoom from 0x140138cd0 to 0x140139466 (1942 bytes)
//
// 2 xrefs:
// > CreatorLayer::init @ 0x140136795
// > ??> @ 0x1409171d4
//
// This function is hookable on this platform (idp: pc, 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 11:27:06 +0000
//
// Hidden C++ exception states: #wind=5
void __fastcall CreatorLayer::onTreasureRoom(__int64 a1)
{
__int64 v2; // rcx
int Stat; // ebx
__int64 v4; // rcx
__int64 v5; // rcx
struct cocos2d::CCScene *v6; // rax
struct cocos2d::CCScene *v7; // rbx
__int64 v8; // rcx
cocos2d::CCDirector *v9; // rax
cocos2d::CCArray *v10; // rbx
int v11; // r9d
struct cocos2d::CCObject *v12; // rax
int v13; // r9d
struct cocos2d::CCObject *v14; // rax
int v15; // r9d
struct cocos2d::CCObject *v16; // rax
_QWORD *v17; // rax
_QWORD *v18; // rsi
__int64 v19; // rdx
__int64 v20; // rcx
__int64 v21; // rax
__int64 v22; // rdi
__int64 v23; // rbx
__int64 v24; // rax
_QWORD *v25; // rcx
int v26; // r9d
int v27; // edx
const char *v28; // r8
cocos2d::CCString *v29; // rax
char *CString; // rax
size_t v31; // r8
void **v32; // rsi
unsigned __int64 v33; // rdi
__int64 v34; // rbx
__int64 v35; // rax
__int64 DialogLayer; // rsi
__int64 v37; // rcx
__int64 v38; // rax
__int64 v39; // rdi
__int64 v40; // rbx
__int64 v41; // rax
void *v42; // rcx
__int16 v43; // [rsp+30h] [rbp-49h] BYREF
char v44; // [rsp+32h] [rbp-47h]
__int128 *v45; // [rsp+40h] [rbp-39h] BYREF
__int128 v46; // [rsp+48h] [rbp-31h] BYREF
__int64 v47; // [rsp+58h] [rbp-21h]
__int64 v48; // [rsp+60h] [rbp-19h]
__int128 v49; // [rsp+68h] [rbp-11h] BYREF
__int64 v50; // [rsp+78h] [rbp-1h]
__int64 v51; // [rsp+80h] [rbp+7h]
__int128 *v52; // [rsp+88h] [rbp+Fh] BYREF
void *Src[2]; // [rsp+90h] [rbp+17h] BYREF
unsigned __int64 v54; // [rsp+A0h] [rbp+27h]
unsigned __int64 v55; // [rsp+A8h] [rbp+2Fh]
v2 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v45 = (__int128 *)operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480(v45);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v2 = qword_14090BFE0;
}
Stat = GameStatsManager::getStat(v2, &word_140737620);
v4 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v45 = (__int128 *)operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager(v45);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v4 = qword_14090BFD0;
}
if ( (unsigned __int8)GameManager::getUGV(v4, &word_14070D048) )
{
v6 = (struct cocos2d::CCScene *)SecretRewardsLayer::scene(0);
v7 = cocos2d::CCTransitionFade::create(0.5, v6);
v9 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v8);
cocos2d::CCDirector::replaceScene(v9, v7);
}
else if ( Stat < 5 )
{
*(_OWORD *)Src = 0;
v25 = sub_14003D460(0x40u);
Src[0] = v25;
v54 = 63;
v55 = 63;
strcpy((char *)v25, "Bring me 5 keys,\nand I will let you pass.");
v27 = 5 - Stat;
if ( Stat > 0 )
{
v28 = &byte_1406ED6E0;
if ( v27 > 1 )
v28 = (const char *)&unk_14070D03C;
v29 = cocos2d::CCString::createWithFormat(
"Collect %i more key%s,\nand I will let you pass.",
v27,
v28);
CString = (char *)cocos2d::CCString::getCString(v29);
v31 = -1;
do
++v31;
while ( CString[v31] );
sub_1400405A0(Src, CString, v31);
}
v52 = &v46;
v43 = -1;
v44 = -1;
v46 = 0;
v47 = 0;
v48 = 0;
v32 = Src;
if ( v55 > 0xF )
v32 = (void **)Src[0];
v33 = v54;
v34 = 0x7FFFFFFFFFFFFFFFLL;
if ( v54 > 0x7FFFFFFFFFFFFFFFLL )
sub_140009D90(v25);
if ( v54 > 0xF )
{
if ( (v54 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
v34 = v54 | 0xF;
if ( (v54 | 0xF) < 0x16 )
v34 = 22;
}
*(_QWORD *)&v46 = sub_14003D460(v34 + 1);
v47 = v33;
v48 = v34;
memcpy((void *)v46, v32, v33 + 1);
}
else
{
v47 = v54;
v48 = 15;
v46 = *(_OWORD *)v32;
}
v50 = 13;
v51 = 15;
strcpy((char *)&v49, "The Keymaster");
HIWORD(v49) = 0;
v35 = DialogObject::create((unsigned int)&v49, (unsigned int)&v46, 2, v26, 0, (__int64)&v43);
DialogLayer = DialogLayer::createDialogLayer(v35, 0, 2);
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)a1 + 456LL))(a1, DialogLayer, 100);
v38 = cocos2d::CCDirector::sharedDirector(v37);
cocos2d::CCDirector::getWinSize(v38, &v45);
v39 = **(_QWORD **)(DialogLayer + 560);
v40 = *(_QWORD *)(DialogLayer + 560);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v52, *(float *)&v45 * 0.5, *((float *)&v45 + 1) * 0.5);
(*(void (__fastcall **)(__int64, __int64))(v39 + 184))(v40, v41);
DialogLayer::animateInRandomSide(DialogLayer);
if ( v55 > 0xF )
{
v42 = Src[0];
if ( v55 + 1 >= 0x1000 )
{
v42 = *((void **)Src[0] - 1);
if ( (unsigned __int64)((char *)Src[0] - (char *)v42 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v42);
}
}
else
{
v10 = (cocos2d::CCArray *)cocos2d::CCArray::create(v5);
v45 = &v49;
v43 = -1;
v44 = -1;
v49 = 0;
v50 = 0;
v51 = 0;
*(_QWORD *)&v49 = sub_14003D460(0x30u);
v50 = 39;
v51 = 47;
strcpy((char *)v49, "Well, well, well.\nLook who it is.");
v47 = 13;
v48 = 15;
strcpy((char *)&v46, "The Keymaster");
HIWORD(v46) = 0;
v12 = (struct cocos2d::CCObject *)DialogObject::create(
(unsigned int)&v46,
(unsigned int)&v49,
2,
v11,
0,
(__int64)&v43);
cocos2d::CCArray::addObject(v10, v12);
v45 = &v49;
v43 = -1;
v44 = -1;
v49 = 0;
v50 = 0;
v51 = 0;
*(_QWORD *)&v49 = sub_14003D460(0x40u);
v50 = 59;
v51 = 63;
strcpy((char *)v49, "I see you have the keys.\nBut what comes next?");
v47 = 13;
v48 = 15;
strcpy((char *)&v46, "The Keymaster");
HIWORD(v46) = 0;
v14 = (struct cocos2d::CCObject *)DialogObject::create(
(unsigned int)&v46,
(unsigned int)&v49,
2,
v13,
0,
(__int64)&v43);
cocos2d::CCArray::addObject(v10, v14);
v45 = &v49;
v43 = -1;
v44 = -1;
v49 = 0;
v50 = 0;
v51 = 0;
*(_QWORD *)&v49 = sub_14003D460(0x50u);
v50 = 69;
v51 = 79;
strcpy((char *)v49, "The door is open.\nTime to find out...");
v47 = 13;
v48 = 15;
strcpy((char *)&v46, "The Keymaster");
HIWORD(v46) = 0;
v16 = (struct cocos2d::CCObject *)DialogObject::create(
(unsigned int)&v46,
(unsigned int)&v49,
2,
v15,
0,
(__int64)&v43);
cocos2d::CCArray::addObject(v10, v16);
v17 = (_QWORD *)DialogLayer::createDialogLayer(0, v10, 2);
v18 = v17;
v19 = a1 + 416;
if ( !a1 )
v19 = 0;
v17[78] = v19;
(*(void (__fastcall **)(_QWORD *, _QWORD))(*v17 + 64LL))(v17, 0);
(*(void (__fastcall **)(__int64, _QWORD *, __int64))(*(_QWORD *)a1 + 456LL))(a1, v18, 100);
v21 = cocos2d::CCDirector::sharedDirector(v20);
cocos2d::CCDirector::getWinSize(v21, &v45);
v22 = *(_QWORD *)v18[70];
v23 = v18[70];
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v52, *(float *)&v45 * 0.5, *((float *)&v45 + 1) * 0.5);
(*(void (__fastcall **)(__int64, __int64))(v22 + 184))(v23, v24);
DialogLayer::animateIn(v18, 2);
}
}