//
// GJBaseGameLayer::swapMiddleground from 0x58c7f4 to 0x58c852 (94 bytes)
//
// 1 xrefs:
// > ArtTriggerGameObject::triggerObject @ 0x4e6914
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:53:03 +0000
//
GJBaseGameLayer *__fastcall GJBaseGameLayer::swapMiddleground(GJBaseGameLayer *this, GJMGLayer *a2)
{
GJBaseGameLayer *v2; // r5
GameManager *v4; // r0
int v5; // r0
v2 = this;
*((_DWORD *)this + 346) = a2;
if ( !*((_BYTE *)this + 10829) )
{
this = (GJBaseGameLayer *)GameManager::sharedState(this);
if ( *((GJMGLayer **)this + 194) != a2 || (int)a2 > 0 && !*((_DWORD *)v2 + 616) )
{
if ( a2 )
{
v4 = (GameManager *)GameManager::sharedState(this);
if ( *((GJMGLayer **)v4 + 194) == a2 )
{
return (GJBaseGameLayer *)GJBaseGameLayer::asyncMGLoaded(v2, a2);
}
else
{
v5 = GameManager::sharedState(v4);
return (GJBaseGameLayer *)GameManager::loadMiddlegroundAsync(v5, (const char *)a2);
}
}
else
{
return GJBaseGameLayer::createMiddleground(v2, nullptr);
}
}
}
return this;
}