//
// GJGarageLayer::onToggleItem from 0x100357b30 to 0x100357c8b (347 bytes)
//
// 1 xrefs:
// > GJGarageLayer::setupSpecialPage @ 0x100356cd6
//
// 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 12:28:52 +0000
//
__int64 __fastcall GJGarageLayer::onToggleItem(__int64 a1, _DWORD *a2)
{
__int64 v2; // rax
unsigned int v4; // r14d
unsigned int v5; // r13d
__int64 v6; // rdx
double v7; // xmm0_8
__int64 v8; // rax
__int64 v9; // rdi
unsigned int v10; // r15d
__int64 v11; // rdx
double v12; // xmm0_8
__int64 v13; // rax
__int64 v14; // rax
unsigned __int8 isItemEnabled; // r12
__int64 v16; // rax
__int64 result; // rax
__int64 v18; // rbx
__int64 v19; // rbx
unsigned int v20; // r14d
__int64 v21; // rax
_DWORD v22[11]; // [rsp+0h] [rbp-2Ch] BYREF
v22[0] = HIDWORD(v2);
v4 = (*(__int64 (__fastcall **)(_DWORD *))(*(_QWORD *)a2 + 64LL))(a2);
v5 = a2[124];
*(_QWORD *)&v7 = GameManager::sharedState(a2, a2, v6).u64[0];
v9 = v8;
v10 = GameManager::iconTypeToUnlockType(v8, v5, v7);
*(_QWORD *)&v12 = GameManager::sharedState(v9, v5, v11).u64[0];
if ( !(unsigned __int8)GameManager::isIconUnlocked(v13, v4, v5, v12) )
return (*(__int64 (__fastcall **)(__int64, _QWORD, _QWORD))(*(_QWORD *)a1 + 1184LL))(a1, v4, v10);
v14 = GameStatsManager::sharedState();
isItemEnabled = GameStatsManager::isItemEnabled(v14, v10, v4);
v16 = GameStatsManager::sharedState();
GameStatsManager::toggleEnableItem(v16, v10, v4, isItemEnabled ^ 1);
result = (*(__int64 (__fastcall **)(_DWORD *))(*(_QWORD *)a2 + 1072LL))(a2);
if ( !*(_BYTE *)(result + 620) )
{
v18 = *(_QWORD *)(result + 600);
if ( isItemEnabled )
{
memset(v22, 100, 3);
}
else
{
BYTE2(v22[0]) = -1;
LOWORD(v22[0]) = -1;
}
(*(void (__fastcall **)(__int64, _DWORD *))(*(_QWORD *)v18 + 960LL))(v18, v22);
result = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v18 + 488LL))(v18);
if ( result )
{
v19 = result;
result = sub_1007FEF90(result);
if ( (_DWORD)result )
{
v20 = 0;
do
{
v21 = sub_1007FEFE0(v19, v20);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v21 + 344LL))(v21, 1);
++v20;
result = sub_1007FEF90(v19);
}
while ( v20 < (unsigned int)result );
}
}
}
return result;
}