//
// LevelAreaInnerLayer::init from 0x100345714 to 0x1003461f4 (2784 bytes)
//
// 1 xrefs:
// > LevelAreaInnerLayer::create @ 0x1003456c8
//
// 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
//
bool __fastcall LevelAreaInnerLayer::init(LevelAreaInnerLayer *a1, bool a2)
{
LevelAreaInnerLayer *v3; // x28
cocos2d::CCDirector *v4; // x0
cocos2d::CCTextureCache *v5; // x0
cocos2d::CCSpriteFrameCache *v6; // x0
cocos2d::CCSprite *v7; // x21
CCMenuItemSpriteExtra *v8; // x19
cocos2d::CCFadeIn *v9; // x0
__int64 v10; // x1
__int64 v11; // x2
__int64 v12; // x3
__int64 v13; // x4
__int64 v14; // x5
__int64 v15; // x6
__int64 v16; // x7
cocos2d::CCDirector *v17; // x0
float v18; // s8
cocos2d::CCDirector *v19; // x0
__n128 v20; // q1
__n128 v21; // q0
cocos2d::CCNode *v22; // x22
cocos2d::CCSprite *v23; // x0
__n128 v24; // q0
__n128 v25; // q1
__int64 i; // x20
__n128 v27; // q0
__n128 v28; // q1
__n128 v29; // q0
__n128 v30; // q1
__n128 v31; // q0
__n128 v32; // q1
__n128 v33; // q0
__n128 v34; // q1
__int64 v35; // x20
GameLevelManager *v36; // x0
GJGameLevel *MainLevel; // x23
GameStatsManager *v38; // x0
_BOOL4 hasCompletedMainLevel; // w19
GameStatsManager *v40; // x0
_BOOL4 v41; // w21
std::string *v42; // x0
cocos2d::CCSprite *v43; // x26
LevelAreaInnerLayer *v44; // x27
CCMenuItemSpriteExtra *v45; // x28
__n128 v46; // q0
__n128 v47; // q1
int j; // w19
GameStatsManager *v49; // x21
const char *CoinKey; // x0
_BOOL4 hasSecretCoin; // w26
const char *v52; // x0
cocos2d::CCSprite *v53; // x0
cocos2d::CCSprite *v54; // x21
__n128 v55; // q0
__n128 v56; // q1
double v57; // d0
cocos2d::CCSprite *v58; // x0
__n128 v59; // q0
CCMenuItemSpriteExtra *m_nextFloorButton; // x19
__n128 v61; // q1
char v62; // w8
char v63; // w25
cocos2d::CCSprite *v64; // x21
__n128 v65; // q1
__n128 v66; // q0
float32x2_t *v67; // x21
__n128 v68; // q1
__n128 v69; // q0
float v70; // s2
cocos2d::CCScaleTo *v71; // x0
cocos2d::CCEaseExponentialOut *v72; // x0
cocos2d::CCSprite *v73; // x19
cocos2d::CCDelayTime *v74; // x21
char v75; // w0
__int64 v76; // x1
__int64 v77; // x2
__int64 v78; // x3
__int64 v79; // x4
__int64 v80; // x5
__int64 v81; // x6
__int64 v82; // x7
cocos2d::CCSequence *v83; // x0
CCMenuItemSpriteExtra *v84; // x19
cocos2d::CCDirector *v85; // x0
__n128 v86; // q0
__n128 v87; // q1
float32x2_t *v88; // x19
__n128 v89; // q0
__n128 v90; // q1
double v91; // d0
__n128 v92; // q0
__n128 v93; // q1
cocos2d::CCMoveBy *v94; // x0
cocos2d::CCEaseInOut *v95; // x19
__n128 v96; // q0
__n128 v97; // q1
cocos2d::CCMoveBy *v98; // x0
char v99; // w0
__int64 v100; // x1
__int64 v101; // x2
__int64 v102; // x3
__int64 v103; // x4
__int64 v104; // x5
__int64 v105; // x6
__int64 v106; // x7
cocos2d::CCSequence *v107; // x0
cocos2d::CCRepeatForever *v108; // x0
cocos2d::CCDelayTime *v109; // x19
char v110; // w0
__int64 v111; // x1
__int64 v112; // x2
__int64 v113; // x3
__int64 v114; // x4
__int64 v115; // x5
__int64 v116; // x6
__int64 v117; // x7
cocos2d::CCSequence *v118; // x0
CCSpriteGrayscale *v119; // x19
cocos2d::CCDelayTime *v120; // x21
char v121; // w0
__int64 v122; // x1
__int64 v123; // x2
__int64 v124; // x3
__int64 v125; // x4
__int64 v126; // x5
__int64 v127; // x6
__int64 v128; // x7
cocos2d::CCSequence *v129; // x0
CCMenuItemSpriteExtra *v130; // x19
cocos2d::CCDirector *v131; // x0
float v132; // s8
cocos2d::CCDirector *v133; // x0
__n128 v134; // q1
__n128 v135; // q0
GameManager *v136; // x0
cocos2d::CCDelayTime *v137; // x19
char v138; // w0
__int64 v139; // x1
__int64 v140; // x2
__int64 v141; // x3
__int64 v142; // x4
__int64 v143; // x5
__int64 v144; // x6
__int64 v145; // x7
cocos2d::CCSequence *v146; // x0
bool v148; // [xsp+18h] [xbp-E8h]
_BOOL4 v149; // [xsp+1Ch] [xbp-E4h]
cocos2d::CCMenu *v150; // [xsp+20h] [xbp-E0h]
int v151; // [xsp+2Ch] [xbp-D4h]
cocos2d::CCMenu *v152; // [xsp+30h] [xbp-D0h]
float32x2_t v153; // [xsp+38h] [xbp-C8h] BYREF
float32x2_t v154; // [xsp+40h] [xbp-C0h] BYREF
float32x2_t v155; // [xsp+48h] [xbp-B8h] BYREF
std::string v156; // [xsp+50h] [xbp-B0h] BYREF
float v157; // [xsp+68h] [xbp-98h]
float v158; // [xsp+6Ch] [xbp-94h]
__int64 v159; // [xsp+70h] [xbp-90h] BYREF
__int64 v160; // [xsp+78h] [xbp-88h] BYREF
__int64 v161; // [xsp+80h] [xbp-80h] BYREF
__int64 v162; // [xsp+88h] [xbp-78h] BYREF
cocos2d::CCPoint v163; // 0:kr08_8.8
cocos2d::CCPoint v164; // 0:kr10_8.8
cocos2d::CCPoint v165; // 0:kr18_8.8
cocos2d::CCPoint v166; // 0:kr20_8.8
cocos2d::SEL_CallFunc v167; // 0:x1.16
cocos2d::SEL_CallFunc v168; // 0:x1.16
cocos2d::SEL_MenuHandler v169; // 0:x3.16
cocos2d::SEL_MenuHandler v170; // 0:x3.16
cocos2d::SEL_MenuHandler v171; // 0:x3.16
cocos2d::SEL_MenuHandler v172; // 0:x3.16
cocos2d::SEL_MenuHandler v173; // 0:x3.16
cocos2d::CCPoint v174; // 0:s0.4,4:s1.4
v3 = a1;
v149 = cocos2d::CCLayer::init(a1);
if ( !v149 )
return v149;
v148 = a2;
((void (__fastcall *)(LevelAreaInnerLayer *, __int64))v3->setKeypadEnabled)(v3, 1);
((void (__fastcall *)(LevelAreaInnerLayer *, __int64))v3->setKeyboardEnabled)(v3, 1);
v4 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v4);
v5 = cocos2d::CCTextureCache::sharedTextureCache();
cocos2d::CCTextureCache::addImage(v5, "TowerSheet.png", 0);
v6 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile(v6, "TowerSheet.plist");
v7 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_03_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))v7->setOpacity)(v7, 0);
v169.ptr = (void (__cdecl *)(cocos2d::CCObject *))LevelAreaInnerLayer::onBack;
v169.adj = 0;
v8 = CCMenuItemSpriteExtra::create(v7, nullptr, v3, v169);
CCMenuItemSpriteExtra::setSizeMult(v8, 1.6);
v9 = cocos2d::CCFadeIn::create(0.3);
cocos2d::CCNode::runAction(v7, v9);
v150 = sub_1001D7ED0(v8, v10, v11, v12, v13, v14, v15, v16, 0);
((void (__fastcall *)(LevelAreaInnerLayer *, cocos2d::CCMenu *, __int64))v3->addChild_0)(v3, v150, 1);
v17 = cocos2d::CCDirector::sharedDirector();
v18 = sub_1001768D8((__int64)v17);
v19 = cocos2d::CCDirector::sharedDirector();
v20.n128_f32[0] = sub_1001768C8((__int64)v19) + -23.0;
v21.n128_f32[0] = v18 + 24.0;
sub_100022980(v21, v20, &v159);
((void (__fastcall *)(cocos2d::CCMenu *, __int64 *))v150->setPosition)(v150, &v159);
if ( PlatformToolbox::isControllerConnected() )
GameToolbox::addBackButton(v3, v8);
v22 = cocos2d::CCNode::create();
((void (__fastcall *)(LevelAreaInnerLayer *, cocos2d::CCNode *))v3->addChild)(v3, v22);
v152 = cocos2d::CCMenu::create();
v23 = cocos2d::CCSprite::createWithSpriteFrameName("towerBG_01_001.png");
v24 = ((__n128 (__fastcall *)(cocos2d::CCNode *, cocos2d::CCSprite *, __int64))v22->addChild_0)(v22, v23, 1);
v24.n128_f32[0] = v157 * 0.5;
v25.n128_f32[0] = v158 * 0.5;
sub_100022980(v24, v25, &v159);
((void (__fastcall *)(cocos2d::CCNode *, __int64 *))v22->setPosition)(v22, &v159);
for ( i = 0; i != 32; i += 8 )
sub_1000229B0((__int64 *)((char *)&v159 + i));
v27.n128_u32[0] = -1027670016;
v28.n128_u32[0] = -1028489216;
sub_100022980(v27, v28, &v156);
v29.n128_f64[0] = sub_1000229D0(&v159, (double *)&v156);
v29.n128_u32[0] = 1120894976;
v30.n128_u32[0] = -1039794176;
sub_100022980(v29, v30, &v156);
v31.n128_f64[0] = sub_1000229D0(&v160, (double *)&v156);
v31.n128_u32[0] = -1027670016;
v32.n128_u32[0] = 1101660160;
sub_100022980(v31, v32, &v156);
v33.n128_f64[0] = sub_1000229D0(&v161, (double *)&v156);
v33.n128_u32[0] = 1113980928;
v34.n128_u32[0] = 1117192192;
sub_100022980(v33, v34, &v156);
sub_1000229D0(&v162, (double *)&v156);
v35 = 0;
v151 = 0;
do
{
v36 = GameLevelManager::sharedState();
MainLevel = GameLevelManager::getMainLevel(v36, (int)v35 + 5001, 1);
v38 = GameStatsManager::sharedState();
hasCompletedMainLevel = GameStatsManager::hasCompletedMainLevel(v38, v35 + 5001);
if ( !v35 )
{
sub_100009900(&v156, "towerDoor_locked_001.png");
if ( hasCompletedMainLevel )
{
v41 = 1;
LABEL_13:
std::string::assign(&v156, "towerDoor_open_001.png");
++v151;
goto LABEL_15;
}
LABEL_14:
std::string::assign(&v156, "towerDoor_unlocked_001.png");
v41 = 1;
goto LABEL_15;
}
v40 = GameStatsManager::sharedState();
v41 = GameStatsManager::hasCompletedMainLevel(v40, v35 | 0x1388);
sub_100009900(&v156, "towerDoor_locked_001.png");
if ( hasCompletedMainLevel )
goto LABEL_13;
if ( v41 )
goto LABEL_14;
LABEL_15:
if ( (v156.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v42 = &v156;
else
v42 = (std::string *)v156.__r_.__value_.__r.__words[0];
v43 = cocos2d::CCSprite::createWithSpriteFrameName((const char *)v42);
v44 = v3;
v170.ptr = (void (__cdecl *)(cocos2d::CCObject *))LevelAreaInnerLayer::onDoor;
v170.adj = 0;
v45 = CCMenuItemSpriteExtra::create(v43, nullptr, v3, v170);
*(_WORD *)&v45->m_animationEnabled = 256;
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))v45->setTag)(v45, (unsigned int)(v35 + 5001));
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v152->addChild)(v152, v45);
if ( !hasCompletedMainLevel && !v41 )
{
v155.i8[2] = -1;
v155.i16[0] = -6703;
((void (__fastcall *)(cocos2d::CCSprite *, float32x2_t *))v43->setColor)(v43, &v155);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))v45->setEnabled)(v45, 0);
}
v163 = cocos2d::CCNode::convertToNodeSpace(v152, (const cocos2d::CCPoint *)&v159 + v35);
((void (__fastcall *)(CCMenuItemSpriteExtra *, float32x2_t *, float, float))v45->setPosition)(
v45,
&v155,
v163.x,
v163.y);
v3 = v44;
if ( hasCompletedMainLevel )
{
v46.n128_u32[0] = 0;
v47.n128_u64[0] = 0x4200000042000000LL;
sub_100022980(v46, v47, &v154);
sub_1000229DC((float32x2_t *)&v159 + v35, &v154, &v155);
for ( j = 1; j != 4; ++j )
{
v49 = GameStatsManager::sharedState();
CoinKey = GJGameLevel::getCoinKey(MainLevel, j);
hasSecretCoin = GameStatsManager::hasSecretCoin(v49, CoinKey);
if ( hasSecretCoin )
v52 = "GJ_coinsIcon_001.png";
else
v52 = "GJ_coinsIcon_gray_001.png";
v53 = cocos2d::CCSprite::createWithSpriteFrameName(v52);
v54 = v53;
if ( hasSecretCoin )
{
v154.i8[2] = -1;
v154.i16[0] = -1;
}
else
{
v154.i8[2] = -31;
v154.i16[0] = -7711;
}
((void (__fastcall *)(cocos2d::CCSprite *, float32x2_t *))v53->setColor)(v53, &v154);
((void (__fastcall *)(cocos2d::CCSprite *, float))v54->setScale)(v54, 0.7);
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCSprite *, __int64))v22->addChild_0)(v22, v54, 10);
v55.n128_f32[0] = (float)(j - 2) * 20.0;
v56.n128_f32[0] = (float)(8 * (unsigned int)(j == 2));
sub_100022980(v55, v56, &v153);
*(float32x2_t *)&v57 = sub_1000229DC(&v155, &v153, &v154);
((void (__fastcall *)(cocos2d::CCSprite *, float32x2_t *, double))v54->setPosition)(v54, &v154, v57);
}
}
if ( SHIBYTE(v156.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v156.__r_.__value_.__l.__data_);
++v35;
}
while ( v35 != 4 );
v58 = cocos2d::CCSprite::createWithSpriteFrameName("towerLockedArrow_001.png");
v171.ptr = (void (__cdecl *)(cocos2d::CCObject *))LevelAreaInnerLayer::onNextFloor;
v171.adj = 0;
v44->m_nextFloorButton = CCMenuItemSpriteExtra::create(v58, nullptr, v44, v171);
v59 = ((__n128 (__fastcall *)(cocos2d::CCMenu *))v152->addChild)(v152);
m_nextFloorButton = v44->m_nextFloorButton;
v59.n128_u32[0] = -1027604480;
v61.n128_u32[0] = 1121452032;
sub_100022980(v59, v61, &v155);
v164 = cocos2d::CCNode::convertToNodeSpace(v152, (const cocos2d::CCPoint *)&v155);
((void (__fastcall *)(CCMenuItemSpriteExtra *, std::string *, float, float))m_nextFloorButton->setPosition)(
m_nextFloorButton,
&v156,
v164.x,
v164.y);
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCMenu *, __int64))v22->addChild_0)(v22, v152, 2);
v62 = 1;
do
{
v63 = v62;
v64 = cocos2d::CCSprite::createWithSpriteFrameName("towerTorchInner_001.png");
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCSprite *, __int64))v22->addChild_0)(v22, v64, 4);
v66.n128_u32[0] = 1128464384;
if ( (v63 & 1) != 0 )
v66.n128_f32[0] = -195.0;
v65.n128_u32[0] = 4.0;
sub_100022980(v66, v65, &v156);
((void (__fastcall *)(cocos2d::CCSprite *, std::string *))v64->setPosition)(v64, &v156);
v67 = (float32x2_t *)((__int64 (__fastcall *)(cocos2d::CCSprite *))v64->getPosition)(v64);
v68.n128_u32[0] = 1107558400;
v69.n128_u32[0] = 0;
sub_100022980(v69, v68, &v155);
sub_1000229DC(v67, &v155, (float32x2_t *)&v156);
v174.x = 1.0;
LevelAreaLayer::addTorch(v22, v174, (int)&v156, v70, 2, 4, 1, nullptr);
v62 = 0;
}
while ( (v63 & 1) != 0 );
if ( !v148 )
{
((void (__fastcall *)(cocos2d::CCNode *, float))v22->setScale)(v22, 0.2);
v71 = cocos2d::CCScaleTo::create_1(1.0, 1.0);
v72 = cocos2d::CCEaseExponentialOut::create(v71);
cocos2d::CCNode::runAction(v22, v72);
}
v73 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_secretLock4_small_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))v73->setOpacity)(v73, 0);
v74 = cocos2d::CCDelayTime::create(0.5);
v75 = (unsigned __int8)cocos2d::CCFadeTo::create(2.0, 0xC8u);
v83 = sub_10018A494(v74, v76, v77, v78, v79, v80, v81, v82, v75);
cocos2d::CCNode::runAction(v73, v83);
v172.ptr = (void (__cdecl *)(cocos2d::CCObject *))LevelAreaInnerLayer::onOnlineVault;
v172.adj = 0;
v84 = CCMenuItemSpriteExtra::create(v73, nullptr, v44, v172);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v150->addChild)(v150, v84);
v85 = cocos2d::CCDirector::sharedDirector();
v86.n128_f32[0] = sub_1001768E0((__int64)v85) + -22.0;
v87.n128_u32[0] = 23.0;
sub_100022980(v86, v87, &v155);
v165 = cocos2d::CCNode::convertToNodeSpace(v150, (const cocos2d::CCPoint *)&v155);
((void (__fastcall *)(CCMenuItemSpriteExtra *, std::string *, float, float))v84->setPosition)(
v84,
&v156,
v165.x,
v165.y);
v88 = (float32x2_t *)((__int64 (__fastcall *)(cocos2d::CCNode *))v22->getPosition)(v22);
v89.n128_u32[0] = 0;
v90.n128_u32[0] = -2.0;
sub_100022980(v89, v90, &v155);
*(float32x2_t *)&v91 = sub_1000229DC(v88, &v155, (float32x2_t *)&v156);
v92 = ((__n128 (__fastcall *)(cocos2d::CCNode *, std::string *, double))v22->setPosition)(v22, &v156, v91);
v92.n128_u32[0] = 0;
v93.n128_u32[0] = 4.0;
sub_100022980(v92, v93, &v156);
v94 = cocos2d::CCMoveBy::create(2.0, (const cocos2d::CCPoint *)&v156);
v95 = cocos2d::CCEaseInOut::create(v94, 2.0);
v96.n128_u32[0] = 0;
v97.n128_u32[0] = -4.0;
sub_100022980(v96, v97, &v156);
v98 = cocos2d::CCMoveBy::create(2.0, (const cocos2d::CCPoint *)&v156);
v99 = (unsigned __int8)cocos2d::CCEaseInOut::create(v98, 2.0);
v107 = sub_10018A494(v95, v100, v101, v102, v103, v104, v105, v106, v99);
v108 = cocos2d::CCRepeatForever::create(v107);
cocos2d::CCNode::runAction(v22, v108);
v109 = cocos2d::CCDelayTime::create(0.0);
v167.ptr = (void (*)(void))LevelAreaInnerLayer::tryResumeTowerMusic;
v167.adj = 0;
v110 = (unsigned __int8)cocos2d::CCCallFunc::create(v44, v167);
v118 = sub_10018A494(v109, v111, v112, v113, v114, v115, v116, v117, v110);
cocos2d::CCNode::runAction(v44, v118);
sub_100009900(&v156, "GJ_infoIcon_001.png");
v119 = CCSpriteGrayscale::createWithSpriteFrameName((__int64)&v156);
if ( SHIBYTE(v156.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v156.__r_.__value_.__l.__data_);
((void (__fastcall *)(CCSpriteGrayscale *, _QWORD))v119->setOpacity)(v119, 0);
((void (__fastcall *)(CCSpriteGrayscale *, float))v119->setScale)(v119, 0.8);
v120 = cocos2d::CCDelayTime::create(0.1);
v121 = (unsigned __int8)cocos2d::CCFadeTo::create(1.0, 0xC8u);
v129 = sub_10018A494(v120, v122, v123, v124, v125, v126, v127, v128, v121);
cocos2d::CCNode::runAction(v119, v129);
v173.ptr = (void (__cdecl *)(cocos2d::CCObject *))LevelAreaInnerLayer::onInfo;
v173.adj = 0;
v130 = CCMenuItemSpriteExtra::create(v119, nullptr, v44, v173);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *))v150->addChild)(v150, v130);
v131 = cocos2d::CCDirector::sharedDirector();
v132 = sub_1001768E0((__int64)v131);
v133 = cocos2d::CCDirector::sharedDirector();
v134.n128_f32[0] = sub_1001768C8((__int64)v133) + -20.0;
v135.n128_f32[0] = v132 + -20.0;
sub_100022980(v135, v134, &v155);
v166 = cocos2d::CCNode::convertToNodeSpace(v150, (const cocos2d::CCPoint *)&v155);
((void (__fastcall *)(CCMenuItemSpriteExtra *, std::string *, float, float))v130->setPosition)(
v130,
&v156,
v166.x,
v166.y);
CCMenuItemSpriteExtra::setSizeMult(v130, 1.2);
if ( v151 == 4 )
{
v136 = GameManager::sharedState();
if ( !GameManager::getUGV(v136, "33") )
{
v44->m_enteringLevel = 1;
v137 = cocos2d::CCDelayTime::create(1.0);
v168.ptr = (void (*)(void))LevelAreaInnerLayer::showFloor1CompleteDialog;
v168.adj = 0;
v138 = (unsigned __int8)cocos2d::CCCallFunc::create(v44, v168);
v146 = sub_10018A494(v137, v139, v140, v141, v142, v143, v144, v145, v138);
cocos2d::CCNode::runAction(v44, v146);
goto LABEL_44;
}
}
else if ( v151 <= 3 )
{
LABEL_44:
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))v44->m_nextFloorButton->setEnabled)(
v44->m_nextFloorButton,
0);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))v44->m_nextFloorButton->setVisible)(
v44->m_nextFloorButton,
0);
}
if ( !v44->m_enteringLevel )
GameManager::sharedState()->m_somethingInMenuLayer = 0;
return v149;
}