//
// EndPortalObject::init from 0x140137d50 to 0x14013819d (1101 bytes)
//
// 5 xrefs:
// > PlayLayer::createObjectsFromSetupFinished @ 0x1403ada2b
// > PlayLayer::createObjectsFromSetupFinished @ 0x1403ada32
// > PlayLayer::createObjectsFromSetupFinished @ 0x1403ada1c
// > ??> @ 0x140556b68
// > ??> @ 0x1406ca08c
//
// 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=3
bool EndPortalObject::init(EndPortalObject *a1)
{
__int64 v2; // rcx
cocos2d::CCDirector *v3; // rax
cocos2d::CCParticleSystemQuad *v4; // rax
cocos2d::CCParticleSystemQuad *v5; // rbx
__int64 v6; // rax
__int64 v7; // rax
float v8; // xmm0_4
__int64 v9; // rax
float v10; // xmm0_4
__int64 v11; // rax
float v12; // xmm0_4
float v13; // xmm0_4
int v14; // r14d
int i; // ebp
struct cocos2d::CCSprite *v16; // rdi
cocos2d::CCSprite_vtbl *v17; // rbx
const cocos2d::CCPoint *v18; // rax
__int16 v20; // [rsp+30h] [rbp-A8h]
__int16 v21; // [rsp+30h] [rbp-A8h]
float v22; // [rsp+44h] [rbp-94h]
cocos2d::CCPoint v23; // [rsp+48h] [rbp-90h] BYREF
__int64 v24; // [rsp+50h] [rbp-88h] BYREF
float v25; // [rsp+58h] [rbp-80h]
int v26; // [rsp+5Ch] [rbp-7Ch]
float v27[4]; // [rsp+60h] [rbp-78h] BYREF
a1->m_eObjType = GameObjectObjectType;
if ( !cocos2d::CCSprite::initWithSpriteFrameName(a1, "block001_01_001.png") )
return 0;
GameObject::commonSetup(a1);
a1->m_bUnkBool2 = 1;
a1->setTextureRect_0(a1, &stru_1406C1B10);
v3 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v2);
cocos2d::CCDirector::getWinSize(v3);
a1->m_isInvisible = 0;
a1->m_unk3F8 = 1;
a1->m_objectType = Decoration;
v4 = GameObject::createAndAddParticle(a1, 7, "endEffectPortal.plist", 4, kCCPositionTypeGrouped);
v5 = v4;
if ( v4 )
{
((void (__fastcall *)(cocos2d::CCParticleSystemQuad *))v4->setStartRadius)(v4);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v24, -15.0, 0.0);
cocos2d::CCPoint::operator=(&a1->m_particleOffset, v6);
v7 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v23 = (cocos2d::CCPoint)operator new(0x668u);
qword_1406C2ED8 = ((__int64 (__fastcall *)(_QWORD))sub_14017AB00)(v23);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v7 = qword_1406C2ED8;
}
v20 = *(_WORD *)(*(_QWORD *)(*(_QWORD *)(v7 + 520) + 3488LL) + 2698LL);
v8 = (float)*(unsigned __int8 *)(*(_QWORD *)(*(_QWORD *)(v7 + 520) + 3488LL) + 2700LL) / 255.0;
v27[0] = (float)(unsigned __int8)v20 / 255.0;
v27[1] = (float)HIBYTE(v20) / 255.0;
v27[2] = v8;
v27[3] = 1.0;
v5->setStartColor(v5, (const cocos2d::ccColor4F *)v27);
v9 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v23 = (cocos2d::CCPoint)operator new(0x668u);
qword_1406C2ED8 = ((__int64 (__fastcall *)(_QWORD))sub_14017AB00)(v23);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v9 = qword_1406C2ED8;
}
v21 = *(_WORD *)(*(_QWORD *)(*(_QWORD *)(v9 + 520) + 3488LL) + 2698LL);
v10 = (float)*(unsigned __int8 *)(*(_QWORD *)(*(_QWORD *)(v9 + 520) + 3488LL) + 2700LL) / 255.0;
*(float *)&v24 = (float)(unsigned __int8)v21 / 255.0;
*((float *)&v24 + 1) = (float)HIBYTE(v21) / 255.0;
v25 = v10;
v26 = 1065353216;
v5->setEndColor(v5, (const cocos2d::ccColor4F *)&v24);
}
a1->m_gradientBar = cocos2d::CCSprite::createWithSpriteFrameName("gradientBar.png");
v11 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v23 = (cocos2d::CCPoint)operator new(0x668u);
qword_1406C2ED8 = ((__int64 (__fastcall *)(_QWORD))sub_14017AB00)(v23);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v11 = qword_1406C2ED8;
}
(*(void (__fastcall **)(_QWORD, cocos2d::CCSprite *))(**(_QWORD **)(*(_QWORD *)(v11 + 520) + 2776LL) + 448LL))(
*(_QWORD *)(*(_QWORD *)(v11 + 520) + 2776LL),
a1->m_gradientBar);
v24 = 0x100000302LL;
((void (__fastcall *)(cocos2d::CCTextureProtocol *, __int64))a1->m_gradientBar->setBlendFunc)(
&a1->m_gradientBar->cocos2d::CCTextureProtocol,
0x100000302LL);
((void (*)(void))a1->m_gradientBar->setScaleY)();
v12 = (float)(v22 * 1.5) / 30.0;
if ( v12 < 0.0 )
v13 = ceilf(v12 - 0.5);
else
v13 = floorf(v12 + 0.5);
v14 = (int)v13;
for ( i = 0; i < v14; ++i )
{
v16 = cocos2d::CCSprite::createWithSpriteFrameName("square_02_001.png");
a1->addChild_1(a1, v16);
((void (__fastcall *)(struct cocos2d::CCSprite *))v16->setRotation)(v16);
v17 = v16->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(&v23, 0.0, (float)((float)(v14 / 2) * 30.0) - (float)((float)i * 30.0));
v17->setPosition_0(v16, v18);
}
a1->m_unk370 = 1;
return 1;
}