//
// LevelAreaLayer::init from 0x1402c43d0 to 0x1402c527d (3757 bytes)
//
// 6 xrefs:
// > LevelAreaLayer::scene @ 0x1402c438e
// > LevelAreaLayer::scene @ 0x1402c4395
// > LevelAreaLayer::scene @ 0x1402c437f
// > ??> @ 0x140583178
// > ??> @ 0x1406d2ad4
// > ??> @ 0x1406d2ae0
//
// 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=7
bool LevelAreaLayer::init(LevelAreaLayer *a1)
{
float v1; // xmm3_4
bool result; // al
__int64 v4; // rcx
__int64 v5; // rcx
cocos2d::CCArray *v6; // rax
cocos2d::CCTextureCache *v7; // rax
__int64 v8; // rcx
cocos2d::CCSpriteFrameCache *v9; // rax
_BOOL8 v10; // rdx
_BOOL8 v11; // rdx
__int64 v12; // rcx
cocos2d::CCDirector *v13; // rax
struct cocos2d::CCSprite *v14; // rax
CCMenuItemSpriteExtra *v15; // rsi
struct cocos2d::CCMenu *v16; // rdi
cocos2d::CCMenu_vtbl *v17; // rbx
__int64 v18; // rcx
cocos2d::CCDirector *v19; // rax
__int64 v20; // rcx
cocos2d::CCDirector *v21; // rax
float v22; // xmm0_4
const cocos2d::CCPoint *v23; // rax
__int64 v24; // rdx
__int64 v25; // rcx
GameManager *v26; // rcx
cocos2d::CCString *v27; // rax
const char *CString; // rax
struct cocos2d::CCSprite *v29; // rdi
cocos2d::CCTexture2D *v30; // rax
float v31; // xmm0_4
cocos2d::CCSprite_vtbl *v32; // rbx
const cocos2d::CCPoint *v33; // rax
float v34; // xmm0_4
cocos2d::CCSprite_vtbl *v35; // rbx
double v36; // xmm0_8
const cocos2d::CCPoint *v37; // rax
CCLightFlash *v38; // rdi
CCLightFlash_vtbl *v39; // rbx
const cocos2d::CCPoint *v40; // rax
struct cocos2d::CCFadeTo *v41; // rax
struct cocos2d::CCEaseInOut *v42; // rbx
struct cocos2d::CCFadeTo *v43; // rax
struct cocos2d::CCEaseInOut *v44; // rax
struct cocos2d::CCSequence *v45; // rax
struct cocos2d::CCRepeatForever *v46; // rax
cocos2d::ccColor3B *v47; // r8
cocos2d::CCSprite *v48; // rax
float v49; // xmm0_4
cocos2d::CCSprite_vtbl *v50; // rbx
const cocos2d::CCPoint *v51; // rax
struct cocos2d::CCSprite *v52; // r15
CCMenuItemSpriteExtra *v53; // rsi
struct cocos2d::CCMenu *v54; // rdi
float v55; // xmm0_4
const cocos2d::CCPoint *v56; // rax
CCMenuItemSpriteExtra_vtbl *v57; // rbx
struct cocos2d::CCPoint v58; // rax
int v59; // r15d
struct cocos2d::CCSprite *v60; // rdi
cocos2d::CCRGBAProtocol *v61; // rsi
double v62; // xmm0_8
float v63; // xmm1_4
cocos2d::CCSprite_vtbl *v64; // rbx
const cocos2d::CCPoint *v65; // rax
__int64 v66; // rdx
struct cocos2d::CCSprite *v67; // rdi
cocos2d::CCRGBAProtocol *v68; // rsi
float v69; // xmm0_4
cocos2d::CCSprite_vtbl *v70; // rbx
const cocos2d::CCPoint *v71; // rax
__int64 v72; // rdx
float v73; // xmm0_4
const cocos2d::CCPoint *v74; // rax
float v75; // xmm0_4
const struct cocos2d::CCPoint *v76; // rax
struct cocos2d::CCMoveBy *v77; // rax
struct cocos2d::CCEaseInOut *v78; // rbx
const struct cocos2d::CCPoint *v79; // rax
struct cocos2d::CCMoveBy *v80; // rax
struct cocos2d::CCEaseInOut *v81; // rax
struct cocos2d::CCSequence *v82; // rax
struct cocos2d::CCRepeatForever *v83; // rax
cocos2d::ccColor3B *v84; // r8
double v85; // xmm0_8
double v86; // xmm0_8
double v87; // xmm0_8
double v88; // xmm0_8
cocos2d::CCParticleSystemQuad *v89; // rdi
void *v90; // rcx
float v91; // xmm0_4
cocos2d::CCParticleSystemQuad_vtbl *v92; // rbx
__int64 v93; // rax
float v94; // xmm0_4
double v95; // xmm0_8
__int64 v96; // rbx
const cocos2d::CCSize *v97; // rax
cocos2d::CCPoint v98; // rax
GameManager *v99; // rcx
__int64 v100; // rbx
struct cocos2d::CCDelayTime *v101; // rax
struct cocos2d::CCSequence *v102; // rax
cocos2d::ccColor3B *v103; // r8
float v104; // [rsp+28h] [rbp-E0h]
float v105; // [rsp+28h] [rbp-E0h]
float v106; // [rsp+28h] [rbp-E0h]
__int64 v107; // [rsp+48h] [rbp-C0h] BYREF
__int64 v108[2]; // [rsp+50h] [rbp-B8h] BYREF
float v109; // [rsp+60h] [rbp-A8h]
__int64 v110; // [rsp+68h] [rbp-A0h] BYREF
struct cocos2d::CCPoint Src; // [rsp+70h] [rbp-98h] BYREF
_QWORD Src_8[4]; // [rsp+78h] [rbp-90h] BYREF
void *Block[2]; // [rsp+98h] [rbp-70h] BYREF
__int64 v114; // [rsp+A8h] [rbp-60h]
unsigned __int64 v115; // [rsp+B0h] [rbp-58h]
struct cocos2d::_ccTexParams v116; // [rsp+B8h] [rbp-50h] BYREF
cocos2d::ParticleStruct v117; // [rsp+C8h] [rbp-40h] BYREF
result = cocos2d::CCLayer::init(a1);
if ( result )
{
v108[0] = (__int64)Block;
v114 = 11;
v115 = 15;
Block[0] = (void *)0x2E31307265776F74LL;
Block[1] = (void *)3371117;
if ( !qword_1406C2ED8 )
{
Src = (struct cocos2d::CCPoint)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(*(_QWORD *)&Src);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
}
GameManager::fadeInMusic(v4, (__int64)Block);
v6 = (cocos2d::CCArray *)cocos2d::CCArray::create(v5);
a1->m_godRays = v6;
cocos2d::CCObject::retain(v6);
v7 = (cocos2d::CCTextureCache *)cocos2d::CCTextureCache::sharedTextureCache();
cocos2d::CCTextureCache::addImage(v7, "TowerSheet.png", 0);
v9 = (cocos2d::CCSpriteFrameCache *)cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache(v8);
cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile(v9, "TowerSheet.plist");
LOBYTE(v10) = 1;
a1->setKeypadEnabled(a1, v10);
LOBYTE(v11) = 1;
a1->setKeyboardEnabled(a1, v11);
v13 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v12);
cocos2d::CCDirector::getWinSize(v13);
v14 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_03_001.png");
v15 = CCMenuItemSpriteExtra::create(v14, nullptr, a1, (cocos2d::SEL_MenuHandler *)LevelAreaLayer::onBack);
HIDWORD(v15->m_pfnSelector.adj) = 1070386381;
v16 = cocos2d::CCMenu::create(v15, 0);
a1->addChild_0(a1, v16, 1);
v17 = v16->cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v19 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v18);
cocos2d::CCDirector::getScreenTop(v19);
v21 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v20);
v22 = cocos2d::CCDirector::getScreenLeft(v21) + 24.0;
cocos2d::CCPoint::CCPoint(v22, v22);
v17->setPosition_0(v16, v23);
if ( *(_BYTE *)(cocos2d::CCApplication::sharedApplication(v25, v24) + 197) )
GameToolbox::addBackButton(a1, v15);
v26 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v108[0] = (__int64)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v108[0]);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v26 = (GameManager *)qword_1406C2ED8;
}
GameManager::loadBackground(v26, 23);
v27 = cocos2d::CCString::createWithFormat("game_bg_%02d_001.png", 23);
CString = cocos2d::CCString::getCString(v27);
v29 = cocos2d::CCSprite::create(CString);
v116.minFilter = 9729;
v116.magFilter = 9729;
v116.wrapS = 10497;
v116.wrapT = 10497;
v30 = v29->getTexture(&v29->cocos2d::CCTextureProtocol);
cocos2d::CCTexture2D::setTexParameters(v30, &v116);
v31 = ((float (__fastcall *)(LevelAreaLayer *, struct cocos2d::CCSprite *, __int64))a1->addChild_0)(
a1,
v29,
4294967293LL);
v32 = v29->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v31, 0.0);
v32->setAnchorPoint(v29, v33);
v34 = ((float (__fastcall *)(struct cocos2d::CCSprite *))v29->setScale_0)(v29);
v35 = v29->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v36 = cocos2d::CCPoint::CCPoint(v34, 0.0);
v35->setPosition_0(v29, v37);
LOWORD(v107) = 15360;
BYTE2(v107) = -76;
v29->setColor(&v29->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v107);
Src.x = 2.3509528e-38;
LODWORD(v107) = -1761607936;
v38 = (CCLightFlash *)cocos2d::CCLayerGradient::create(
(const struct cocos2d::_ccColor4B *)&v107,
(const struct cocos2d::_ccColor4B *)&Src);
v108[0] = 0x100000302LL;
v39 = v38->__vftable;
cocos2d::CCPoint::CCPoint(*(float *)&v36, 0.0);
v39->setAnchorPoint(v38, v40);
(**(void (__fastcall ***)(__int64, __int64))&v38[1].m_fVertexZ)((__int64)&v38[1].m_fVertexZ, v108[0]);
BYTE1(v38[1].m_pGrid) = 1;
((void (__fastcall *)(CCLightFlash *))v38->setScaleY)(v38);
((void (__fastcall *)(CCLightFlash *))v38->__vftable[1].setScale_0)(v38);
a1->addChild_0(a1, v38, 2);
v41 = cocos2d::CCFadeTo::create(3.0, 0xFFu);
v42 = cocos2d::CCEaseInOut::create(v41, 2.0);
v43 = cocos2d::CCFadeTo::create(3.0, 0x96u);
v44 = cocos2d::CCEaseInOut::create(v43, 2.0);
v45 = cocos2d::CCSequence::create(v42, v44, 0);
v46 = cocos2d::CCRepeatForever::create(v45);
cocos2d::CCNode::runAction(v38, (cocos2d::CCPoint)v46, v47, v1, v104);
v48 = cocos2d::CCSprite::createWithSpriteFrameName("theTower_01_001.png");
a1->m_towerSprite = v48;
a1->addChild_0(a1, v48, 1);
v49 = ((float (__fastcall *)(cocos2d::CCSprite *))a1->m_towerSprite->setScale_0)(a1->m_towerSprite);
v50 = a1->m_towerSprite->__vftable;
cocos2d::CCPoint::CCPoint(v49, v109 * 0.5);
v50->setPosition_0(a1->m_towerSprite, v51);
v52 = cocos2d::CCSprite::createWithSpriteFrameName("whiteSquare60_001.png");
((void (__fastcall *)(struct cocos2d::CCSprite *))v52->setScaleX)(v52);
((void (__fastcall *)(struct cocos2d::CCSprite *))v52->setScaleY)(v52);
v53 = CCMenuItemSpriteExtra::create(v52, nullptr, a1, (cocos2d::SEL_MenuHandler *)LevelAreaLayer::onClickDoor);
Src_8[1] = 26471;
Src_8[2] = 10;
Src_8[3] = 15;
Src_8[0] = 0x6F2E3230726F6F64LL;
v108[1] = (__int64)Src_8;
if ( &v53->m_animationEnabled != (bool *)Src_8 )
sub_14003CCE0((void **)&v53->m_animationEnabled, Src_8, 0xAu);
sub_14003A830((__int64)Src_8);
v54 = cocos2d::CCMenu::create(v53, 0);
v55 = ((float (__fastcall *)(LevelAreaLayer *, struct cocos2d::CCMenu *, __int64))a1->addChild_0)(a1, v54, 10);
cocos2d::CCPoint::CCPoint(v55, 0.0);
v56 = a1->m_towerSprite->getPosition_0(a1->m_towerSprite);
cocos2d::CCPoint::operator+(v56, v108);
v57 = v53->cocos2d::CCMenuItemSprite::cocos2d::CCMenuItem::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v58 = cocos2d::CCNode::convertToNodeSpace(v54, &Src);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v57->setPosition_0)(v53, v58);
v52->setOpacity(&v52->cocos2d::CCRGBAProtocol, 0);
v59 = 0;
LOWORD(v107) = 0;
do
{
v60 = cocos2d::CCSprite::createWithSpriteFrameName("godray01_001.png");
v61 = &v60->cocos2d::CCRGBAProtocol;
v60->setColor(&v60->cocos2d::CCRGBAProtocol, &stru_140529B0C);
a1->addChild_0(a1, v60, -1);
((void (__fastcall *)(struct cocos2d::CCSprite *))v60->setScaleX)(v60);
v62 = ((double (__fastcall *)(struct cocos2d::CCSprite *))v60->setScaleY)(v60);
((void (__fastcall *)(struct cocos2d::CCSprite *))v60->setRotation)(v60);
if ( v59 )
v63 = v109;
else
v63 = 0.0;
v64 = v60->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(*(float *)&v62, v63);
v64->setPosition_0(v60, v65);
LOBYTE(v66) = 125;
v61->setOpacity(v61, v66);
LOWORD(v107) = 0;
BYTE2(v107) = 50;
v61->setColor(v61, (const cocos2d::ccColor3B *)&v107);
++v59;
}
while ( v59 < 2 );
v67 = cocos2d::CCSprite::createWithSpriteFrameName("godray01_001.png");
v68 = &v67->cocos2d::CCRGBAProtocol;
v67->setColor(&v67->cocos2d::CCRGBAProtocol, &stru_140529B0C);
a1->addChild_0(a1, v67, -1);
((void (__fastcall *)(struct cocos2d::CCSprite *))v67->setScaleX)(v67);
v69 = ((float (__fastcall *)(struct cocos2d::CCSprite *))v67->setScaleY)(v67);
v70 = v67->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v69, v109 * 0.5);
v70->setPosition_0(v67, v71);
LOBYTE(v72) = 125;
v68->setOpacity(v68, v72);
LOWORD(v107) = 0;
BYTE2(v107) = 50;
v73 = ((float (__fastcall *)(cocos2d::CCRGBAProtocol *, __int64 *))v68->setColor)(v68, &v107);
cocos2d::CCPoint::CCPoint(v73, 0.0);
v74 = a1->m_towerSprite->getPosition_0(a1->m_towerSprite);
cocos2d::CCPoint::operator+(v74, v108);
v75 = ((float (__fastcall *)(cocos2d::CCSprite *, __int64 *))a1->m_towerSprite->setPosition_0)(
a1->m_towerSprite,
v108);
cocos2d::CCPoint::CCPoint(v75, 0.0);
v77 = cocos2d::CCMoveBy::create(2.0, v76);
v78 = cocos2d::CCEaseInOut::create(v77, 2.0);
cocos2d::CCPoint::CCPoint(2.0, 0.0);
v80 = cocos2d::CCMoveBy::create(2.0, v79);
v81 = cocos2d::CCEaseInOut::create(v80, 2.0);
v82 = cocos2d::CCSequence::create(v78, v81, 0);
v83 = cocos2d::CCRepeatForever::create(v82);
cocos2d::CCNode::runAction((CCLightFlash *)a1->m_towerSprite, (cocos2d::CCPoint)v83, v84, v1, v105);
v85 = cocos2d::CCPoint::CCPoint(2.0, v109 * 0.5);
cocos2d::CCPoint::CCPoint(*(float *)&v85, 0.0);
v86 = cocos2d::CCPoint::operator+(&v110, v108);
LevelAreaLayer::addGodRay(a1, 50.0, 0.0, 125.0, 5.0, 4.0, (cocos2d::CCPoint)v108);
cocos2d::CCPoint::CCPoint(*(float *)&v86, 0.0);
v87 = cocos2d::CCPoint::operator+(&v110, v108);
LevelAreaLayer::addGodRay(a1, 25.0, 125.0, 0.0, 3.0, 2.5, (cocos2d::CCPoint)v108);
cocos2d::CCPoint::CCPoint(*(float *)&v87, 0.0);
v88 = cocos2d::CCPoint::operator+(&v110, v108);
LevelAreaLayer::addGodRay(a1, 125.0, 25.0, 125.0, 4.0, 3.0, (cocos2d::CCPoint)v108);
cocos2d::CCPoint::CCPoint(*(float *)&v88, 0.0);
cocos2d::CCPoint::operator+(&v110, v108);
LevelAreaLayer::addGodRay(a1, 75.0, 0.0, 100.0, 6.0, 2.5, (cocos2d::CCPoint)v108);
cocos2d::CCPoint::CCPoint(6.0, 0.0);
cocos2d::CCPoint::operator+(&v110, v108);
LevelAreaLayer::addGodRay(a1, 0.0, 100.0, 25.0, 5.0, 3.5, (cocos2d::CCPoint)v108);
cocos2d::CCPoint::CCPoint(3.5, 0.0);
cocos2d::CCPoint::operator+(&v110, v108);
LevelAreaLayer::addGodRay(a1, 0.0, 75.0, 25.0, 4.5, 2.5, (cocos2d::CCPoint)v108);
*(_OWORD *)Block = 0;
v114 = 0;
v115 = 15;
Block[0] = sub_14003AA10(0xA0u);
v114 = 159;
v115 = 159;
strcpy(
(char *)Block[0],
"60a-1a8a2a6a90a90a0a2a45a70a0a0a0a0a0a0a1a0a0a0a1a0a0.886275a0a0a0a0a0.7a1a0a0a0a1a0a0.552941a0a0a0a0a0.7a2a0a2a0a"
"0a0a0a0a0a0a0a2a1a0a0a0a0a0a0a0a0a0a0a0a0a0a0");
if ( v114 )
{
sub_140063B90((__int64)&v117);
GameToolbox::particleStringToStruct((__int64 *)Block, (__int64)&v117);
v89 = GameToolbox::particleFromStruct(&v117, nullptr, 0);
sub_14003A830((__int64)&v117.sFrame);
}
else
{
v89 = nullptr;
}
if ( v115 > 0xF )
{
v90 = Block[0];
if ( v115 + 1 >= 0x1000 )
{
v90 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v90 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v90);
}
v114 = 0;
v115 = 15;
LOBYTE(Block[0]) = 0;
a1->addChild_0(a1, v89, 0);
v91 = ((float (__fastcall *)(cocos2d::CCParticleSystemQuad *))v89->setRotation)(v89);
v92 = v89->cocos2d::CCParticleSystem::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v91, 100.0);
v94 = ((float (__fastcall *)(cocos2d::CCParticleSystemQuad *, __int64))v92->setPosVar)(v89, v93);
cocos2d::CCPoint::CCPoint(v94, -100.0);
v95 = cocos2d::CCPoint::operator+(&v110, v108);
v89->setPosition_0(v89, (const cocos2d::CCPoint *)v108);
v96 = 20;
do
{
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *))v89->update)(v89);
--v96;
}
while ( v96 );
a1->m_towerSprite->getContentSize(a1->m_towerSprite);
v97 = a1->m_towerSprite->getContentSize(a1->m_towerSprite);
cocos2d::CCPoint::CCPoint(*(float *)&v95, (float)(v97->width * 0.5) + 35.0);
LevelAreaLayer::addTorch(a1->m_towerSprite, v98, 1, 0.40000001, 6, 0, 0, nullptr);
v99 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v108[0] = (__int64)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v108[0]);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v99 = (GameManager *)qword_1406C2ED8;
}
if ( !GameManager::getUGV(v99, (const char *)&word_14055A524) )
{
a1->m_enteringTower = 1;
v100 = cocos2d::CCCallFunc::create(a1, LevelAreaLayer::showDialog);
v101 = cocos2d::CCDelayTime::create(1.2);
v102 = cocos2d::CCSequence::create(v101, v100, 0);
cocos2d::CCNode::runAction((CCLightFlash *)a1, (cocos2d::CCPoint)v102, v103, 0.40000001, v106);
}
return 1;
}
return result;
}