//
// GJGarageLayer::onToggleItem from 0x10036e710 to 0x10036e86b (347 bytes)
//
// 1 xrefs:
// > GJGarageLayer::setupSpecialPage @ 0x10036d8b6
//
// 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 GJGarageLayer::onToggleItem(GJGarageLayer *a1, cocos2d::CCObject *a2)
{
__int64 v2; // rax
unsigned int v3; // r14d
IconType m_uOrderOfArrival; // r13d
GameManager *v5; // rax
UnlockType v6; // r15d
GameManager *v7; // rax
GameStatsManager *v8; // rax
bool isItemEnabled; // r12
GameStatsManager *v10; // rax
__int64 v11; // rax
__int64 v12; // rbx
__int64 v13; // rax
__int64 v14; // rbx
unsigned int v15; // r14d
__int64 v16; // rax
_DWORD v17[11]; // [rsp+0h] [rbp-2Ch] BYREF
v17[0] = HIDWORD(v2);
v3 = ((__int64 (__fastcall *)(cocos2d::CCObject *))a2->getTag)(a2);
m_uOrderOfArrival = a2[8].m_uOrderOfArrival;
v5 = GameManager::sharedState();
v6 = GameManager::iconTypeToUnlockType(v5, m_uOrderOfArrival);
v7 = GameManager::sharedState();
if ( GameManager::isIconUnlocked(v7, v3, m_uOrderOfArrival) )
{
v8 = GameStatsManager::sharedState();
isItemEnabled = GameStatsManager::isItemEnabled(v8, v6, v3);
v10 = GameStatsManager::sharedState();
GameStatsManager::toggleEnableItem(v10, v6, v3, !isItemEnabled);
v11 = ((__int64 (__fastcall *)(cocos2d::CCObject *))a2->__vftable[13].~CCObject_0)(a2);
if ( !*(_BYTE *)(v11 + 620) )
{
v12 = *(_QWORD *)(v11 + 600);
if ( isItemEnabled )
{
memset(v17, 100, 3);
}
else
{
BYTE2(v17[0]) = -1;
LOWORD(v17[0]) = -1;
}
(*(void (__fastcall **)(__int64, _DWORD *))(*(_QWORD *)v12 + 944LL))(v12, v17);
v13 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v12 + 472LL))(v12);
if ( v13 )
{
v14 = v13;
if ( (unsigned int)sub_100720070(v13) )
{
v15 = 0;
do
{
v16 = sub_1007200C0(v14, v15);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v16 + 328LL))(v16, 1);
++v15;
}
while ( v15 < (unsigned int)sub_100720070(v14) );
}
}
}
}
else
{
((void (__fastcall *)(GJGarageLayer *, _QWORD, _QWORD))a1->showUnlockPopup)(a1, v3, (unsigned int)v6);
}
}