//
// GJBaseGameLayer::hasUniqueCoin from 0x140216700 to 0x1402168ca (458 bytes)
//
// 5 xrefs:
// > EnhancedGameObject::updateUserCoin @ 0x1401a695e
// > GameObject::playDestroyObjectAnim @ 0x1401ab34a
// > GJBaseGameLayer::collisionCheckObjects @ 0x140215c39
// > GJBaseGameLayer::collisionCheckObjects @ 0x140215cef
// > ??> @ 0x1406cd134
//
// 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 GJBaseGameLayer::hasUniqueCoin(GJBaseGameLayer *a1, EffectGameObject *a2)
{
GJGameLevel *m_level; // rcx
int m_secretCoinID; // eax
const char *CoinKey; // rdi
GameStatsManager *v8; // rcx
GameStatsManager *v9; // rcx
void *v10; // [rsp+30h] [rbp+8h]
void *v11; // [rsp+30h] [rbp+8h]
void *v12; // [rsp+30h] [rbp+8h]
m_level = a1->m_level;
if ( m_level->m_levelType == Editor )
{
if ( a2->getType(a2) == (Collectible|0x1) )
{
m_secretCoinID = a2->m_secretCoinID;
switch ( m_secretCoinID )
{
case 1:
return a1->m_level->m_firstCoinVerified.random - a1->m_level->m_firstCoinVerified.seed == 1;
case 2:
return a1->m_level->m_secondCoinVerified.random - a1->m_level->m_secondCoinVerified.seed == 1;
case 3:
return a1->m_level->m_thirdCoinVerified.random - a1->m_level->m_thirdCoinVerified.seed == 1;
}
}
return 0;
}
CoinKey = GJGameLevel::getCoinKey(m_level, a2->m_secretCoinID);
v8 = (GameStatsManager *)qword_1406C2EE8;
if ( a1->m_level->m_levelType == Main )
{
if ( !qword_1406C2EE8 )
{
v10 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v10);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v8 = (GameStatsManager *)qword_1406C2EE8;
}
return GameStatsManager::hasSecretCoin(v8, CoinKey);
}
else
{
if ( !qword_1406C2EE8 )
{
v11 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v11);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v8 = (GameStatsManager *)qword_1406C2EE8;
}
if ( !GameStatsManager::hasUserCoin(v8, CoinKey) )
{
v9 = (GameStatsManager *)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 = (GameStatsManager *)qword_1406C2EE8;
}
if ( !GameStatsManager::hasPendingUserCoin(v9, CoinKey) )
return 0;
}
return 1;
}
}