//
// LevelAreaLayer::addTorch from 0x1402c5890 to 0x1402c5f13 (1667 bytes)
//
// 5 xrefs:
// > LevelAreaLayer::init @ 0x1402c518f
// > LevelAreaInnerLayer::init @ 0x1402c6f85
// > SecretLayer5::init @ 0x1403f5041
// > ??> @ 0x1406d2b28
// > ??> @ 0x1406d2b34
//
// 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=1
void LevelAreaLayer::addTorch(
cocos2d::CCNode *a1,
cocos2d::CCPoint a2,
int a3,
float a4,
int a5,
bool a6,
int a7,
cocos2d::CCArray *a8)
{
const char *v11; // rdx
size_t v12; // r8
const char *v13; // rcx
struct cocos2d::CCSprite *v14; // r14
const char *v15; // rcx
struct cocos2d::CCSprite *v16; // r13
cocos2d::CCSprite_vtbl *v17; // rbx
double v18; // xmm0_8
float v19; // xmm0_4
cocos2d::CCSprite_vtbl *v20; // rbx
__int64 v21; // rax
BOOL v22; // esi
__int64 v23; // rcx
__int64 v24; // rcx
__int64 v25; // rax
int v26; // edi
cocos2d::CCArray *v27; // r12
cocos2d::CCArray *v28; // r15
cocos2d::CCString *v29; // rax
const char *CString; // rbx
__int64 v31; // rcx
cocos2d::CCSpriteFrameCache *v32; // rax
struct cocos2d::CCSpriteFrame *v33; // rax
cocos2d::CCString *v34; // rax
const char *v35; // rbx
__int64 v36; // rcx
cocos2d::CCSpriteFrameCache *v37; // rax
struct cocos2d::CCSpriteFrame *v38; // rax
struct cocos2d::CCAnimation *v39; // rax
struct cocos2d::CCAnimate *v40; // rax
struct cocos2d::CCRepeatForever *v41; // rax
cocos2d::ccColor3B *v42; // r8
struct cocos2d::CCAnimation *v43; // rax
struct cocos2d::CCAnimate *v44; // rax
struct cocos2d::CCRepeatForever *v45; // rax
cocos2d::ccColor3B *v46; // r8
CCLightFlash *v47; // rsi
__int64 v48; // rax
cocos2d::CCNode *v49; // r15
__int64 v50; // rdx
struct cocos2d::CCFadeTo *v51; // rax
struct cocos2d::CCEaseInOut *v52; // rdi
struct cocos2d::CCFadeTo *v53; // rax
struct cocos2d::CCEaseInOut *v54; // rax
struct cocos2d::CCSequence *v55; // rax
struct cocos2d::CCRepeatForever *v56; // rax
cocos2d::ccColor3B *v57; // r8
struct cocos2d::CCScaleTo *v58; // rax
struct cocos2d::CCEaseInOut *v59; // rdi
double v60; // xmm0_8
struct cocos2d::CCScaleTo *v61; // rax
struct cocos2d::CCEaseInOut *v62; // rax
struct cocos2d::CCSequence *v63; // rax
struct cocos2d::CCRepeatForever *v64; // rax
cocos2d::ccColor3B *v65; // r8
cocos2d::CCArray *v66; // r12
struct cocos2d::CCSprite *v67; // rsi
float v68; // xmm0_4
__int64 v69; // rax
struct cocos2d::CCSprite *v70; // rsi
__int64 v71; // rax
__int64 v72; // rdx
struct cocos2d::CCObject *v73; // rdi
__int64 v74; // [rsp+28h] [rbp-A1h] BYREF
__int64 v75; // [rsp+30h] [rbp-99h] BYREF
cocos2d::CCArray *v76; // [rsp+38h] [rbp-91h] BYREF
CCLightFlash *v77; // [rsp+40h] [rbp-89h]
cocos2d::CCNode *v78; // [rsp+50h] [rbp-79h]
__int128 v79; // [rsp+58h] [rbp-71h] BYREF
__int128 v80; // [rsp+68h] [rbp-61h]
v78 = a1;
v76 = a8;
v11 = "Fire_01_looped_001.png";
if ( a3 == 2 )
v11 = "Fire_02_looped_001.png";
v79 = 0;
v80 = 0;
v12 = -1;
do
++v12;
while ( v11[v12] );
sub_14003A930(&v79, v11, v12);
v13 = (const char *)&v79;
if ( *((_QWORD *)&v80 + 1) > 0xFu )
v13 = (const char *)v79;
v14 = cocos2d::CCSprite::createWithSpriteFrameName(v13);
a1->addChild_0(a1, v14, a5 - 2);
((void (__fastcall *)(struct cocos2d::CCSprite *, cocos2d::CCPoint))v14->setPosition_0)(v14, a2);
((void (__fastcall *)(struct cocos2d::CCSprite *))v14->setScale_0)(v14);
v15 = (const char *)&v79;
if ( *((_QWORD *)&v80 + 1) > 0xFu )
v15 = (const char *)v79;
v16 = cocos2d::CCSprite::createWithSpriteFrameName(v15);
a1->addChild_0(a1, v16, a5 - 3);
v17 = v16->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v18 = ((double (__fastcall *)(struct cocos2d::CCSprite *))v14->getScale)(v14);
v19 = *(float *)&v18 + *(float *)&v18;
((void (__fastcall *)(struct cocos2d::CCSprite *))v17->setScale_0)(v16);
v20 = v16->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v21 = (__int64)v14->getPosition_0(v14);
v20->setPosition_0(v16, (const cocos2d::CCPoint *)v21);
LOWORD(v74) = 13055;
BYTE2(v74) = 0;
v14->setColor(&v14->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v74);
LOWORD(v74) = -1;
BYTE2(v74) = 0;
v16->setColor(&v16->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v74);
v22 = a3 == 2;
v75 = cocos2d::CCArray::create(v23);
v25 = cocos2d::CCArray::create(v24);
v26 = 1;
v27 = (cocos2d::CCArray *)v75;
v28 = (cocos2d::CCArray *)v25;
do
{
v29 = cocos2d::CCString::createWithFormat("Fire_0%i_looped_%03i.png", v22 + 1, v26);
CString = cocos2d::CCString::getCString(v29);
v32 = (cocos2d::CCSpriteFrameCache *)cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache(v31);
v33 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v32, CString);
cocos2d::CCArray::addObject(v27, v33);
v34 = cocos2d::CCString::createWithFormat("Fire_0%i_2_looped_%03i.png", v22 + 1, v26);
v35 = cocos2d::CCString::getCString(v34);
v37 = (cocos2d::CCSpriteFrameCache *)cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache(v36);
v38 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v37, v35);
cocos2d::CCArray::addObject(v28, v38);
++v26;
}
while ( v26 <= 9 );
v39 = cocos2d::CCAnimation::createWithSpriteFrames(v27, 0.079999998);
v40 = cocos2d::CCAnimate::create(v39);
v41 = cocos2d::CCRepeatForever::create(v40);
cocos2d::CCNode::runAction((CCLightFlash *)v14, (cocos2d::CCPoint)v41, v42, a4, *(float *)&v74);
v43 = cocos2d::CCAnimation::createWithSpriteFrames(v28, 0.079999998);
v44 = cocos2d::CCAnimate::create(v43);
v45 = cocos2d::CCRepeatForever::create(v44);
cocos2d::CCNode::runAction((CCLightFlash *)v16, (cocos2d::CCPoint)v45, v46, a4, *(float *)&v74);
v47 = (CCLightFlash *)cocos2d::CCSprite::createWithSpriteFrameName("towerShine.png");
v77 = v47;
cocos2d::CCPoint::CCPoint(v19, 0.0);
v48 = (__int64)v14->getPosition_0(v14);
cocos2d::CCPoint::operator+(v48, &v75);
v47->setPosition_0(v47, (const cocos2d::CCPoint *)&v75);
v49 = v78;
v78->addChild_0(v78, v47, a5 - 1);
((void (__fastcall *)(CCLightFlash *))v47->setScale_0)(v47);
v75 = 0x100000302LL;
((void (__fastcall *)(cocos2d::CCNode **, __int64))v47->m_mainLayer->__vftable)(&v47->m_mainLayer, 0x100000302LL);
LOBYTE(v50) = -116;
(*(void (__fastcall **)(cocos2d::CCArray **, __int64))&v47->m_lightStripArray->m_unknown2)(
&v47->m_lightStripArray,
v50);
LOWORD(v74) = -14081;
BYTE2(v74) = 0;
((void (__fastcall *)(cocos2d::CCArray **, __int64 *))v47->m_lightStripArray->__vftable)(
&v47->m_lightStripArray,
&v74);
v51 = cocos2d::CCFadeTo::create(1.6, 0x70u);
v52 = cocos2d::CCEaseInOut::create(v51, 1.3);
v53 = cocos2d::CCFadeTo::create(1.6, 0x9Du);
v54 = cocos2d::CCEaseInOut::create(v53, 1.3);
v55 = cocos2d::CCSequence::create(v52, v54, 0);
v56 = cocos2d::CCRepeatForever::create(v55);
cocos2d::CCNode::runAction(v47, (cocos2d::CCPoint)v56, v57, a4, *(float *)&v74);
v58 = cocos2d::CCScaleTo::create(1.0, a4 + a4);
v59 = cocos2d::CCEaseInOut::create(v58, 1.5);
LODWORD(v60) = 1065353216;
v61 = cocos2d::CCScaleTo::create(1.0, (float)(a4 + a4) * 1.2);
v62 = cocos2d::CCEaseInOut::create(v61, 1.5);
v63 = cocos2d::CCSequence::create(v59, v62, 0);
v64 = cocos2d::CCRepeatForever::create(v63);
cocos2d::CCNode::runAction(v47, (cocos2d::CCPoint)v64, v65, a4, *(float *)&v74);
v66 = v76;
if ( !a6 )
{
v67 = cocos2d::CCSprite::createWithSpriteFrameName("towerTorch_001.png");
v68 = ((float (__fastcall *)(cocos2d::CCNode *, struct cocos2d::CCSprite *, _QWORD))v49->addChild_0)(
v49,
v67,
(unsigned int)a5);
cocos2d::CCPoint::CCPoint(v68, 0.5);
v69 = (__int64)v14->getPosition_0(v14);
v60 = cocos2d::CCPoint::operator+(v69, &v76);
v67->setPosition_0(v67, (const cocos2d::CCPoint *)&v76);
}
v70 = cocos2d::CCSprite::createWithSpriteFrameName("towerShine.png");
cocos2d::CCPoint::CCPoint(*(float *)&v60, 0.0);
v71 = (__int64)v14->getPosition_0(v14);
cocos2d::CCPoint::operator+(v71, &v76);
v70->setPosition_0(v70, (const cocos2d::CCPoint *)&v76);
v49->addChild_0(v49, v70, a5 + 1);
((void (__fastcall *)(struct cocos2d::CCSprite *))v70->setScale_0)(v70);
((void (__fastcall *)(cocos2d::CCTextureProtocol *, __int64))v70->setBlendFunc)(
&v70->cocos2d::CCTextureProtocol,
0x100000302LL);
LOBYTE(v72) = 122;
v70->setOpacity(&v70->cocos2d::CCRGBAProtocol, v72);
LOWORD(v74) = -26881;
BYTE2(v74) = 0;
v70->setColor(&v70->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v74);
if ( a7 == 1 )
{
LOWORD(v74) = 50;
BYTE2(v74) = 127;
v14->setColor(&v14->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v74);
LOWORD(v74) = 10837;
BYTE2(v74) = -40;
v16->setColor(&v16->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v74);
LOWORD(v74) = 12950;
BYTE2(v74) = -1;
v73 = v77;
((void (__fastcall *)(cocos2d::CCArray **, __int64 *))v77->m_lightStripArray->__vftable)(
&v77->m_lightStripArray,
&v74);
LOWORD(v74) = 130;
BYTE2(v74) = -1;
v70->setColor(&v70->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v74);
}
else
{
v73 = v77;
}
if ( v66 )
{
cocos2d::CCArray::addObject(v66, v14);
cocos2d::CCArray::addObject(v66, v16);
cocos2d::CCArray::addObject(v66, v73);
cocos2d::CCArray::addObject(v66, v70);
}
sub_14003A830((__int64)&v79);
}