//
// LevelAreaLayer::init from 0x56c7f4 to 0x56d040 (2124 bytes)
//
// 1 xrefs:
// > LevelAreaLayer::create @ 0x56c008
//
// 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)
{
_BOOL4 v2; // r8
GameManager *v3; // r6
int v4; // r2
int v5; // r3
cocos2d::CCArray *v6; // r0
cocos2d::CCArray *v7; // r0
cocos2d::CCTextureCache *v8; // r0
cocos2d::CCSpriteFrameCache *v9; // r0
cocos2d::CCDirector *v10; // r0
cocos2d::CCSprite *v11; // r0
CCMenuItemSpriteExtra *v12; // r9
cocos2d::CCNode *v13; // r6
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r10
cocos2d::CCDirector *v15; // r0
float v16; // s16
cocos2d::CCDirector *v17; // r0
float v18; // r0
GameManager *v19; // r0
cocos2d::CCSprite *BGTexture; // r0
const char *v21; // r1
cocos2d::CCNode *v22; // r6
cocos2d::CCTexture2D *v23; // r0
void (__fastcall *setAnchorPoint)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r7
void (__fastcall *v25)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r7
int (__fastcall *getTag)(const cocos2d::CCObject *__hidden); // r3
const cocos2d::_ccColor4B *v27; // r2
cocos2d::CCNode *v28; // r6
cocos2d::CCNode_vtbl *v29; // r2
cocos2d::CCNode_vtbl *v30; // r3
cocos2d::CCFadeTo *v31; // r0
cocos2d::CCEaseInOut *v32; // r10
cocos2d::CCFadeTo *v33; // r0
cocos2d::CCEaseInOut *v34; // r0
cocos2d::CCActionInterval *v35; // r0
cocos2d::CCRepeatForever *v36; // r0
cocos2d::CCSprite *v37; // r0
LevelAreaLayer_vtbl *v38; // r3
cocos2d::CCSprite *m_towerSprite; // r6
void (__fastcall *v40)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r9
cocos2d::CCSprite *v41; // r6
CCMenuItemSpriteExtra *v42; // r7
cocos2d::CCNode *v43; // r10
int v44; // r11
cocos2d::CCSprite *v45; // r6
void (__fastcall *v46)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r7
float v47; // r1
void (__fastcall *setColor)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // r2
cocos2d::CCSprite *v49; // r6
void (__fastcall *v50)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r10
void (__fastcall *v51)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // r3
cocos2d::CCSprite *v52; // r9
void (__fastcall *v53)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // r10
int v54; // r11
cocos2d::CCMoveBy *v55; // r0
cocos2d::CCEaseInOut *v56; // r9
cocos2d::CCMoveBy *v57; // r0
cocos2d::CCEaseInOut *v58; // r0
cocos2d::CCActionInterval *v59; // r0
cocos2d::CCRepeatForever *v60; // r0
cocos2d::CCParticleSystemQuad *v61; // r7
void (__fastcall *setPosVar)(cocos2d::CCParticleSystem *__hidden, const cocos2d::CCPoint *); // r10
void (__fastcall *v63)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // r10
int v64; // r6
const cocos2d::CCSize *v65; // r0
cocos2d::CCSprite *v66; // r7
float width; // s15
int v68; // r0
cocos2d::CCPoint v69; // r1
GameManager *v70; // r0
_BOOL4 UGV; // r0
cocos2d::CCDelayTime *v72; // r0
cocos2d::CCSequence *v73; // r7
cocos2d::CCFiniteTimeAction *v74; // r0
cocos2d::CCAction *v75; // r0
cocos2d::CCPoint v77; // [sp+8h] [bp-6Ch]
cocos2d::CCPoint v78; // [sp+8h] [bp-6Ch]
cocos2d::CCPoint v79; // [sp+8h] [bp-6Ch]
cocos2d::CCPoint v80; // [sp+8h] [bp-6Ch]
cocos2d::CCPoint v81; // [sp+8h] [bp-6Ch]
cocos2d::CCPoint v82; // [sp+8h] [bp-6Ch]
cocos2d::CCArray *v83; // [sp+10h] [bp-64h]
void (__fastcall *v84)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // [sp+18h] [bp-5Ch]
const cocos2d::CCPoint *v85; // [sp+18h] [bp-5Ch]
void (__fastcall *v86)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // [sp+1Ch] [bp-58h]
cocos2d::CCSize v87; // [sp+24h] [bp-50h] BYREF
int v88; // [sp+2Ch] [bp-48h]
int v89; // [sp+30h] [bp-44h]
cocos2d::CCPoint v90; // [sp+34h] [bp-40h] BYREF
cocos2d::CCPoint v91; // [sp+3Ch] [bp-38h] BYREF
void (*v92)(LevelAreaLayer *, cocos2d::CCObject *); // [sp+44h] [bp-30h]
int v93; // [sp+48h] [bp-2Ch]
_DWORD v94[2]; // [sp+4Ch] [bp-28h] BYREF
cocos2d::CCPoint v95; // [sp+54h] [bp-20h] BYREF
cocos2d::ccTexParams v96; // [sp+5Ch] [bp-18h] BYREF
v2 = cocos2d::CCLayer::init(a1);
if ( v2 )
{
v3 = GameManager::sharedState();
sub_776584((int)&v96, "tower01.mp3");
GameManager::fadeInMusic((int)v3, &v96, v4, v5);
v6 = (cocos2d::CCArray *)sub_774008(&v96);
v7 = (cocos2d::CCArray *)cocos2d::CCArray::create(v6);
a1->m_godRays = v7;
cocos2d::CCObject::retain(v7);
v8 = cocos2d::CCTextureCache::sharedTextureCache();
cocos2d::CCTextureCache::addImage(v8, "TowerSheet.png", 0);
v9 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile(v9, "TowerSheet.plist");
a1->setKeypadEnabled(a1, 1);
a1->setKeyboardEnabled(a1, 1);
v10 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(&v87, v10);
v11 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_03_001.png");
v92 = LevelAreaLayer::onBack;
v93 = 0;
v12 = CCMenuItemSpriteExtra::create(
v11,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(LevelAreaLayer::onBack, (unsigned int)a1));
CCMenuItemSpriteExtra::setSizeMult(v12, 1.6);
v13 = (cocos2d::CCNode *)cocos2d::CCMenu::create((cocos2d::CCMenu *)v12, nullptr);
a1->addChild_0(a1, v13, 1);
setPosition = v13->setPosition;
v15 = cocos2d::CCDirector::sharedDirector();
v16 = COERCE_FLOAT(cocos2d::CCDirector::getScreenLeft(v15));
v17 = cocos2d::CCDirector::sharedDirector();
v18 = COERCE_FLOAT(cocos2d::CCDirector::getScreenTop(v17));
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v96, v16 + 24.0, v18 - 23.0);
setPosition(v13, (const cocos2d::CCPoint *)&v96);
if ( PlatformToolbox::isControllerConnected() )
GameToolbox::addBackButton(a1, v12);
v19 = GameManager::sharedState();
BGTexture = (cocos2d::CCSprite *)GameManager::getBGTexture(v19, 23);
v22 = (cocos2d::CCNode *)cocos2d::CCSprite::create(BGTexture, v21);
v96.minFilter = 9729;
v96.magFilter = 9729;
v96.wrapS = 10497;
v96.wrapT = 10497;
v23 = (cocos2d::CCTexture2D *)((int (__fastcall *)(cocos2d::CCNode *))v22->__vftable[1].setScale_0)(v22);
cocos2d::CCTexture2D::setTexParameters(v23, &v96);
a1->addChild_0(a1, v22, -3);
setAnchorPoint = v22->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v95, 0.0, 0.0);
setAnchorPoint(v22, &v95);
((void (__fastcall *)(cocos2d::CCNode *, _DWORD))v22->setScale)(v22, v87.width / v22[1].m_fSkewX);
v25 = v22->setPosition;
cocos2d::CCPoint::CCPoint(&v95, 0.0, -50.0);
v25(v22, &v95);
getTag = v22->__vftable[1].getTag;
LOWORD(v95.x) = 15360;
BYTE2(v95.x) = -76;
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::CCPoint *))getTag)(v22, &v95);
v94[0] = -1761607936;
v95.x = 2.351e-38;
v28 = (cocos2d::CCNode *)cocos2d::CCLayerGradient::create(
(cocos2d::CCLayerGradient *)v94,
(const cocos2d::_ccColor4B *)&v95,
v27);
v29 = v28->__vftable;
v88 = 770;
v89 = 1;
v84 = v29->setAnchorPoint;
cocos2d::CCPoint::CCPoint(&v95, 0.0, 1.0);
v84(v28, &v95);
((void (__fastcall *)(cocos2d::CCNode *, int, int))v28->__vftable[1].setOrderOfArrival)(v28, v88, v89);
v30 = v28->__vftable;
BYTE1(v28[1].m_pChildren) = 1;
((void (__fastcall *)(cocos2d::CCNode *, int))v30->setScaleY)(v28, 1060320051);
v28->__vftable[1].getOrderOfArrival(v28);
a1->addChild_0(a1, v28, 2);
v31 = cocos2d::CCFadeTo::create(3.0, 0xFFu);
v32 = cocos2d::CCEaseInOut::create(v31, 2.0);
v33 = cocos2d::CCFadeTo::create(3.0, 0x96u);
v34 = cocos2d::CCEaseInOut::create(v33, 2.0);
v35 = (cocos2d::CCActionInterval *)cocos2d::CCSequence::create((cocos2d::CCSequence *)v32, v34, 0);
v36 = cocos2d::CCRepeatForever::create(v35);
cocos2d::CCNode::runAction(v28, v36);
v37 = cocos2d::CCSprite::createWithSpriteFrameName("theTower_01_001.png");
v38 = a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_towerSprite = v37;
v38->addChild_0(a1, v37, 1);
((void (__fastcall *)(cocos2d::CCSprite *, int))a1->m_towerSprite->setScale)(a1->m_towerSprite, 1065353216);
m_towerSprite = a1->m_towerSprite;
v40 = m_towerSprite->setPosition;
cocos2d::CCPoint::CCPoint(&v95, v87.width * 0.5, v87.height * 0.5);
v40(m_towerSprite, &v95);
v41 = cocos2d::CCSprite::createWithSpriteFrameName("whiteSquare60_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, int))v41->setScaleX)(v41, 0x40000000);
((void (__fastcall *)(cocos2d::CCSprite *, int))v41->setScaleY)(v41, 1074580685);
v94[0] = LevelAreaLayer::onClickDoor;
v94[1] = 0;
v42 = CCMenuItemSpriteExtra::create(
v41,
nullptr,
(cocos2d::SEL_MenuHandler)__PAIR64__(LevelAreaLayer::onClickDoor, (unsigned int)a1));
sub_776584((int)&v95, "door02.ogg");
sub_775D40(&v42->m_activateSound, &v95);
sub_774008(&v95);
v43 = (cocos2d::CCNode *)cocos2d::CCMenu::create((cocos2d::CCMenu *)v42, nullptr);
a1->addChild_0(a1, v43, 10);
v86 = v42->setPosition;
v85 = a1->m_towerSprite->getPosition(a1->m_towerSprite);
cocos2d::CCPoint::CCPoint(&v90, 0.0, -75.0);
v44 = 0;
cocos2d::CCPoint::operator+(&v91, v85, &v90);
cocos2d::CCNode::convertToNodeSpace(&v95, v43, &v91);
v86(v42, &v95);
v41->setOpacity(v41, 0);
while ( 1 )
{
v45 = cocos2d::CCSprite::createWithSpriteFrameName("godray01_001.png");
v45->setColor(v45, &stru_9AD7B8);
a1->addChild_0(a1, v45, -1);
((void (__fastcall *)(cocos2d::CCSprite *, _DWORD))v45->setScaleX)(v45, v87.height / v45->m_obRect.size.width);
((void (__fastcall *)(cocos2d::CCSprite *, int))v45->setScaleY)(v45, 1077936128);
((void (__fastcall *)(cocos2d::CCSprite *, int))v45->setRotation)(v45, 1119092736);
v46 = v45->setPosition;
v47 = v44 ? v87.width : 0.0;
cocos2d::CCPoint::CCPoint(&v95, v47, v87.height * 0.5);
v46(v45, &v95);
v45->setOpacity(v45, 125);
setColor = v45->setColor;
LOWORD(v95.x) = 0;
BYTE2(v95.x) = 50;
setColor(v45, (const cocos2d::ccColor3B *)&v95);
if ( v44 )
break;
v44 = 1;
}
v49 = cocos2d::CCSprite::createWithSpriteFrameName("godray01_001.png");
v49->setColor(v49, &stru_9AD7B8);
a1->addChild_0(a1, v49, -1);
((void (__fastcall *)(cocos2d::CCSprite *, _DWORD))v49->setScaleX)(v49, v87.width / v49->m_obRect.size.width);
((void (__fastcall *)(cocos2d::CCSprite *, int))v49->setScaleY)(v49, 1065353216);
v50 = v49->setPosition;
cocos2d::CCPoint::CCPoint(&v95, v87.width * 0.5, 0.0);
v50(v49, &v95);
v49->setOpacity(v49, 125);
v51 = v49->setColor;
LOBYTE(v95.x) = 0;
*(_WORD *)((char *)&v95.x + 1) = 12800;
v51(v49, (const cocos2d::ccColor3B *)&v95);
v52 = a1->m_towerSprite;
v53 = v52->setPosition;
v54 = (int)v52->getPosition(v52);
cocos2d::CCPoint::CCPoint(&v91, 0.0, -2.0);
cocos2d::CCPoint::operator+(&v95, v54, &v91);
v53(v52, &v95);
cocos2d::CCPoint::CCPoint(&v95, 0.0, 4.0);
v55 = cocos2d::CCMoveBy::create(2.0, &v95);
v56 = cocos2d::CCEaseInOut::create(v55, 2.0);
cocos2d::CCPoint::CCPoint(&v95, 0.0, -4.0);
v57 = cocos2d::CCMoveBy::create(2.0, &v95);
v58 = cocos2d::CCEaseInOut::create(v57, 2.0);
v59 = (cocos2d::CCActionInterval *)cocos2d::CCSequence::create((cocos2d::CCSequence *)v56, v58, 0);
v60 = cocos2d::CCRepeatForever::create(v59);
cocos2d::CCNode::runAction(a1->m_towerSprite, v60);
cocos2d::CCPoint::CCPoint(&v90, v87.width * 0.5, (float)(v87.height * 0.5) + 13.0);
cocos2d::CCPoint::CCPoint(&v91, 0.0, 0.0);
cocos2d::CCPoint::operator+(&v95, &v90, &v91);
LODWORD(v77.x) = &v95;
LevelAreaLayer::addGodRay(a1, 50.0, 0.0, 125.0, 5.0, 4.0, v77);
cocos2d::CCPoint::CCPoint(&v91, 0.0, 10.0);
cocos2d::CCPoint::operator+(&v95, &v90, &v91);
LODWORD(v78.x) = &v95;
LevelAreaLayer::addGodRay(a1, 25.0, 125.0, 0.0, 3.0, 2.5, v78);
cocos2d::CCPoint::CCPoint(&v91, 0.0, 20.0);
cocos2d::CCPoint::operator+(&v95, &v90, &v91);
LODWORD(v79.x) = &v95;
LevelAreaLayer::addGodRay(a1, 125.0, 25.0, 125.0, 4.0, 3.0, v79);
cocos2d::CCPoint::CCPoint(&v91, 0.0, -20.0);
cocos2d::CCPoint::operator+(&v95, &v90, &v91);
LODWORD(v80.x) = &v95;
LevelAreaLayer::addGodRay(a1, 75.0, 0.0, 100.0, 6.0, 2.5, v80);
cocos2d::CCPoint::CCPoint(&v91, 0.0, -10.0);
cocos2d::CCPoint::operator+(&v95, &v90, &v91);
LODWORD(v81.x) = &v95;
LevelAreaLayer::addGodRay(a1, 0.0, 100.0, 25.0, 5.0, 3.5, v81);
cocos2d::CCPoint::CCPoint(&v91, 0.0, 10.0);
cocos2d::CCPoint::operator+(&v95, &v90, &v91);
LODWORD(v82.x) = &v95;
LevelAreaLayer::addGodRay(a1, 0.0, 75.0, 25.0, 4.5, 2.5, v82);
sub_776584(
(int)&v95,
"60a-1a8a2a6a90a90a0a2a45a70a0a0a0a0a0a0a1a0a0a0a1a0a0.886275a0a0a0a0a0.7a1a0a0a0a1a0a0.552941a0a0a0a0a0.7a2a0a2a0a"
"0a0a0a0a0a0a0a2a1a0a0a0a0a0a0a0a0a0a0a0a0a0a0");
v61 = GameToolbox::particleFromString((void **)&v95, nullptr, 0);
sub_774008(&v95);
a1->addChild_0(a1, v61, 0);
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *, int))v61->setRotation)(v61, 1106247680);
setPosVar = v61->setPosVar;
cocos2d::CCPoint::CCPoint(&v95, 100.0, 40.0);
setPosVar(v61, &v95);
v63 = v61->setPosition;
cocos2d::CCPoint::CCPoint(&v91, -100.0, 60.0);
v64 = 20;
cocos2d::CCPoint::operator+(&v95, &v90, &v91);
v63(v61, &v95);
do
{
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *, int))v61->update)(v61, 1045220557);
--v64;
}
while ( v64 );
v65 = a1->m_towerSprite->getContentSize(a1->m_towerSprite);
v66 = a1->m_towerSprite;
width = v65->width;
v68 = (int)v66->getContentSize(v66);
cocos2d::CCPoint::CCPoint(&v95, (float)(width * 0.5) + 35.0, (float)(*(float *)(v68 + 4) * 0.5) - 69.5);
LODWORD(v69.x) = &v95;
LODWORD(v69.y) = 1;
LevelAreaLayer::addTorch(v66, v69, 1053609165, COERCE_FLOAT(6), 0, 0, 0, v83);
v70 = GameManager::sharedState();
UGV = GameManager::getUGV(v70, "29");
if ( UGV )
{
LOBYTE(v2) = UGV;
}
else
{
a1->m_enteringTower = 1;
v72 = cocos2d::CCDelayTime::create(1.2);
v95.y = 0.0;
LODWORD(v95.x) = LevelAreaLayer::showDialog;
v73 = (cocos2d::CCSequence *)v72;
v74 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCCallFunc::create(a1, LevelAreaLayer::showDialog, 0);
v75 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v73, v74, 0);
cocos2d::CCNode::runAction(a1, v75);
}
}
return v2;
}