//
// GJBaseGameLayer::syncBGTextures from 0x100158f50 to 0x10015905b (267 bytes)
//
// 3 xrefs:
// > PlayLayer::resetLevel @ 0x1000beddd
// > LevelEditorLayer::onPlaytest @ 0x1000f2831
// > LevelEditorLayer::onStopPlaytest @ 0x1000f2e96
//
// 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
//
void __fastcall GJBaseGameLayer::syncBGTextures(GJBaseGameLayer *a1)
{
int v2; // eax
int m_background; // esi
int v4; // eax
int m_ground; // esi
GJMGLayer *m_middleground; // rdi
int v7; // eax
int v8; // r15d
GJMGLayer *v9; // rdi
unsigned int v10; // r14d
GJMGLayer *v11; // rax
v2 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_background->getTag)(a1->m_background);
m_background = a1->m_gameState.m_background;
if ( v2 != m_background )
GJBaseGameLayer::createBackground(a1, m_background);
v4 = ((__int64 (__fastcall *)(GJGroundLayer *))a1->m_groundLayer->getTag)(a1->m_groundLayer);
m_ground = a1->m_gameState.m_ground;
if ( v4 != m_ground )
GJBaseGameLayer::createGroundLayer(a1, m_ground, a1->m_levelSettings->m_groundLineIndex);
m_middleground = a1->m_middleground;
if ( m_middleground )
{
v7 = ((__int64 (__fastcall *)(GJMGLayer *))m_middleground->getTag)(m_middleground);
v8 = a1->m_gameState.m_middleground;
v9 = a1->m_middleground;
if ( v7 == v8 )
{
if ( v9 )
return;
v8 = v7;
}
else if ( v9 )
{
((void (__fastcall *)(GJMGLayer *))v9->removeFromParent)(v9);
a1->m_middleground = nullptr;
}
}
else
{
v8 = a1->m_gameState.m_middleground;
}
if ( v8 > 0 )
{
v10 = 3;
if ( (unsigned int)v8 < 3 )
v10 = v8;
v11 = GJMGLayer::create(v10);
a1->m_middleground = v11;
((void (__fastcall *)(GJMGLayer *, _QWORD))v11->setTag)(v11, v10);
((void (__fastcall *)(cocos2d::CCNode *, GJMGLayer *, __int64))a1->m_objectParent->addChild_0)(
a1->m_objectParent,
a1->m_middleground,
4294967257LL);
}
}