//
// LevelEditorLayer::getNextColorChannel from 0x672b98 to 0x672e0c (628 bytes)
//
// 3 xrefs:
// > EditorUI::pasteObjects @ 0x6bf82c
// > CustomizeObjectLayer::onNextColorChannel @ 0x8418b8
// > ??> @ 0x7a7a8
//
// 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
//
int LevelEditorLayer::getNextColorChannel(LevelEditorLayer *a1)
{
unsigned __int64 v2; // x0
__int64 *v3; // x1
cocos2d::CCArray *AllObjects; // x0
cocos2d::ccArray *data; // x1
GameObject **arr; // x19
GameObject **v7; // x22
GameObject *i; // x28
int SecondaryColorMode; // w0
cocos2d::CCArray *m_colorTriggers; // x0
cocos2d::ccArray *v11; // x1
int k; // w19
ColorAction *ColorAction; // x0
GameObject **v15; // x19
GameObject **v16; // x22
GameObject *j; // x0
int MainColorMode; // [xsp+64h] [xbp+64h] BYREF
_QWORD *v19; // [xsp+68h] [xbp+68h]
_QWORD *v20; // [xsp+70h] [xbp+70h] BYREF
_QWORD *v21; // [xsp+78h] [xbp+78h] BYREF
_QWORD v22[4]; // [xsp+80h] [xbp+80h] BYREF
float v23; // [xsp+A0h] [xbp+A0h] BYREF
__int64 v24; // [xsp+A8h] [xbp+A8h]
__int64 v25; // [xsp+B0h] [xbp+B0h] BYREF
v22[2] = 0;
v22[3] = 0;
v23 = 1.0;
v24 = 0;
v2 = sub_D146DC(&v23, 10);
v22[1] = v2;
if ( v2 == 1 )
{
v25 = 0;
v3 = &v25;
}
else
{
v3 = (__int64 *)sub_65C6D0(v2);
}
v22[0] = v3;
AllObjects = LevelEditorLayer::getAllObjects(a1);
if ( AllObjects )
{
data = AllObjects->data;
if ( data->num )
{
arr = (GameObject **)data->arr;
v7 = &arr[data->num - 1];
if ( arr <= v7 )
{
for ( i = *arr; *arr; i = *arr )
{
MainColorMode = GameObject::getMainColorMode(i);
SecondaryColorMode = GameObject::getSecondaryColorMode(i);
LODWORD(v21) = SecondaryColorMode;
if ( MainColorMode <= 999 )
{
v19 = v22;
std::_Hashtable,std::__detail::_Identity,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::_M_insert>>>(
v22,
&MainColorMode);
SecondaryColorMode = (int)v21;
}
if ( SecondaryColorMode <= 999 )
{
v20 = v22;
std::_Hashtable,std::__detail::_Identity,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::_M_insert>>>(
v22,
(int *)&v21);
}
if ( v7 < ++arr )
break;
}
}
}
}
m_colorTriggers = a1->m_colorTriggers;
if ( m_colorTriggers )
{
v11 = m_colorTriggers->data;
if ( v11->num )
{
v15 = (GameObject **)v11->arr;
v16 = &v15[v11->num - 1];
if ( v15 <= v16 )
{
for ( j = *v15; *v15; j = *v15 )
{
LODWORD(v20) = GameObject::getColorIndex(j);
if ( (int)v20 <= 999 )
{
v21 = v22;
std::_Hashtable,std::__detail::_Identity,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::_M_insert>>>(
v22,
(int *)&v20);
}
if ( v16 < ++v15 )
break;
}
}
}
}
for ( k = 1; ; ++k )
{
if ( !sub_65B9F4(v22, k) )
{
if ( !GJEffectManager::colorExists(a1->m_levelSettings->GJBaseGameLayer::m_effectManager, k) )
break;
ColorAction = GJEffectManager::getColorAction(a1->m_levelSettings->GJBaseGameLayer::m_effectManager, k);
if ( !ColorAction::isInUse(ColorAction) )
break;
}
if ( k == 1000 )
break;
}
std::_Hashtable,std::__detail::_Identity,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::~_Hashtable((__int64)v22);
if ( k > 999 )
return 999;
else
return k;
}