//
// GJGroundLayer::init from 0x1005eaa90 to 0x1005eaf6d (1245 bytes)
//
// 1 xrefs:
// > GJGroundLayer::create @ 0x1005eaa4b
//
// 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 __fastcall GJGroundLayer::init(GJGroundLayer *a1, int a2, int a3)
{
bool result; // al
GameManager *v5; // rax
const char *GTexture; // r14
cocos2d::CCSprite *v7; // r12
cocos2d::CCDirector *v8; // rax
float v9; // xmm0_4
cocos2d::CCSprite *v10; // r13
cocos2d::CCDirector *v11; // rax
float v12; // xmm0_4
cocos2d::CCSpriteBatchNode *v13; // r12
__int64 v14; // rax
float v15; // xmm0_4
__m128 v16; // xmm1
cocos2d::CCTexture2D *v17; // rax
cocos2d::CCSprite *v18; // r15
__int64 v19; // rax
__int64 v20; // r12
unsigned int v21; // r13d
__int64 v22; // rax
cocos2d::CCString *v23; // rax
const char *CString; // rax
cocos2d::CCSpriteBatchNode *v25; // r14
cocos2d::CCTexture2D *v26; // rax
cocos2d::CCSprite *v27; // r15
__int64 v28; // rax
__int64 v29; // rbx
unsigned int v30; // r14d
__int64 v31; // rax
char v32; // [rsp+0h] [rbp-50h]
float v33; // [rsp+4h] [rbp-4Ch] BYREF
int v34; // [rsp+Ch] [rbp-44h]
int v35; // [rsp+10h] [rbp-40h]
float v36[2]; // [rsp+14h] [rbp-3Ch] BYREF
float v37; // [rsp+1Ch] [rbp-34h] BYREF
__int16 v38; // [rsp+24h] [rbp-2Ch] BYREF
char v39; // [rsp+26h] [rbp-2Ah]
bool v40; // [rsp+27h] [rbp-29h]
result = cocos2d::CCLayer::init(a1);
if ( result )
{
v40 = result;
((void (__fastcall *)(GJGroundLayer *, void *))a1->setContentSize)(a1, &unk_1009A2FC0);
cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v33);
v5 = GameManager::sharedState();
v34 = a2;
GTexture = GameManager::getGTexture(v5, a2);
a1->m_blendLine = 1;
GJGroundLayer::createLine(a1, a3);
v7 = cocos2d::CCSprite::createWithSpriteFrameName("groundSquareShadow_001.png");
sub_10028CBE0(v36, 0.0, 1.0);
((void (__fastcall *)(cocos2d::CCSprite *, float *))v7->setAnchorPoint)(v7, v36);
v8 = cocos2d::CCDirector::sharedDirector();
v9 = sub_100484D90((__int64)v8);
sub_10028CBE0(v36, v9 + -1.0, 0.0);
((void (__fastcall *)(cocos2d::CCSprite *, float *))v7->setPosition)(v7, v36);
((void (__fastcall *)(GJGroundLayer *, cocos2d::CCSprite *, __int64))a1->addChild_0)(a1, v7, 6);
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))v7->setTag)(v7, 0);
v10 = cocos2d::CCSprite::createWithSpriteFrameName("groundSquareShadow_001.png");
sub_10028CBE0(v36, 1.0, 1.0);
((void (__fastcall *)(cocos2d::CCSprite *, float *))v10->setAnchorPoint)(v10, v36);
v11 = cocos2d::CCDirector::sharedDirector();
v12 = sub_100484DA0((__int64)v11);
sub_10028CBE0(v36, v12 + 1.0, 0.0);
((void (__fastcall *)(cocos2d::CCSprite *, float *))v10->setPosition)(v10, v36);
((void (__fastcall *)(GJGroundLayer *, cocos2d::CCSprite *, __int64))a1->addChild_0)(a1, v10, 6);
cocos2d::CCSprite::setFlipX(v10, 1);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v10->setTag)(v10, 1);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v7->setOpacity)(v7, 100);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v10->setOpacity)(v10, 100);
((void (__fastcall *)(cocos2d::CCSprite *, float))v7->setScaleX)(v7, 0.69999999);
((void (__fastcall *)(cocos2d::CCSprite *, float))v10->setScaleX)(v10, 0.69999999);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v7->setBlendFunc)(v7, 0x30300000306LL);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v10->setBlendFunc)(v10, 0x30300000306LL);
a1->m_showGround = 0;
v39 = -1;
v38 = 26112;
v13 = cocos2d::CCSpriteBatchNode::create(GTexture, 0x1Du);
((void (__fastcall *)(GJGroundLayer *, cocos2d::CCSpriteBatchNode *, __int64))a1->addChild_0)(a1, v13, 2);
v14 = ((__int64 (__fastcall *)(cocos2d::CCSpriteBatchNode *))v13->getTexture)(v13);
(*(void (__fastcall **)(float *, __int64))(*(_QWORD *)v14 + 144LL))(v36, v14);
v15 = v36[0];
a1->m_textureWidth = v36[0];
v16 = (__m128)LODWORD(v33);
v16.f32[0] = v33 / v15;
a1->m_ground1Offset = 128.0 - v36[1];
v17 = (cocos2d::CCTexture2D *)((__int64 (__fastcall *)(cocos2d::CCSpriteBatchNode *))v13->getTexture)(v13);
v18 = cocos2d::CCSprite::createWithTexture(v17, &stru_1009A2FC8);
a1->m_ground1Sprite = v18;
v18->m_bDontDraw = 1;
sub_10028CBE0(&v37, 0.0, 0.0);
((void (__fastcall *)(cocos2d::CCSprite *, float *))v18->setPosition)(v18, &v37);
((void (__fastcall *)(cocos2d::CCSprite *, __int16 *))a1->m_ground1Sprite->setColor)(a1->m_ground1Sprite, &v38);
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *, cocos2d::CCSprite *))v13->addChild)(v13, a1->m_ground1Sprite);
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *, __int64))v13->setBlendFunc)(v13, 1);
v35 = (int)(float)(_mm_round_ss((__m128)0LL, v16, 10).f32[0] + 1.0);
GJGroundLayer::loadGroundSprites(a1, v35, 1);
BYTE2(v37) = v39;
LOWORD(v37) = v38;
v19 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_ground1Sprite->getChildren)(a1->m_ground1Sprite);
if ( v19 )
{
v20 = v19;
if ( (unsigned int)sub_100720070(v19) )
{
v21 = 0;
do
{
v22 = sub_1007200C0(v20, v21);
(*(void (__fastcall **)(__int64, float *))(*(_QWORD *)v22 + 944LL))(v22, &v37);
++v21;
}
while ( v21 < (unsigned int)sub_100720070(v20) );
}
}
result = v40;
if ( v34 >= 8 )
{
v23 = (cocos2d::CCString *)sub_1007AB580("groundSquare_%02d_2_001.png", v32);
CString = cocos2d::CCString::getCString(v23);
v25 = cocos2d::CCSpriteBatchNode::create(CString, 0x1Du);
((void (__fastcall *)(GJGroundLayer *, cocos2d::CCSpriteBatchNode *, __int64))a1->addChild_0)(a1, v25, 3);
v26 = (cocos2d::CCTexture2D *)((__int64 (__fastcall *)(cocos2d::CCSpriteBatchNode *))v25->getTexture)(v25);
v27 = cocos2d::CCSprite::createWithTexture(v26, &stru_1009A2FC8);
a1->m_ground2Sprite = v27;
v27->m_bDontDraw = 1;
sub_10028CBE0(&v37, 0.0, 0.0);
((void (__fastcall *)(cocos2d::CCSprite *, float *))v27->setPosition)(v27, &v37);
((void (__fastcall *)(cocos2d::CCSprite *, __int16 *))a1->m_ground2Sprite->setColor)(a1->m_ground2Sprite, &v38);
((void (__fastcall *)(cocos2d::CCSpriteBatchNode *, cocos2d::CCSprite *))v25->addChild)(v25, a1->m_ground2Sprite);
GJGroundLayer::loadGroundSprites(a1, v35, 0);
BYTE2(v37) = v39;
LOWORD(v37) = v38;
v28 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_ground1Sprite->getChildren)(a1->m_ground1Sprite);
if ( v28 )
{
v29 = v28;
if ( (unsigned int)sub_100720070(v28) )
{
v30 = 0;
do
{
v31 = sub_1007200C0(v29, v30);
(*(void (__fastcall **)(__int64, float *))(*(_QWORD *)v31 + 944LL))(v31, &v37);
++v30;
}
while ( v30 < (unsigned int)sub_100720070(v29) );
}
}
return v40;
}
}
return result;
}