//
// GameObject::addToColorGroup from 0x76fe7c to 0x76ff20 (164 bytes)
//
// 3 xrefs:
// > PlayLayer::optimizeColorGroups @ 0x704df0
// > GJBaseGameLayer::calculateColorGroups @ 0x9c5084
// > ??> @ 0x67b88
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 12:53:12 +0000
//
__int64 __fastcall GameObject::addToColorGroup(__int64 this, int a2)
{
__int64 v3; // x20
int v4; // w4
__int16 *v5; // x3
int v6; // t1
v3 = this;
if ( *(__int16 *)(this + 1184) <= 9 && (unsigned int)(a2 - 1) <= 0x270E )
{
GameObject::createColorGroupContainer(this, 10);
v4 = *(__int16 *)(v3 + 1184);
v5 = *(__int16 **)(v3 + 1176);
if ( v4 > 0 )
{
this = (unsigned int)*v5;
if ( (_DWORD)this == a2 )
return this;
this = (__int64)(v5 + 1);
while ( (__int16 *)this != &v5[v4 - 1 + 1] )
{
v6 = *(__int16 *)this;
this += 2;
if ( v6 == a2 )
return this;
}
}
v5[*(__int16 *)(v3 + 1184)] = a2;
return (unsigned int)(unsigned __int16)(*(_WORD *)(v3 + 1184))++ + 1;
}
return this;
}