//
// GJBaseGameLayer::triggerGradientCommand from 0x100138e90 to 0x100139286 (1014 bytes)
//
// 6 xrefs:
// > PlayLayer::loadFromCheckpoint @ 0x1000bd621
// > LevelEditorLayer::activateTriggerEffect @ 0x1000ef846
// > GJBaseGameLayer::controlTriggersInGroup @ 0x100135f92
// > GJBaseGameLayer::controlGradientTrigger @ 0x100136ce3
// > GJBaseGameLayer::controlTriggersWithControlID @ 0x100137176
// > EffectGameObject::triggerObject @ 0x1001b9d39
//
// 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)
{
cocos2d::CCDictionary *m_gradientLayers; // rax
cocos2d::CCDictElement *m_pElements; // r14
cocos2d::CCObject *m_pObject; // rbx
int m_gradientID; // ecx
intptr_t v8; // r12
GJGradientLayer *v9; // rbx
int m_blendingMode; // ecx
unsigned int v11; // ecx
unsigned int v12; // r12d
__int64 v13; // rsi
int m_blendingLayer; // ecx
int v15; // r13d
cocos2d::CCNode *m_aboveShaderParent; // r15
void *m_specialLayerT1; // rdi
int ObjectZOrder; // eax
int v19; // ecx
int v20; // r12d
unsigned int v21; // eax
int v22; // ecx
unsigned int v23; // r12d
void (__cdecl *reorderChild)(cocos2d::CCNode *__hidden, cocos2d::CCNode *, int); // rax
if ( a2->m_disableAll )
{
m_gradientLayers = a1->m_gradientLayers;
if ( m_gradientLayers )
{
m_pElements = m_gradientLayers->m_pElements;
while ( m_pElements )
{
m_pObject = m_pElements->m_pObject;
m_pElements = (cocos2d::CCDictElement *)m_pElements->hh.next;
((void (__fastcall *)(cocos2d::CCObject *, _QWORD))m_pObject->__vftable[6].acceptVisitor)(m_pObject, 0);
*(_QWORD *)&m_pObject[10].m_uAutoReleaseCount = 0;
LOBYTE(m_pObject[10].m_uIndexInArray) = 0;
((void (__fastcall *)(cocos2d::CCObject *, _QWORD))m_pObject->__vftable[4].~CCObject)(m_pObject, 0);
}
}
return;
}
m_gradientID = 999;
if ( a2->m_gradientID < 999 )
m_gradientID = a2->m_gradientID;
v8 = m_gradientID;
v9 = (GJGradientLayer *)cocos2d::CCDictionary::objectForKey(a1->m_gradientLayers, m_gradientID);
if ( v9 )
{
if ( a2->m_disable )
{
LABEL_10:
((void (__fastcall *)(GJGradientLayer *, _QWORD))v9->removeFromParentAndCleanup)(v9, 0);
v9->m_triggerObject = nullptr;
return;
}
}
else
{
v9 = GJGradientLayer::create();
v9->m_gradientID = v8;
cocos2d::CCDictionary::setObject(a1->m_gradientLayers, v9, v8);
if ( a2->m_disable )
goto LABEL_10;
}
v9->m_triggerObject = a2;
v9->m_baseColor = GameObject::getMainColorMode(a2);
v9->m_detailColor = GameObject::getSecondaryColorMode(a2);
m_blendingMode = a2->m_blendingMode;
v9->m_blendingMode = m_blendingMode;
v11 = m_blendingMode - 1;
if ( v11 > 2 )
{
v13 = 0x30300000302LL;
LOBYTE(v12) = 0;
}
else
{
v12 = 0x10100u >> (8 * v11);
v13 = qword_100816C70[v11] | qword_100816C88[v11];
}
((void (__fastcall *)(GJGradientLayer *, __int64))v9->setBlendFunc)(v9, v13);
v9->m_bShouldPremultiply = v12;
m_blendingLayer = a2->m_blendingLayer;
v9->m_blendingLayer = m_blendingLayer;
switch ( m_blendingLayer )
{
case 1:
case 2:
v15 = -1600;
goto LABEL_23;
case 3:
case 4:
case 5:
case 6:
case 7:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
v15 = 1399;
switch ( m_blendingLayer )
{
case 3:
m_aboveShaderParent = (cocos2d::CCNode *)((__int64 (__fastcall *)(CCNodeContainer *))a1->m_specialLayerB5->getParent)(a1->m_specialLayerB5);
v15 = -1201;
break;
case 4:
m_aboveShaderParent = (cocos2d::CCNode *)((__int64 (__fastcall *)(CCNodeContainer *))a1->m_specialLayerB4->getParent)(a1->m_specialLayerB4);
v15 = -901;
break;
case 5:
m_aboveShaderParent = (cocos2d::CCNode *)((__int64 (__fastcall *)(CCNodeContainer *))a1->m_specialLayerB3->getParent)(a1->m_specialLayerB3);
v15 = -601;
break;
case 6:
m_aboveShaderParent = (cocos2d::CCNode *)((__int64 (__fastcall *)(CCNodeContainer *))a1->m_specialLayerB2->getParent)(a1->m_specialLayerB2);
v15 = -301;
break;
case 7:
m_aboveShaderParent = (cocos2d::CCNode *)((__int64 (__fastcall *)(CCNodeContainer *))a1->m_specialLayerB1->getParent)(a1->m_specialLayerB1);
v15 = 38;
break;
case 8:
v15 = 99;
goto LABEL_40;
case 9:
v15 = 399;
LABEL_33:
m_specialLayerT1 = a1->m_specialLayerT1;
goto LABEL_41;
case 10:
v15 = 699;
LABEL_38:
m_specialLayerT1 = a1->m_specialLayerT2;
goto LABEL_41;
case 11:
v15 = 999;
LABEL_30:
m_specialLayerT1 = a1->m_specialLayerT3;
goto LABEL_41;
case 12:
LABEL_27:
m_specialLayerT1 = a1->m_specialLayerT4;
goto LABEL_41;
case 13:
LABEL_28:
m_specialLayerT1 = a1->m_groundLayer;
goto LABEL_41;
case 14:
LABEL_26:
m_specialLayerT1 = a1->m_uiTriggerUI;
goto LABEL_41;
}
goto LABEL_42;
case 8:
v15 = 61;
LABEL_40:
m_specialLayerT1 = a1->m_player1;
goto LABEL_41;
case 15:
v15 = 1400;
LABEL_25:
m_aboveShaderParent = a1->m_aboveShaderParent;
goto LABEL_42;
default:
v15 = 0;
LABEL_23:
switch ( m_blendingLayer )
{
case 2:
m_specialLayerT1 = a1->m_middleground;
if ( m_specialLayerT1 )
goto LABEL_41;
break;
case 8:
goto LABEL_40;
case 9:
goto LABEL_33;
case 10:
goto LABEL_38;
case 11:
goto LABEL_30;
case 12:
goto LABEL_27;
case 13:
goto LABEL_28;
case 14:
goto LABEL_26;
case 15:
goto LABEL_25;
default:
break;
}
m_specialLayerT1 = a1->m_background;
LABEL_41:
m_aboveShaderParent = (cocos2d::CCNode *)(*(__int64 (__fastcall **)(void *))(*(_QWORD *)m_specialLayerT1 + 496LL))(m_specialLayerT1);
LABEL_42:
switch ( a2->m_blendingLayer )
{
case 1:
v15 = -54;
break;
case 2:
v15 = -14;
break;
case 0xD:
v15 = 46;
break;
case 0xE:
v15 = 56;
break;
default:
break;
}
ObjectZOrder = GameObject::getObjectZOrder(a2);
v19 = -5;
if ( ObjectZOrder >= -4 )
v19 = ObjectZOrder;
v20 = 5;
if ( v19 < 5 )
v20 = v19;
v9->m_noScale = 1;
v21 = a2->m_blendingLayer;
if ( v21 <= 0xF )
{
v22 = 57350;
if ( _bittest(&v22, v21) )
v9->m_noScale = 0;
}
v23 = v15 + v20;
if ( (cocos2d::CCNode *)((__int64 (__fastcall *)(GJGradientLayer *))v9->getParent)(v9) == m_aboveShaderParent )
{
reorderChild = m_aboveShaderParent->reorderChild;
}
else
{
((void (__fastcall *)(GJGradientLayer *, _QWORD))v9->removeFromParentAndCleanup)(v9, 0);
reorderChild = m_aboveShaderParent->addChild_0;
}
((void (__fastcall *)(cocos2d::CCNode *, GJGradientLayer *, _QWORD))reorderChild)(m_aboveShaderParent, v9, v23);
break;
}
}