//
// SecretLayer3::onClick from 0x1004a4d90 to 0x1004a5a9c (3340 bytes)
//
// 3 xrefs:
// > SecretLayer3::init @ 0x1004a435a
// > SecretLayer3::init @ 0x1004a43fe
// > SecretLayer3::init @ 0x1004a449d
//
// 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 __fastcall SecretLayer3::onClick(SecretLayer3 *a1, cocos2d::CCObject *a2)
{
double v2; // xmm0_8
__m128 v3; // xmm2
__m128 v4; // xmm3
int v6; // r12d
cocos2d::CCArray *v7; // r14
GameManager *v8; // rax
GameStatsManager *v9; // rax
unsigned int v10; // ebx
const char *v11; // r14
GameStatsManager *v12; // rax
GameStatsManager *v13; // rax
GameManager *v14; // rax
FMODAudioEngine *v15; // rax
FMODAudioEngine *v16; // rax
const cocos2d::CCPoint *v17; // r12
cocos2d::CCParticleSystemQuad *v18; // r15
__m128 v19; // xmm0
CCCircleWave *v20; // r15
CCCircleWave *v21; // r15
GameManager *v22; // rax
_BOOL4 UGV; // ebx
GameManager *v24; // rax
int v25; // r14d
GameManager *v26; // rax
void (__fastcall *v27)(SecretLayer3 *); // r14
float v28; // xmm0_4
cocos2d::CCDelayTime *v29; // r15
cocos2d::CCCallFunc *v30; // rax
cocos2d::CCSequence *v31; // rax
char *v32; // rax
char *v33; // rax
char *v34; // rax
void *v35; // rdi
char *v36; // rax
char *v37; // rax
char *v38; // rax
char *v39; // rax
char *v40; // rax
GameManager *v41; // rax
char *v42; // rax
char *v43; // rax
char *v44; // rax
DialogLayer *v45; // r14
cocos2d::CCNode v46; // [rsp+0h] [rbp-280h] BYREF
__int64 v47; // [rsp+140h] [rbp-140h]
void *v48; // [rsp+148h] [rbp-138h]
std::string v49; // [rsp+150h] [rbp-130h] BYREF
std::string v50; // [rsp+168h] [rbp-118h] BYREF
std::string v51; // [rsp+180h] [rbp-100h] BYREF
std::string v52; // [rsp+198h] [rbp-E8h] BYREF
std::string v53; // [rsp+1B0h] [rbp-D0h] BYREF
std::string v54; // [rsp+1C8h] [rbp-B8h] BYREF
std::string v55; // [rsp+1E0h] [rbp-A0h] BYREF
std::string v56; // [rsp+1F8h] [rbp-88h] BYREF
std::string v57; // [rsp+210h] [rbp-70h] BYREF
__int128 v58; // [rsp+228h] [rbp-58h] BYREF
void *__p; // [rsp+238h] [rbp-48h]
char v60; // [rsp+240h] [rbp-40h] BYREF
_BYTE v61[46]; // [rsp+241h] [rbp-3Fh] BYREF
double v62; // 0:xmm0_8.8
if ( a1->m_lockInput )
return;
v6 = ((__int64 (__fastcall *)(cocos2d::CCObject *))a2->getTag)(a2);
v7 = (cocos2d::CCArray *)sub_10071F9E0(a2, a2);
if ( v6 == 3 )
{
v13 = GameStatsManager::sharedState();
if ( GameStatsManager::isItemUnlocked(v13, GJItem, 3) )
{
v10 = 51455;
v11 = "16";
goto LABEL_11;
}
LOBYTE(v46.m_sInverse.b) = 6;
*(_DWORD *)((char *)&v46.m_sInverse.b + 1) = 3026478;
v53.__r_.__value_.__r.__words[2] = (std::string::size_type)operator new(0x58u);
v53.__r_.__value_.__r.__words[0] = 89;
v53.__r_.__value_.__l.__size_ = 81;
strcpy(
v53.__r_.__value_.__l.__data_,
"The third key is hidden well.\nEven I have not been able to find it.");
v36 = DialogObject::create((__int128 *)&v46.m_sInverse.b, &v53, 15, 0, 0xFFFFFF, 0.89999998);
sub_10071FCD0(v7, v36);
if ( (*(_BYTE *)&v53.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v53.__r_.__value_.__l.__data_);
if ( (LOBYTE(v46.m_sInverse.b) & 1) != 0 )
operator delete(*(void **)&v46.m_sInverse.ty);
LOBYTE(v46.m_pCamera) = 6;
*(_DWORD *)((char *)&v46.m_pCamera + 1) = 3026478;
v54.__r_.__value_.__r.__words[2] = (std::string::size_type)operator new(0x70u);
v54.__r_.__value_.__r.__words[0] = 113;
v54.__r_.__value_.__l.__size_ = 107;
strcpy(
v54.__r_.__value_.__l.__data_,
"I suspect it is guarded by The Gatekeeper.\nRubRub's trusted pet....");
v37 = DialogObject::create((__int128 *)&v46.m_pCamera, &v54, 15, 0, 0xFFFFFF, 0.80000001);
sub_10071FCD0(v7, v37);
if ( (*(_BYTE *)&v54.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v54.__r_.__value_.__l.__data_);
if ( ((__int64)v46.m_pCamera & 1) != 0 )
operator delete(v46.m_pChildren);
LOBYTE(v46.m_pParent) = 6;
*(_DWORD *)((char *)&v46.m_pParent + 1) = 3026478;
v55.__r_.__value_.__r.__words[2] = (std::string::size_type)operator new(0x48u);
v55.__r_.__value_.__r.__words[0] = 73;
v55.__r_.__value_.__l.__size_ = 68;
strcpy(v55.__r_.__value_.__l.__data_, "To claim the key you must fool him.\nI do not know how.");
v38 = DialogObject::create((__int128 *)&v46.m_pParent, &v55, 15, 0, 0xFFFFFF, 0.89999998);
sub_10071FCD0(v7, v38);
if ( (*(_BYTE *)&v55.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v55.__r_.__value_.__l.__data_);
if ( ((__int64)v46.m_pParent & 1) != 0 )
operator delete(v46.m_pUserObject);
LOBYTE(v46.m_pShaderProgram) = 6;
*(_DWORD *)((char *)&v46.m_pShaderProgram + 1) = 3026478;
v56.__r_.__value_.__r.__words[2] = (std::string::size_type)operator new(0x40u);
v56.__r_.__value_.__r.__words[0] = 65;
v56.__r_.__value_.__l.__size_ = 61;
strcpy(v56.__r_.__value_.__l.__data_, "You will find The Gatekeeper at the end of the world.");
v39 = DialogObject::create((__int128 *)&v46.m_pShaderProgram, &v56, 15, 0, 0xFFFFFF, 1.0);
sub_10071FCD0(v7, v39);
if ( (*(_BYTE *)&v56.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v56.__r_.__value_.__l.__data_);
if ( ((__int64)v46.m_pShaderProgram & 1) != 0 )
operator delete(v46.m_pScheduler);
LOBYTE(v46.m_pActionManager) = 6;
*(_DWORD *)((char *)&v46.m_pActionManager + 1) = 3026478;
v57.__r_.__value_.__r.__words[2] = (std::string::size_type)operator new(0x50u);
v57.__r_.__value_.__r.__words[0] = 81;
v57.__r_.__value_.__l.__size_ = 76;
strcpy(
v57.__r_.__value_.__l.__data_,
"Touch the ground beneath the promise, and the door will be revealed.");
v40 = DialogObject::create((__int128 *)&v46.m_pActionManager, &v57, 15, 0, 0xFFFFFF, 0.80000001);
sub_10071FCD0(v7, v40);
if ( (*(_BYTE *)&v57.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v57.__r_.__value_.__l.__data_);
if ( ((__int64)v46.m_pActionManager & 1) != 0 )
operator delete(*(void **)&v46.m_fTransformY);
v41 = GameManager::sharedState();
GameManager::setUGV(v41, "6", 1);
goto LABEL_65;
}
if ( v6 == 2 )
{
v12 = GameStatsManager::sharedState();
if ( GameStatsManager::isItemUnlocked(v12, GJItem, 2) )
{
v10 = 3342130;
v11 = "15";
goto LABEL_11;
}
LOBYTE(v46.m_obAnchorPointInPoints.y) = 6;
*(_DWORD *)((char *)&v46.m_obAnchorPointInPoints.y + 1) = 3026478;
v50.__r_.__value_.__r.__words[2] = (std::string::size_type)operator new(0x48u);
v50.__r_.__value_.__r.__words[0] = 73;
v50.__r_.__value_.__l.__size_ = 67;
strcpy(v50.__r_.__value_.__l.__data_, "They tried to hide it from me,\nbut I have my spies.");
v32 = DialogObject::create((__int128 *)&v46.m_obAnchorPointInPoints.y, &v50, 15, 0, 0xFFFFFF, 1.0);
sub_10071FCD0(v7, v32);
if ( (*(_BYTE *)&v50.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v50.__r_.__value_.__l.__data_);
if ( (LOBYTE(v46.m_obAnchorPointInPoints.y) & 1) != 0 )
operator delete(*(void **)&v46.m_obContentSize.height);
LOBYTE(v46.m_sAdditionalTransform.b) = 6;
*(_DWORD *)((char *)&v46.m_sAdditionalTransform.b + 1) = 3026478;
v51.__r_.__value_.__r.__words[2] = (std::string::size_type)operator new(0x48u);
v51.__r_.__value_.__r.__words[0] = 73;
v51.__r_.__value_.__l.__size_ = 64;
strcpy(v51.__r_.__value_.__l.__data_, "The second key is locked away in a secret chest.");
v33 = DialogObject::create((__int128 *)&v46.m_sAdditionalTransform.b, &v51, 15, 0, 0xFFFFFF, 1.0);
sub_10071FCD0(v7, v33);
if ( (*(_BYTE *)&v51.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v51.__r_.__value_.__l.__data_);
if ( (LOBYTE(v46.m_sAdditionalTransform.b) & 1) != 0 )
operator delete(*(void **)&v46.m_sAdditionalTransform.ty);
LOBYTE(v46.m_sTransform.b) = 6;
*(_DWORD *)((char *)&v46.m_sTransform.b + 1) = 3026478;
v52.__r_.__value_.__r.__words[2] = (std::string::size_type)operator new(0x40u);
v52.__r_.__value_.__r.__words[0] = 65;
v52.__r_.__value_.__l.__size_ = 57;
strcpy(v52.__r_.__value_.__l.__data_, "Unlock 50 secret chests to claim the key.");
v34 = DialogObject::create((__int128 *)&v46.m_sTransform.b, &v52, 15, 0, 0xFFFFFF, 1.0);
sub_10071FCD0(v7, v34);
if ( (*(_BYTE *)&v52.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v52.__r_.__value_.__l.__data_);
if ( (LOBYTE(v46.m_sTransform.b) & 1) != 0 )
{
v35 = *(void **)&v46.m_sTransform.ty;
LABEL_64:
operator delete(v35);
}
LABEL_65:
v45 = DialogLayer::createWithObjects(v7, 4);
((void (__fastcall *)(SecretLayer3 *, DialogLayer *, __int64))a1->addChild_0)(a1, v45, 100);
DialogLayer::updateChatPlacement(v45, Center);
DialogLayer::animateIn(v45, FromCenter);
return;
}
if ( v6 != 1 )
goto LABEL_65;
v8 = GameManager::sharedState();
GameManager::setUGV(v8, "19", 1);
v9 = GameStatsManager::sharedState();
if ( !GameStatsManager::isItemUnlocked(v9, GJItem, 1) )
{
LOBYTE(v46.m_uAutoReleaseCount) = 6;
*(unsigned int *)((char *)&v46.m_uAutoReleaseCount + 1) = 3026478;
v46.m_pComponentContainer = (cocos2d::CCComponentContainer *)operator new(0x40u);
*(_QWORD *)&v46.m_bReorderChildDirty = 65;
*(_QWORD *)&v46.m_nUpdateScriptHandler = 63;
strcpy((char *)v46.m_pComponentContainer, "The first key is hidden in a secret gauntlet...");
v42 = DialogObject::create(
(__int128 *)&v46.m_uAutoReleaseCount,
(std::string *)&v46.m_bReorderChildDirty,
15,
0,
0xFFFFFF,
1.0);
sub_10071FCD0(v7, v42);
if ( v46.m_bReorderChildDirty )
operator delete(v46.m_pComponentContainer);
if ( (v46.m_uAutoReleaseCount & 1) != 0 )
operator delete(*(void **)&v46.m_unknown2);
LOBYTE(v46.m_uOrderOfArrival) = 6;
*(int *)((char *)&v46.m_uOrderOfArrival + 1) = 3026478;
v48 = operator new(0x58u);
*(_QWORD *)&v46.m_bUseChildIndex = 89;
v47 = 80;
strcpy((char *)v48, "Only a chosen few can find it, but I will grant you this gift...");
v43 = DialogObject::create(
(__int128 *)&v46.m_uOrderOfArrival,
(std::string *)&v46.m_bUseChildIndex,
15,
0,
0xFFFFFF,
1.0);
sub_10071FCD0(v7, v43);
if ( v46.m_bUseChildIndex )
operator delete(v48);
if ( (v46.m_uOrderOfArrival & 1) != 0 )
operator delete(*(void **)&v46.m_fScaleX);
LOBYTE(v46.m_fVertexZ) = 6;
*(_DWORD *)((char *)&v46.m_fVertexZ + 1) = 3026478;
v49.__r_.__value_.__r.__words[2] = (std::string::size_type)operator new(0x60u);
v49.__r_.__value_.__r.__words[0] = 97;
v49.__r_.__value_.__l.__size_ = 91;
strcpy(
v49.__r_.__value_.__l.__data_,
"Complete the Chaos Gauntlet, and the key will be yours...");
v44 = DialogObject::create((__int128 *)&v46.m_fVertexZ, &v49, 15, 0, 0xFFFFFF, 1.0);
sub_10071FCD0(v7, v44);
if ( (*(_BYTE *)&v49.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v49.__r_.__value_.__l.__data_);
if ( (LOBYTE(v46.m_fVertexZ) & 1) == 0 )
goto LABEL_65;
v35 = *(void **)&v46.m_fSkewY;
goto LABEL_64;
}
v10 = 16737280;
v11 = "14";
LABEL_11:
v14 = GameManager::sharedState();
GameManager::setUGV(v14, v11, 1);
((void (__fastcall *)(cocos2d::CCObject *, _QWORD))a2->__vftable[13].copyWithZone)(a2, 0);
((void (__fastcall *)(cocos2d::CCObject *, _QWORD))a2->__vftable[4].~CCObject)(a2, 0);
v15 = FMODAudioEngine::sharedEngine();
LOBYTE(v58) = 28;
strcpy((char *)&v58 + 1, "chestClick.ogg");
FMODAudioEngine::playEffect_1((__int64)v15, &v58, v2);
if ( (v58 & 1) != 0 )
operator delete(__p);
v16 = FMODAudioEngine::sharedEngine();
v60 = 30;
strcpy(v61, "chestOpen01.ogg");
FMODAudioEngine::playEffect_1((__int64)v16, (__int128 *)&v60, v2);
if ( (v60 & 1) != 0 )
operator delete(*(void **)&v61[15]);
v17 = (const cocos2d::CCPoint *)((__int64 (__fastcall *)(cocos2d::CCObject *))a2->__vftable[6].~CCObject_0)(a2);
((void (__fastcall *)(cocos2d::CCObject *))a2->__vftable[2].acceptVisitor)(a2);
*(cocos2d::CCPoint *)&v62 = cocos2d::CCNode::convertToWorldSpace(&v46, v17);
v18 = cocos2d::CCParticleSystemQuad::create("coinPickupEffect.plist", 0);
v19 = ((__m128 (__fastcall *)(cocos2d::CCParticleSystemQuad *, __int64, double))v18->setAutoRemoveOnFinish)(
v18,
1,
v62);
v19.f32[0] = (float)(unsigned __int8)v10 / 255.0;
v3.f32[0] = (float)BYTE1(v10) / 255.0;
v4.f32[0] = (float)HIWORD(v10) / 255.0;
*(__m128 *)&v46.m_uID = _mm_movelh_ps(_mm_insert_ps(v19, v3, 16), _mm_blend_ps(v4, (__m128)xmmword_1008150D0, 14));
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *, unsigned int *))v18->setStartColor)(v18, &v46.m_uID);
((void (__fastcall *)(SecretLayer3 *, cocos2d::CCParticleSystemQuad *, __int64))a1->addChild_0)(a1, v18, 1);
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *, cocos2d::CCNode *))v18->setPosition)(v18, &v46);
v20 = CCCircleWave::create(25.0, 5.0, 0.30000001, 0, 0);
v20->m_color = (cocos2d::ccColor3B)v10;
((void (__fastcall *)(CCCircleWave *, cocos2d::CCNode *))v20->setPosition)(v20, &v46);
((void (__fastcall *)(SecretLayer3 *, CCCircleWave *, _QWORD))a1->addChild_0)(a1, v20, 0);
v21 = CCCircleWave::create_1(5.0, 60.0, 0.30000001, 0);
v21->m_color = (cocos2d::ccColor3B)v10;
((void (__fastcall *)(CCCircleWave *, cocos2d::CCNode *))v21->setPosition)(v21, &v46);
((void (__fastcall *)(SecretLayer3 *, CCCircleWave *, _QWORD))a1->addChild_0)(a1, v21, 0);
*(_QWORD *)&v21->m_circleMode = 0x400000001LL;
v22 = GameManager::sharedState();
UGV = GameManager::getUGV(v22, "14");
v24 = GameManager::sharedState();
v25 = UGV + GameManager::getUGV(v24, "15");
v26 = GameManager::sharedState();
if ( v25 + GameManager::getUGV(v26, "16") == 3 )
{
v27 = SecretLayer3::revealStep1;
v28 = 1.0;
}
else
{
a1->m_lockInput = 1;
v27 = SecretLayer3::showUnlockDialog;
v28 = 0.5;
}
v29 = cocos2d::CCDelayTime::create(v28);
v30 = cocos2d::CCCallFunc::create(a1, (cocos2d::SEL_CallFunc)(unsigned __int64)v27);
v31 = sub_1003B5760(v29, v30, 0);
cocos2d::CCNode::runAction(a1, v31);
}