//
// GJShopLayer::ccTouchBegan from 0x1402ae950 to 0x1402aeb88 (568 bytes)
//
// 2 xrefs:
// > ??> @ 0x14057e268
// > ??> @ 0x1406d2288
//
// 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
//
// Hidden C++ exception states: #wind=3
bool GJShopLayer::ccTouchBegan(GJShopLayer *a1, cocos2d::CCTouch *a2, cocos2d::CCEvent *a3)
{
struct cocos2d::CCPoint v5; // rax
float v6; // xmm6_4
float *v7; // rax
GameManager *v8; // rcx
__int64 v9; // rcx
char v10; // cl
cocos2d::CCGridBase *m_pGrid; // rax
void *v12; // [rsp+30h] [rbp-58h]
cocos2d::CCRect v13; // [rsp+38h] [rbp-50h] BYREF
__int128 v14; // [rsp+48h] [rbp-40h] BYREF
__int64 v15; // [rsp+58h] [rbp-30h]
__int64 v16; // [rsp+60h] [rbp-28h]
struct cocos2d::CCPoint v17; // [rsp+90h] [rbp+8h] BYREF
__int128 *v18; // [rsp+A8h] [rbp+20h] BYREF
if ( LODWORD(a1->m_sAdditionalTransform.ty) )
return 0;
cocos2d::CCTouch::getLocation(a2);
v5 = cocos2d::CCNode::convertToNodeSpace((GJShopLayer *)((char *)a1 - 320), (const struct cocos2d::CCPoint *)&v18);
((void (__fastcall *)(_QWORD, _QWORD))cocos2d::CCPoint::operator=)(&v17, v5);
v6 = *(float *)(((__int64 (__fastcall *)(cocos2d::CCGridBase *))a1->m_pGrid->cocos2d::CCLayer::cocos2d::CCNode::__vftable[2].~CCGridBase)(a1->m_pGrid)
+ 4);
v7 = (float *)((__int64 (__fastcall *)(cocos2d::CCGridBase *))a1->m_pGrid->cocos2d::CCLayer::cocos2d::CCNode::__vftable[2].~CCGridBase)(a1->m_pGrid);
cocos2d::CCRect::CCRect(&v13, *v7 - 40.0, (float)(v6 - 45.0) + 10.0, 80.0, 90.0);
if ( cocos2d::CCRect::containsPoint(&v13, &v17) && !BYTE1(a1->m_pGrid[6].m_uUnknown) )
{
v8 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v18 = (__int128 *)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v18);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v8 = (GameManager *)qword_1406C2ED8;
}
if ( !GameManager::getUGV(v8, (const char *)&word_14055A648) )
goto LABEL_12;
v18 = &v14;
v14 = 0;
v15 = 4;
v16 = 15;
strcpy((char *)&v14, "0022");
v9 = qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v12 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v12);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v9 = qword_1406C2EE8;
}
if ( GameStatsManager::isSpecialChestUnlocked(v9, &v14) )
LABEL_12:
v10 = 0;
else
v10 = 1;
m_pGrid = a1->m_pGrid;
if ( m_pGrid[6].m_unknown2 >= 5 || v10 )
{
m_pGrid[6].m_unknown2 = 2;
GJShopLayer::showReactMessage((GJShopLayer *)((char *)a1 - 320));
if ( LODWORD(a1->m_pChildren) == 9 )
a1->m_pGrid[6].m_unknown2 = 0;
}
else
{
AnimatedShopKeeper::playReactAnimation((AnimatedShopKeeper *)a1->m_pGrid);
}
}
return 1;
}