//
// GJBaseGameLayer::triggerGradientCommand from 0x59b438 to 0x59b63c (516 bytes)
//
// 4 xrefs:
// > PlayLayer::loadFromCheckpoint @ 0x411ab4
// > LevelEditorLayer::activateTriggerEffect @ 0x467ca2
// > EffectGameObject::triggerObject @ 0x4f4bbe
// > GJBaseGameLayer::controlGradientTrigger @ 0x59b674
//
// 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:12 +0000
//
int __fastcall GJBaseGameLayer::triggerGradientCommand(GJBaseGameLayer *this, GradientTriggerObject *a2)
{
int result; // r0
int v5; // r7
cocos2d::CCDictionary *v6; // r0
int *v7; // r4
char v8; // r7
int v9; // r3
int v10; // r3
int v11; // r7
int v12; // r0
int v13; // r5
int v14; // r3
int ObjectZOrder; // r0
int v16; // r7
unsigned int v17; // r2
int v18; // r0
int v19; // [sp+0h] [bp-8h]
if ( *((_BYTE *)a2 + 1678) )
return GJBaseGameLayer::resetGradientLayers((int)this);
v5 = *((_DWORD *)a2 + 414);
v6 = *((cocos2d::CCDictionary **)this + 2676);
if ( v5 >= 999 )
v5 = 999;
v7 = (int *)cocos2d::CCDictionary::objectForKey(v6, v5);
if ( !v7 )
{
v7 = GJGradientLayer::create(nullptr);
v7[123] = v5;
cocos2d::CCDictionary::setObject(*((cocos2d::CCDictionary **)this + 2676), (cocos2d::CCObject *)v7, v5);
}
v8 = *((_BYTE *)a2 + 1677);
if ( v8 )
{
result = (*(int (__fastcall **)(int *, _DWORD))(*v7 + 264))(v7, 0);
v7[119] = 0;
return result;
}
v7[119] = (int)a2;
v7[115] = (int)GameObject::getMainColorMode(a2);
v7[116] = (int)GameObject::getSecondaryColorMode(a2);
v9 = *((_DWORD *)a2 + 413);
v7[121] = v9;
if ( v9 == 2 )
{
v19 = 774;
v10 = 771;
}
else
{
if ( v9 != 3 )
{
if ( v9 != 1 )
v9 = 771;
(*(void (__fastcall **)(int *, int, int))(*v7 + 644))(v7, 770, v9);
goto LABEL_17;
}
v19 = 775;
v10 = 769;
}
v8 = 1;
(*(void (__fastcall **)(int *, int, int))(*v7 + 644))(v7, v19, v10);
LABEL_17:
*((_BYTE *)v7 + 457) = v8;
v7[122] = *((_DWORD *)a2 + 412);
v11 = GJBaseGameLayer::maxZOrderForShaderZ(this, *((_DWORD *)a2 + 412));
switch ( *((_DWORD *)a2 + 412) )
{
case 2:
v12 = *((_DWORD *)this + 616);
if ( v12 )
goto LABEL_34;
goto LABEL_33;
case 3:
v12 = *((_DWORD *)this + 508);
goto LABEL_34;
case 4:
v12 = *((_DWORD *)this + 494);
goto LABEL_34;
case 5:
v12 = *((_DWORD *)this + 480);
goto LABEL_34;
case 6:
v12 = *((_DWORD *)this + 466);
goto LABEL_34;
case 7:
v12 = *((_DWORD *)this + 452);
goto LABEL_34;
case 8:
v12 = *((_DWORD *)this + 519);
goto LABEL_34;
case 9:
v12 = *((_DWORD *)this + 432);
goto LABEL_34;
case 0xA:
v12 = *((_DWORD *)this + 418);
goto LABEL_34;
case 0xB:
v12 = *((_DWORD *)this + 404);
goto LABEL_34;
case 0xC:
v12 = *((_DWORD *)this + 390);
goto LABEL_34;
case 0xD:
v12 = *((_DWORD *)this + 614);
goto LABEL_34;
case 0xE:
v12 = *((_DWORD *)this + 2813);
goto LABEL_34;
case 0xF:
v13 = *((_DWORD *)this + 608);
goto LABEL_35;
default:
LABEL_33:
v12 = *((_DWORD *)this + 612);
LABEL_34:
v13 = (*(int (__fastcall **)(int))(*(_DWORD *)v12 + 256))(v12);
LABEL_35:
v14 = *((_DWORD *)a2 + 412);
if ( v14 == 2 )
{
v11 = -14;
}
else if ( v14 > 2 )
{
if ( v14 == 13 )
{
v11 = 46;
}
else if ( v14 == 14 )
{
v11 = 56;
}
}
else if ( v14 == 1 )
{
v11 = -54;
}
ObjectZOrder = GameObject::getObjectZOrder(a2);
if ( ObjectZOrder < -5 )
ObjectZOrder = -5;
*((_BYTE *)v7 + 480) = 1;
if ( ObjectZOrder > 5 )
v16 = v11 + 5;
else
v16 = v11 + ObjectZOrder;
v17 = *((_DWORD *)a2 + 412) - 1;
if ( v17 <= 0xE && ((1 << v17) & 0x7003) != 0 )
*((_BYTE *)v7 + 480) = 0;
v18 = (*(int (__fastcall **)(int *))(*v7 + 256))(v7);
if ( v13 == v18 )
{
result = (*(int (__fastcall **)(int, int *, int))(*(_DWORD *)v13 + 296))(v18, v7, v16);
}
else
{
(*(void (__fastcall **)(int *, _DWORD))(*v7 + 264))(v7, 0);
result = (*(int (__fastcall **)(int, int *, int))(*(_DWORD *)v13 + 232))(v13, v7, v16);
}
break;
}
return result;
}