//
// GJBaseGameLayer::triggerGradientCommand from 0x86c1c4 to 0x86c508 (836 bytes)
//
// 5 xrefs:
// > PlayLayer::loadFromCheckpoint @ 0x5e4d40
// > LevelEditorLayer::activateTriggerEffect @ 0x66d5bc
// > EffectGameObject::triggerObject @ 0x76fd20
// > GJBaseGameLayer::controlGradientTrigger @ 0x86c568
// > ??> @ 0x2b170
//
// 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 GJBaseGameLayer::triggerGradientCommand(GJBaseGameLayer *a1, GradientTriggerObject *a2)
{
int m_gradientID; // w1
cocos2d::CCDictionary *m_gradientLayers; // x0
int v6; // w20
GJGradientLayer *v7; // x21
int m_blendingMode; // w0
char v9; // w20
__int64 v10; // x1
int v11; // w20
void *m_specialLayerB5; // x1
cocos2d::CCNode *m_aboveShaderParent; // x22
int ObjectZOrder; // w0
int v15; // w1
int v16; // w19
GJMGLayer *m_middleground; // x0
cocos2d::CCDictionary *v18; // x0
if ( a2->m_disableAll )
{
GJBaseGameLayer::resetGradientLayers(a1);
}
else
{
m_gradientID = a2->m_gradientID;
m_gradientLayers = a1->m_gradientLayers;
if ( m_gradientID > 999 )
v6 = 999;
else
v6 = m_gradientID;
v7 = (GJGradientLayer *)cocos2d::CCDictionary::objectForKey(m_gradientLayers, v6);
if ( !v7 )
{
v7 = GJGradientLayer::create();
v18 = a1->m_gradientLayers;
v7->m_gradientID = v6;
cocos2d::CCDictionary::setObject(v18, v7, v6);
}
if ( a2->m_disable )
{
v7->removeFromParentAndCleanup(v7, 0);
v7->m_triggerObject = nullptr;
}
else
{
v7->m_triggerObject = a2;
v7->m_baseColor = GameObject::getMainColorMode(a2);
v7->m_detailColor = GameObject::getSecondaryColorMode(a2);
m_blendingMode = a2->m_blendingMode;
v7->m_blendingMode = m_blendingMode;
if ( m_blendingMode == 2 )
{
v9 = 1;
v10 = 0x30300000306LL;
}
else if ( m_blendingMode == 3 )
{
v9 = 1;
v10 = 0x30100000307LL;
}
else
{
v9 = 0;
if ( m_blendingMode == 1 )
v10 = 0x100000302LL;
else
v10 = 0x30300000302LL;
}
((void (__fastcall *)(GJGradientLayer *, __int64))v7->setBlendFunc)(v7, v10);
v7->m_blendingLayer = a2->m_blendingLayer;
v7->m_bShouldPremultiply = v9;
v11 = GJBaseGameLayer::maxZOrderForShaderZ(a1, a2->m_blendingLayer);
switch ( a2->m_blendingLayer )
{
case 2:
m_middleground = a1->m_middleground;
if ( !m_middleground )
goto LABEL_14;
m_aboveShaderParent = m_middleground->getParent(m_middleground);
goto LABEL_16;
case 3:
m_specialLayerB5 = a1->m_specialLayerB5;
goto LABEL_15;
case 4:
m_specialLayerB5 = a1->m_specialLayerB4;
goto LABEL_15;
case 5:
m_specialLayerB5 = a1->m_specialLayerB3;
goto LABEL_15;
case 6:
m_specialLayerB5 = a1->m_specialLayerB2;
goto LABEL_15;
case 7:
m_specialLayerB5 = a1->m_specialLayerB1;
goto LABEL_15;
case 8:
m_specialLayerB5 = a1->m_player1;
goto LABEL_15;
case 9:
m_specialLayerB5 = a1->m_specialLayerT1;
goto LABEL_15;
case 0xA:
m_specialLayerB5 = a1->m_specialLayerT2;
goto LABEL_15;
case 0xB:
m_specialLayerB5 = a1->m_specialLayerT3;
goto LABEL_15;
case 0xC:
m_specialLayerB5 = a1->m_specialLayerT4;
goto LABEL_15;
case 0xD:
m_specialLayerB5 = a1->m_groundLayer;
goto LABEL_15;
case 0xE:
m_specialLayerB5 = a1->m_uiTriggerUI;
goto LABEL_15;
case 0xF:
m_aboveShaderParent = a1->m_aboveShaderParent;
goto LABEL_23;
default:
LABEL_14:
m_specialLayerB5 = a1->m_background;
LABEL_15:
m_aboveShaderParent = (cocos2d::CCNode *)(*(__int64 (__fastcall **)(void *))(*(_QWORD *)m_specialLayerB5
+ 496LL))(m_specialLayerB5);
LABEL_16:
switch ( a2->m_blendingLayer )
{
case 1:
v11 = -54;
break;
case 2:
v11 = -14;
break;
case 0xD:
v11 = 46;
break;
case 0xE:
v11 = 56;
break;
default:
break;
}
LABEL_23:
ObjectZOrder = GameObject::getObjectZOrder(a2);
if ( ObjectZOrder < -5 )
ObjectZOrder = -5;
v15 = a2->m_blendingLayer - 1;
if ( ObjectZOrder > 5 )
ObjectZOrder = 5;
v7->m_noScale = 1;
v16 = v11 + ObjectZOrder;
switch ( v15 )
{
case 0:
case 1:
case 12:
case 13:
case 14:
v7->m_noScale = 0;
break;
default:
break;
}
if ( m_aboveShaderParent == v7->getParent(v7) )
{
((void (*)(void))m_aboveShaderParent->reorderChild)();
}
else
{
v7->removeFromParentAndCleanup(v7, 0);
m_aboveShaderParent->addChild_0(m_aboveShaderParent, v7, v16);
}
break;
}
}
}
}