//
// GJBaseGameLayer::triggerGradientCommand from 0x1001ef928 to 0x1001efc28 (768 bytes)
//
// 4 xrefs:
// > PlayLayer::loadFromCheckpoint @ 0x10012123c
// > GJBaseGameLayer::controlGradientTrigger @ 0x1001ee414
// > LevelEditorLayer::activateTriggerEffect @ 0x100361048
// > EffectGameObject::triggerObject @ 0x100385960
//
// 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::triggerGradientCommand(GJBaseGameLayer *a1, GradientTriggerObject *a2)
{
int m_gradientID; // w23
GJGradientLayer *v5; // x19
int m_blendingMode; // w8
__int64 v7; // x12
__int64 v8; // x13
__int64 v9; // x15
bool v10; // w11
bool v11; // zf
unsigned __int64 v12; // x8
__int64 v13; // x9
bool v14; // w21
int m_blendingLayer; // w23
int v16; // w21
void *m_middleground; // x0
cocos2d::CCNode *m_aboveShaderParent; // x22
int v19; // w8
int ObjectZOrder; // w0
int v21; // w8
int v22; // w23
unsigned int v23; // w9
if ( a2->m_disableAll )
{
GJBaseGameLayer::resetGradientLayers(a1);
}
else
{
if ( a2->m_gradientID >= 999 )
m_gradientID = 999;
else
m_gradientID = a2->m_gradientID;
v5 = (GJGradientLayer *)cocos2d::CCDictionary::objectForKey(a1->m_gradientLayers, m_gradientID);
if ( !v5 )
{
v5 = GJGradientLayer::create();
v5->m_gradientID = m_gradientID;
cocos2d::CCDictionary::setObject(a1->m_gradientLayers, v5, m_gradientID);
}
if ( a2->m_disable )
{
((void (__fastcall *)(GJGradientLayer *, _QWORD))v5->removeFromParentAndCleanup)(v5, 0);
v5->m_triggerObject = nullptr;
}
else
{
v5->m_triggerObject = a2;
v5->m_baseColor = GameObject::getMainColorMode(a2);
v5->m_detailColor = GameObject::getSecondaryColorMode(a2);
m_blendingMode = a2->m_blendingMode;
v5->m_blendingMode = m_blendingMode;
v7 = 0x30100000000LL;
v8 = 775;
v9 = 770;
if ( m_blendingMode == 2 )
v9 = 774;
if ( m_blendingMode == 3 )
{
v10 = 1;
}
else
{
v7 = 0x30300000000LL;
v8 = v9;
v10 = m_blendingMode == 2;
}
v11 = m_blendingMode == 1;
if ( m_blendingMode == 1 )
v12 = (unsigned __int64)&_mh_execute_header;
else
v12 = v7;
if ( v11 )
v13 = 770;
else
v13 = v8;
v14 = !v11 && v10;
((void (__fastcall *)(GJGradientLayer *, unsigned __int64))v5->setBlendFunc)(v5, v13 | v12);
v5->m_bShouldPremultiply = v14;
m_blendingLayer = a2->m_blendingLayer;
v5->m_blendingLayer = m_blendingLayer;
v16 = GJBaseGameLayer::maxZOrderForShaderZ(a1, m_blendingLayer);
switch ( m_blendingLayer )
{
case 2:
m_middleground = a1->m_middleground;
if ( m_middleground )
goto LABEL_40;
goto LABEL_26;
case 3:
m_middleground = a1->m_specialLayerB5;
goto LABEL_40;
case 4:
m_middleground = a1->m_specialLayerB4;
goto LABEL_40;
case 5:
m_middleground = a1->m_specialLayerB3;
goto LABEL_40;
case 6:
m_middleground = a1->m_specialLayerB2;
goto LABEL_40;
case 7:
m_middleground = a1->m_specialLayerB1;
goto LABEL_40;
case 8:
m_middleground = a1->m_player1;
goto LABEL_40;
case 9:
m_middleground = a1->m_specialLayerT1;
goto LABEL_40;
case 10:
m_middleground = a1->m_specialLayerT2;
goto LABEL_40;
case 11:
m_middleground = a1->m_specialLayerT3;
goto LABEL_40;
case 12:
m_middleground = a1->m_specialLayerT4;
goto LABEL_40;
case 13:
m_middleground = a1->m_groundLayer;
goto LABEL_40;
case 14:
m_middleground = a1->m_uiTriggerUI;
goto LABEL_40;
case 15:
m_aboveShaderParent = a1->m_aboveShaderParent;
goto LABEL_41;
default:
LABEL_26:
m_middleground = a1->m_background;
LABEL_40:
m_aboveShaderParent = (cocos2d::CCNode *)(*(__int64 (__fastcall **)(void *))(*(_QWORD *)m_middleground + 496LL))(m_middleground);
LABEL_41:
v19 = a2->m_blendingLayer;
if ( v19 > 12 )
{
if ( v19 == 13 )
{
v16 = 46;
}
else if ( v19 == 14 )
{
v16 = 56;
}
}
else if ( v19 == 1 )
{
v16 = -54;
}
else if ( v19 == 2 )
{
v16 = -14;
}
ObjectZOrder = GameObject::getObjectZOrder(a2);
if ( ObjectZOrder <= -5 )
v21 = -5;
else
v21 = ObjectZOrder;
if ( v21 >= 5 )
v22 = 5;
else
v22 = v21;
v5->m_noScale = 1;
v23 = a2->m_blendingLayer;
if ( v23 <= 0xF && ((1 << v23) & 0xE006) != 0 )
v5->m_noScale = 0;
if ( (cocos2d::CCNode *)((__int64 (__fastcall *)(GJGradientLayer *))v5->getParent)(v5) == m_aboveShaderParent )
{
((void (__fastcall *)(cocos2d::CCNode *, GJGradientLayer *, _QWORD))m_aboveShaderParent->reorderChild)(
m_aboveShaderParent,
v5,
(unsigned int)(v22 + v16));
}
else
{
((void (__fastcall *)(GJGradientLayer *, _QWORD))v5->removeFromParentAndCleanup)(v5, 0);
((void (__fastcall *)(cocos2d::CCNode *, GJGradientLayer *, _QWORD))m_aboveShaderParent->addChild_0)(
m_aboveShaderParent,
v5,
(unsigned int)(v22 + v16));
}
break;
}
}
}
}