//
// LevelAreaLayer::init from 0xa2f638 to 0xa30350 (3352 bytes)
//
// 3 xrefs:
// > LevelAreaLayer::create @ 0xa30408
// > ??> @ 0xabaf8
// > ??> @ 0x11da130
//
// 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 LevelAreaLayer::init(LevelAreaLayer *a1)
{
bool v2; // w25
GameManager *v4; // x19
cocos2d::CCArray *v5; // x0
cocos2d::CCArray *v6; // x0
cocos2d::CCTextureCache *v7; // x0
cocos2d::CCSpriteFrameCache *v8; // x0
cocos2d::CCDirector *v9; // x0
cocos2d::CCSprite *v10; // x0
CCMenuItemSpriteExtra *v11; // x27
cocos2d::CCNode *v12; // x24
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x28
cocos2d::CCDirector *v14; // x0
float v15; // s0
float v16; // s8
cocos2d::CCDirector *v17; // x0
float v18; // s0
GameManager *v19; // x0
cocos2d::CCSprite *BGTexture; // x0
const char *v21; // x1
cocos2d::CCNode *v22; // x0
cocos2d::CCNode_vtbl *v23; // x6
__int64 (*setScale_0)(void); // x2
cocos2d::CCNode *v25; // x27
cocos2d::CCTexture2D *v26; // x0
void (__fastcall *setAnchorPoint)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x26
void (__fastcall *v28)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x26
int (__fastcall *getTag)(const cocos2d::CCObject *__hidden); // x2
cocos2d::CCNode *v30; // x26
cocos2d::CCNode_vtbl *v31; // x1
cocos2d::CCFadeTo *v32; // x0
cocos2d::CCFadeTo *v33; // x0
cocos2d::CCEaseInOut *v34; // x0
cocos2d::CCActionInterval *v35; // x0
cocos2d::CCRepeatForever *v36; // x0
cocos2d::CCSprite *v37; // x0
cocos2d::CCSprite *m_towerSprite; // x26
void (__fastcall *v39)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x27
cocos2d::CCSprite *v40; // x26
CCMenuItemSpriteExtra *v41; // x28
void *v42; // x0
int v43; // w27
cocos2d::CCSprite *v44; // x28
float v45; // s0
void (__fastcall *setColor)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x2
cocos2d::CCSprite *v47; // x28
void (__fastcall *v48)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x27
void (__fastcall *v49)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x2
cocos2d::CCSprite *v50; // x26
void (__fastcall *v51)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x27
__int64 v52; // x28
cocos2d::CCMoveBy *v53; // x0
cocos2d::CCEaseInOut *v54; // x26
cocos2d::CCMoveBy *v55; // x0
cocos2d::CCEaseInOut *v56; // x0
cocos2d::CCActionInterval *v57; // x0
cocos2d::CCRepeatForever *v58; // x0
cocos2d::CCParticleSystemQuad *v59; // x26
void *v60; // x28
int v61; // w23
void (__fastcall *setPosVar)(cocos2d::CCParticleSystem *__hidden, const cocos2d::CCPoint *); // x27
void (__fastcall *v63)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x27
const cocos2d::CCSize *v64; // x0
cocos2d::CCSprite *v65; // x21
__int64 v66; // x0
float v67; // s2
GameManager *v68; // x0
bool UGV; // w0
cocos2d::CCSequence *v70; // x19
cocos2d::CCFiniteTimeAction *v71; // x0
cocos2d::CCAction *v72; // x0
unsigned int *v73; // x27
int v74; // w0
unsigned int *v75; // x1
int v76; // w2
unsigned int *v77; // x1
int v78; // w2
cocos2d::CCNode *v79; // [xsp+88h] [xbp+88h]
void (__fastcall *v80)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // [xsp+90h] [xbp+90h]
void (__fastcall *v81)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // [xsp+A0h] [xbp+A0h]
cocos2d::CCEaseInOut *v82; // [xsp+A0h] [xbp+A0h]
const cocos2d::CCPoint *v83; // [xsp+A0h] [xbp+A0h]
void (__fastcall *v84)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // [xsp+A0h] [xbp+A0h]
float v85; // [xsp+A0h] [xbp+A0h]
float v86; // [xsp+B8h] [xbp+B8h]
float v87; // [xsp+BCh] [xbp+BCh]
cocos2d::CCPoint v88; // [xsp+C0h] [xbp+C0h] BYREF
cocos2d::CCPoint v89; // [xsp+C8h] [xbp+C8h] BYREF
cocos2d::CCPoint v90; // [xsp+D0h] [xbp+D0h] BYREF
cocos2d::ccTexParams v91; // [xsp+D8h] [xbp+D8h] BYREF
cocos2d::CCPoint v92; // 0:kr08_8.8
cocos2d::SEL_MenuHandler v93; // 0:x2.16
cocos2d::SEL_MenuHandler v94; // 0:x2.16
cocos2d::CCPoint v95; // 0:s0.4,4:s1.4
cocos2d::CCPoint v96; // 0:s5.4,4:s6.4
cocos2d::CCPoint v97; // 0:s5.4,4:s6.4
cocos2d::CCPoint v98; // 0:s5.4,4:s6.4
cocos2d::CCPoint v99; // 0:s5.4,4:s6.4
cocos2d::CCPoint v100; // 0:s5.4,4:s6.4
cocos2d::CCPoint v101; // 0:s5.4,4:s6.4
v2 = cocos2d::CCLayer::init(a1);
if ( v2 )
{
v4 = GameManager::sharedState();
sub_D153B8((int)&v91, "tower01.mp3");
GameManager::fadeInMusic((__int64)v4, &v91);
v5 = (cocos2d::CCArray *)(*(_QWORD *)&v91.minFilter - 24LL);
if ( (__int64 *)(*(_QWORD *)&v91.minFilter - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v77 = (unsigned int *)(*(_QWORD *)&v91.minFilter - 8LL);
do
v78 = __ldaxr(v77);
while ( __stlxr(v78 - 1, v77) );
}
else
{
v78 = *(_DWORD *)(*(_QWORD *)&v91.minFilter - 8LL);
*(_DWORD *)(*(_QWORD *)&v91.minFilter - 8LL) = v78 - 1;
}
if ( v78 <= 0 )
operator delete(v5);
}
v6 = (cocos2d::CCArray *)cocos2d::CCArray::create(v5);
a1->m_godRays = v6;
cocos2d::CCObject::retain(v6);
v7 = cocos2d::CCTextureCache::sharedTextureCache();
cocos2d::CCTextureCache::addImage(v7, "TowerSheet.png", 0);
v8 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile(v8, "TowerSheet.plist");
a1->setKeypadEnabled(a1, 1);
a1->setKeyboardEnabled(a1, 1);
v9 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v9);
v10 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_03_001.png");
v93.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v93.adj = (size_t)LevelAreaLayer::onBack;
v11 = CCMenuItemSpriteExtra::create(v10, nullptr, v93);
CCMenuItemSpriteExtra::setSizeMult(v11, 1.6);
v12 = (cocos2d::CCNode *)cocos2d::CCMenu::create((cocos2d::CCMenu *)v11, nullptr);
a1->addChild_0(a1, v12, 1);
setPosition = v12->setPosition;
v14 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenLeft(v14);
v16 = v15;
v17 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenTop(v17);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v91, v16 + 24.0, v18 - 23.0);
setPosition(v12, (const cocos2d::CCPoint *)&v91);
if ( PlatformToolbox::isControllerConnected() )
GameToolbox::addBackButton(a1, v11);
v19 = GameManager::sharedState();
BGTexture = (cocos2d::CCSprite *)GameManager::getBGTexture(v19, 23);
v22 = (cocos2d::CCNode *)cocos2d::CCSprite::create(BGTexture, v21);
v23 = v22->__vftable;
*(_QWORD *)&v91.minFilter = 0x260100002601LL;
setScale_0 = (__int64 (*)(void))v23[1].setScale_0;
v25 = v22;
v91.wrapS = 10497;
v91.wrapT = 10497;
v26 = (cocos2d::CCTexture2D *)setScale_0();
cocos2d::CCTexture2D::setTexParameters(v26, &v91);
a1->addChild_0(a1, v25, -3);
setAnchorPoint = v25->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v90, 0.0, 0.0);
setAnchorPoint(v25, &v90);
v25->setScale(v25, v86 / v25[1].m_obContentSize.height);
v28 = v25->setPosition;
cocos2d::CCPoint::CCPoint(&v90, 0.0, -50.0);
v28(v25, &v90);
getTag = v25->__vftable[1].getTag;
LOWORD(v90.x) = 15360;
BYTE2(v90.x) = -76;
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCPoint *))getTag)(v25, &v90);
v89.x = -4.1358e-25;
v90.x = 2.351e-38;
v30 = (cocos2d::CCNode *)cocos2d::CCLayerGradient::create(
(cocos2d::CCLayerGradient *)&v89,
(const cocos2d::_ccColor4B *)&v90,
(const cocos2d::_ccColor4B *)0xFFFFFF96LL);
v81 = v30->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v90, 0.0, 1.0);
v81(v30, &v90);
v30->__vftable[1].setOrderOfArrival(v30, 0x302u);
v31 = v30->__vftable;
BYTE1(v30[1].m_pShaderProgram) = 1;
v31->setScaleY(v30, 0.7);
v30->__vftable[1].getOrderOfArrival(v30);
a1->addChild_0(a1, v30, 2);
v32 = cocos2d::CCFadeTo::create(3.0, 0xFFu);
v82 = cocos2d::CCEaseInOut::create(v32, 2.0);
v33 = cocos2d::CCFadeTo::create(3.0, 0x96u);
v34 = cocos2d::CCEaseInOut::create(v33, 2.0);
v35 = (cocos2d::CCActionInterval *)cocos2d::CCSequence::create((cocos2d::CCSequence *)v82, v34, 0);
v36 = cocos2d::CCRepeatForever::create(v35);
cocos2d::CCNode::runAction(v30, v36);
v37 = cocos2d::CCSprite::createWithSpriteFrameName("theTower_01_001.png");
a1->m_towerSprite = v37;
a1->addChild_0(a1, v37, 1);
a1->m_towerSprite->setScale(a1->m_towerSprite, 1.0);
m_towerSprite = a1->m_towerSprite;
v39 = m_towerSprite->setPosition;
cocos2d::CCPoint::CCPoint(&v90, v86 * 0.5, v87 * 0.5);
v39(m_towerSprite, &v90);
v40 = cocos2d::CCSprite::createWithSpriteFrameName("whiteSquare60_001.png");
v40->setScaleX(v40, 2.0);
v40->setScaleY(v40, 2.2);
v94.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v94.adj = (size_t)LevelAreaLayer::onClickDoor;
v41 = CCMenuItemSpriteExtra::create(v40, nullptr, v94);
sub_D153B8((int)&v90, "door02.ogg");
sub_D18EA8(&v41->m_activateSound, &v90);
v42 = (void *)(*(_QWORD *)&v90 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v90 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v75 = (unsigned int *)(*(_QWORD *)&v90 - 8LL);
do
v76 = __ldaxr(v75);
while ( __stlxr(v76 - 1, v75) );
}
else
{
v76 = *(_DWORD *)(*(_QWORD *)&v90 - 8LL);
*(_DWORD *)(*(_QWORD *)&v90 - 8LL) = v76 - 1;
}
if ( v76 <= 0 )
operator delete(v42);
}
v43 = 0;
v79 = (cocos2d::CCNode *)cocos2d::CCMenu::create((cocos2d::CCMenu *)v41, nullptr);
a1->addChild_0(a1, v79, 10);
v80 = v41->setPosition;
v83 = a1->m_towerSprite->getPosition(a1->m_towerSprite);
cocos2d::CCPoint::CCPoint(&v88, 0.0, -75.0);
cocos2d::CCPoint::operator+(&v89, v83, &v88);
v92 = cocos2d::CCNode::convertToNodeSpace(v79, &v89);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCPoint *, float, float))v80)(v41, &v90, v92.x, v92.y);
v40->setOpacity(v40, 0);
while ( 1 )
{
v44 = cocos2d::CCSprite::createWithSpriteFrameName("godray01_001.png");
v44->setColor(v44, (const cocos2d::ccColor3B *)algn_F0F128);
a1->addChild_0(a1, v44, -1);
v44->setScaleX(v44, v87 / v44->m_obRect.size.width);
v44->setScaleY(v44, 3.0);
v44->setRotation(v44, 90.0);
v45 = v43 ? v86 : 0.0;
v84 = v44->setPosition;
cocos2d::CCPoint::CCPoint(&v90, v45, v87 * 0.5);
v84(v44, &v90);
v44->setOpacity(v44, 125);
setColor = v44->setColor;
LOWORD(v90.x) = 0;
BYTE2(v90.x) = 50;
setColor(v44, (const cocos2d::ccColor3B *)&v90);
if ( v43 )
break;
v43 = 1;
}
v47 = cocos2d::CCSprite::createWithSpriteFrameName("godray01_001.png");
v47->setColor(v47, (const cocos2d::ccColor3B *)algn_F0F128);
a1->addChild_0(a1, v47, -1);
v47->setScaleX(v47, v86 / v47->m_obRect.size.width);
v47->setScaleY(v47, 1.0);
v48 = v47->setPosition;
cocos2d::CCPoint::CCPoint(&v90, v86 * 0.5, 0.0);
v48(v47, &v90);
v47->setOpacity(v47, 125);
v49 = v47->setColor;
LOBYTE(v90.x) = 0;
*(_WORD *)((char *)&v90.x + 1) = 12800;
v49(v47, (const cocos2d::ccColor3B *)&v90);
v50 = a1->m_towerSprite;
v51 = v50->setPosition;
v52 = (__int64)v50->getPosition(v50);
cocos2d::CCPoint::CCPoint(&v89, 0.0, -2.0);
cocos2d::CCPoint::operator+(&v90, v52, &v89);
v51(v50, &v90);
cocos2d::CCPoint::CCPoint(&v90, 0.0, 4.0);
v53 = cocos2d::CCMoveBy::create(2.0, &v90);
v54 = cocos2d::CCEaseInOut::create(v53, 2.0);
cocos2d::CCPoint::CCPoint(&v90, 0.0, -4.0);
v55 = cocos2d::CCMoveBy::create(2.0, &v90);
v56 = cocos2d::CCEaseInOut::create(v55, 2.0);
v57 = (cocos2d::CCActionInterval *)cocos2d::CCSequence::create((cocos2d::CCSequence *)v54, v56, 0);
v58 = cocos2d::CCRepeatForever::create(v57);
cocos2d::CCNode::runAction(a1->m_towerSprite, v58);
cocos2d::CCPoint::CCPoint(&v88, v86 * 0.5, (float)(v87 * 0.5) + 13.0);
cocos2d::CCPoint::CCPoint(&v89, 0.0, 0.0);
cocos2d::CCPoint::operator+(&v90, &v88, &v89);
LevelAreaLayer::addGodRay(a1, 50.0, 0.0, 125.0, 5.0, 4.0, v96);
cocos2d::CCPoint::CCPoint(&v89, 0.0, 10.0);
cocos2d::CCPoint::operator+(&v90, &v88, &v89);
LevelAreaLayer::addGodRay(a1, 25.0, 125.0, 0.0, 3.0, 2.5, v97);
cocos2d::CCPoint::CCPoint(&v89, 0.0, 20.0);
cocos2d::CCPoint::operator+(&v90, &v88, &v89);
LevelAreaLayer::addGodRay(a1, 125.0, 25.0, 125.0, 4.0, 3.0, v98);
cocos2d::CCPoint::CCPoint(&v89, 0.0, -20.0);
cocos2d::CCPoint::operator+(&v90, &v88, &v89);
LevelAreaLayer::addGodRay(a1, 75.0, 0.0, 100.0, 6.0, 2.5, v99);
cocos2d::CCPoint::CCPoint(&v89, 0.0, -10.0);
cocos2d::CCPoint::operator+(&v90, &v88, &v89);
LevelAreaLayer::addGodRay(a1, 0.0, 100.0, 25.0, 5.0, 3.5, v100);
cocos2d::CCPoint::CCPoint(&v89, 0.0, 10.0);
cocos2d::CCPoint::operator+(&v90, &v88, &v89);
LevelAreaLayer::addGodRay(a1, 0.0, 75.0, 25.0, 4.5, 2.5, v101);
sub_D153B8(
(int)&v90,
"60a-1a8a2a6a90a90a0a2a45a70a0a0a0a0a0a0a1a0a0a0a1a0a0.886275a0a0a0a0a0.7a1a0a0a0a1a0a0.552941a0a0a0a0a0.7a2a0a2a0a"
"0a0a0a0a0a0a0a2a1a0a0a0a0a0a0a0a0a0a0a0a0a0a0");
v59 = GameToolbox::particleFromString(&v90, nullptr, 0);
v60 = (void *)(*(_QWORD *)&v90 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v90 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v73 = (unsigned int *)(*(_QWORD *)&v90 - 8LL);
do
v74 = __ldaxr(v73);
while ( __stlxr(v74 - 1, v73) );
}
else
{
v74 = *(_DWORD *)(*(_QWORD *)&v90 - 8LL);
*(_DWORD *)(*(_QWORD *)&v90 - 8LL) = v74 - 1;
}
if ( v74 <= 0 )
operator delete(v60);
}
v61 = 20;
a1->addChild_0(a1, v59, 0);
v59->setRotation(v59, 30.0);
setPosVar = v59->setPosVar;
cocos2d::CCPoint::CCPoint(&v90, 100.0, 40.0);
setPosVar(v59, &v90);
v63 = v59->setPosition;
cocos2d::CCPoint::CCPoint(&v89, -100.0, 60.0);
cocos2d::CCPoint::operator+(&v90, &v88, &v89);
v63(v59, &v90);
do
{
v59->update(v59, 0.2);
--v61;
}
while ( v61 );
v64 = a1->m_towerSprite->getContentSize(a1->m_towerSprite);
v65 = a1->m_towerSprite;
v85 = (float)(v64->width * 0.5) + 35.0;
v66 = (__int64)v65->getContentSize(v65);
cocos2d::CCPoint::CCPoint(&v90, v85, (float)(*(float *)(v66 + 4) * 0.5) + -69.5);
v95.x = 0.4;
LevelAreaLayer::addTorch(v65, v95, (int)&v90, v67, 1, 6, 0, nullptr);
v68 = GameManager::sharedState();
UGV = GameManager::getUGV(v68, "29");
if ( UGV )
{
return UGV;
}
else
{
a1->m_enteringTower = (unsigned __int8)&dword_0 + 1;
v70 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create(1.2);
v71 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCCallFunc::create(a1, LevelAreaLayer::showDialog, 0);
v72 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v70, v71, 0);
cocos2d::CCNode::runAction(a1, v72);
}
}
return v2;
}