//
// GJBaseGameLayer::createMiddleground from 0x14020bae0 to 0x14020bc5b (379 bytes)
//
// 7 xrefs:
// > GameManager::finishedLoadingMGAsync @ 0x140182bba
// > GJBaseGameLayer::syncBGTextures @ 0x14023b02f
// > LevelEditorLayer::init @ 0x1402d2bb4
// > LevelSettingsLayer::selectArtClosed @ 0x140322160
// > PlayLayer::setupHasCompleted @ 0x1403a6a72
// > ArtTriggerGameObject::triggerObject @ 0x1404c24a3
// > ??> @ 0x1406ccd14
//
// 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 GJBaseGameLayer::createMiddleground(GJBaseGameLayer *a1, int a2)
{
GJMGLayer *m_middleground; // rcx
GJMGLayer *v5; // rbx
m_middleground = a1->m_middleground;
if ( m_middleground )
{
m_middleground->removeFromParent(m_middleground);
a1->m_middleground = nullptr;
}
if ( a2 > 0 )
{
if ( a2 > 3 )
a2 = 3;
v5 = (GJMGLayer *)operator new(0x1E8u);
cocos2d::CCLayer::CCLayer(v5);
v5->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable = (GJMGLayer_vtbl *)&GJMGLayer::`vftable';
v5->cocos2d::CCLayer::cocos2d::CCTouchDelegate::__vftable = (cocos2d::CCTouchDelegate_vtbl *)&GJMGLayer::`vftable';
v5->cocos2d::CCLayer::cocos2d::CCAccelerometerDelegate::__vftable = (cocos2d::CCAccelerometerDelegate_vtbl *)&GJMGLayer::`vftable';
v5->cocos2d::CCLayer::cocos2d::CCKeypadDelegate::__vftable = (cocos2d::CCKeypadDelegate_vtbl *)&GJMGLayer::`vftable';
v5->cocos2d::CCLayer::cocos2d::CCKeyboardDelegate::__vftable = (cocos2d::CCKeyboardDelegate_vtbl *)&GJMGLayer::`vftable';
v5->cocos2d::CCLayer::cocos2d::CCMouseDelegate::__vftable = (cocos2d::CCMouseDelegate_vtbl *)&GJMGLayer::`vftable';
v5->m_ground1Sprite = nullptr;
v5->m_ground2Sprite = nullptr;
v5->m_textureWidth = 0.0;
v5->m_unk1b0 = nullptr;
v5->m_showGround = 0;
v5->m_groundWidth = 0.0;
*(_WORD *)&v5->m_showGround1 = 257;
v5->m_unk1c4 = 0.0;
*(_WORD *)&v5->m_cameraRotated = 0;
v5->m_blendMG2 = 0;
v5->m_mg1BatchNode = nullptr;
v5->m_mg2BatchNode = nullptr;
*(_QWORD *)&v5->m_groundScale = 0;
if ( GJMGLayer::init(v5, a2) )
{
cocos2d::CCObject::autorelease(v5);
}
else
{
((void (__fastcall *)(GJMGLayer *, __int64))v5->~GJMGLayer)(v5, 1);
v5 = nullptr;
}
a1->m_middleground = v5;
v5->setTag(v5, a2);
a1->m_objectParent->addChild_0(a1->m_objectParent, a1->m_middleground, -39);
}
}