//
// GJBaseGameLayer::toggleGroup from 0x14032b860 to 0x14032b9ce (366 bytes)
//
// 3 xrefs:
// > GJBaseGameLayer::toggleGroupTriggered @ 0x14032b817
// > EffectGameObject::triggerObject @ 0x1406481f5
// > ??> @ 0x14091f190
//
// This function is hookable on this platform (idp: pc, 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 11:30:29 +0000
//
unsigned __int8 __fastcall GJBaseGameLayer::toggleGroup(__int64 a1, int a2, char a3)
{
int v5; // ebx
__int64 v7; // rdx
int v8; // eax
unsigned int v9; // ecx
int v10; // eax
unsigned __int8 result; // al
__int64 Group; // rax
unsigned int *v13; // rdx
__int64 v14; // rax
__int64 *v15; // rdx
__int64 *i; // r8
__int64 v17; // rcx
__int64 *v18; // rdx
__int64 *j; // r8
__int64 v20; // rax
__int64 v21; // r8
__int64 v22; // rax
char v23; // dl
int *v24; // r9
int v25; // eax
_QWORD *v26; // rcx
char v27[24]; // [rsp+20h] [rbp-18h] BYREF
int v28; // [rsp+50h] [rbp+18h] BYREF
v5 = a2;
if ( a2 < 0 )
v5 = 0;
v7 = *(_QWORD *)(*(_QWORD *)(a1 + 2408) + 1280LL);
v8 = v5;
if ( v5 > 9999 )
v8 = 9999;
v9 = v8 & 0x1F;
v10 = *(_DWORD *)(v7 + 4 * ((unsigned __int64)v8 >> 5));
result = _bittest(&v10, v9);
if ( result != a3 )
{
Group = GJBaseGameLayer::getGroup(a1, (unsigned int)a2);
if ( Group )
{
v13 = *(unsigned int **)(Group + 56);
v14 = *v13;
if ( a3 )
{
if ( (_DWORD)v14 )
{
v15 = *((__int64 **)v13 + 2);
for ( i = &v15[v14 - 1]; v15 <= i; *(_BYTE *)(v17 + 654) = *(int *)(v17 + 1216) < 0 )
{
v17 = *v15;
if ( !*v15 )
break;
++*(_DWORD *)(v17 + 1216);
++v15;
}
}
}
else if ( (_DWORD)v14 )
{
v18 = *((__int64 **)v13 + 2);
for ( j = &v18[v14 - 1]; v18 <= j; *(_BYTE *)(v20 + 654) = *(int *)(v20 + 1216) < 0 )
{
v20 = *v18;
if ( !*v18 )
break;
--*(_DWORD *)(v20 + 1216);
++v18;
}
}
}
v21 = *(_QWORD *)(a1 + 2408);
if ( v5 > 9999 )
v5 = 9999;
v22 = *(_QWORD *)(v21 + 1280);
v23 = v5 & 0x1F;
v28 = v5;
v24 = (int *)(v22 + 4 * ((unsigned __int64)v5 >> 5));
v25 = *v24;
v26 = (_QWORD *)(v21 + 1312);
if ( a3 )
{
*v24 = v25 | (1 << v23);
return sub_140066A60(v26, (unsigned __int8 *)&v28);
}
else
{
*v24 = v25 & ~(1 << v23);
return sub_140068190((__int64)v26, (__int64)v27, (unsigned __int8 *)&v28);
}
}
return result;
}