//
// PlayLayer::destroyPlayer from 0x6ff190 to 0x6ffbb0 (2592 bytes)
//
// 2 xrefs:
// > ??> @ 0x56cc8
// > ??> @ 0x1428950
//
// This function is hookable on this platform (idp: arm, 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:52:01 +0000
//
__int64 __fastcall PlayLayer::destroyPlayer(PlayLayer *this, PlayerObject *a2, GameObject *a3)
{
PlayerObject *v4; // x22
__int64 v5; // x0
__int64 v6; // x1
signed int CurrentPercentInt; // w23
int v8; // w0
int v9; // w0
int v10; // w0
int v11; // w24
char *v12; // x0
int v13; // w26
GJGameLevel *v14; // x0
int *v15; // x3
GameManager *v16; // x0
DialogLayer *v17; // x0
int v18; // w2
_QWORD *v19; // x22
_BOOL4 v21; // w24
int v22; // w28
int v23; // w27
_BOOL4 v24; // w25
float v25; // s8
__int64 v26; // x0
FMOD::ChannelControl **v27; // x0
unsigned __int64 v28; // x0
__int64 v29; // x23
GameManager *v30; // x0
__int64 v31; // x0
__int64 v32; // x0
float v33; // s0
cocos2d::CCSequence *v34; // x21
cocos2d::CCFiniteTimeAction *v35; // x0
cocos2d::CCAction *v36; // x0
GameManager *v37; // x0
float v38; // s0
GameManager *GameVariable; // x0
cocos2d::CCDelayTime *v40; // x0
cocos2d::CCSequence *v41; // x21
cocos2d::CCFiniteTimeAction *v42; // x0
cocos2d::CCAction *v43; // x21
GJGameLevel *v44; // x0
int *v45; // x3
int v46; // w1
GameManager *v47; // x0
__int64 v48; // x0
GameManager *v49; // x0
PlayerObject *OtherPlayer; // x24
int v51; // w0
_DWORD *v52; // x1
double TempMilliTime; // d0
GameStatsManager *v54; // x0
GameStatsManager *v55; // x0
GameStatsManager *HasDiamonds; // x0
bool v57; // cc
const cocos2d::CCPoint *v58; // x0
float v59; // s0
GameManager *v60; // x0
GameManager *v61; // x0
GameManager *v62; // x0
_BOOL4 v63; // w23
unsigned __int64 UGV; // x0
GameStatsManager *v65; // x0
unsigned __int8 v66; // w0
GameManager *v67; // x0
GameStatsManager *v68; // x0
GameStatsManager *v69; // x0
unsigned __int8 v70; // [xsp+7Ch] [xbp+7Ch]
int v71; // [xsp+80h] [xbp+80h] BYREF
int v72; // [xsp+84h] [xbp+84h] BYREF
__int64 v73[2]; // [xsp+88h] [xbp+88h] BYREF
void *v74; // [xsp+98h] [xbp+98h]
GameManager *v75; // [xsp+A0h] [xbp+A0h] BYREF
__int64 v76; // [xsp+A8h] [xbp+A8h]
void *v77; // [xsp+B0h] [xbp+B0h]
v4 = a2;
if ( !a2 )
v4 = *((PlayerObject **)this + 407);
if ( *(_BYTE *)(*((_QWORD *)this + 407) + 2530LL) || *((_BYTE *)this + 12650) )
return _stack_chk_guard;
if ( a3 )
{
v5 = *((_QWORD *)this + 1741);
if ( v5 )
{
if ( *((_DWORD *)a3 + 229) == *(_DWORD *)(v5 + 916) )
{
*((_BYTE *)this + 14024) = 1;
return _stack_chk_guard;
}
}
}
cocos2d::CCNode::stopActionByTag(this, 20);
v6 = *(_QWORD *)this;
*((_BYTE *)this + 1982) = 1;
(*(void (__fastcall **)(PlayLayer *, float))(v6 + 1464))(this, 1.0);
PlayLayer::commitJumps(this);
CurrentPercentInt = PlayLayer::getCurrentPercentInt(this);
if ( !*((_BYTE *)this + 12544)
|| (v49 = (GameManager *)GameManager::sharedState((GameManager *)*((unsigned __int8 *)this + 12544)),
!(unsigned __int8)GameManager::getGameVariable(v49, "0212")) )
{
GJEffectManager::playerDied(*((GJEffectManager **)this + 269));
}
*((_DWORD *)this + 481) = 0;
if ( !*((_BYTE *)this + 12544) )
{
v47 = (GameManager *)GameManager::sharedState((GameManager *)*((unsigned __int8 *)this + 12544));
if ( !(unsigned __int8)GameManager::getGameVariable(v47, "0014") )
GJBaseGameLayer::shakeCamera(this, 0.15, 1.0, 0.0);
}
v8 = *((unsigned __int8 *)this + 14345);
*((_BYTE *)this + 12648) = 1;
if ( !v8 )
{
v9 = *(_DWORD *)(*((_QWORD *)this + 242) + 328LL) - *(_DWORD *)(*((_QWORD *)this + 242) + 332LL);
if ( (v9 == 1 || v9 == 1001) && !*(_BYTE *)(*((_QWORD *)this + 407) + 2600LL) && *((int *)this + 3053) > 1 )
{
PlayLayer::showHint(this);
if ( *((_BYTE *)this + 14345) )
goto LABEL_16;
v9 = *(_DWORD *)(*((_QWORD *)this + 242) + 328LL) - *(_DWORD *)(*((_QWORD *)this + 242) + 332LL);
}
if ( (v9 == 3 || v9 == 1003) && !*(_BYTE *)(*((_QWORD *)this + 407) + 2601LL) && *((int *)this + 3053) > 1 )
PlayLayer::showHint(this);
}
LABEL_16:
v10 = *((unsigned __int8 *)this + 13842);
*((_BYTE *)this + 12650) = 1;
if ( (v10 || *((_BYTE *)this + 13844))
&& !(*(unsigned __int8 (__fastcall **)(_QWORD))(**((_QWORD **)this + 1727) + 352LL))(*((_QWORD *)this + 1727)) )
{
PlayLayer::toggleDebugDraw((cocos2d::CCDrawNode **)this);
}
PlayerObject::playerDestroyed(v4, 0);
if ( *((_BYTE *)this + 1010) )
{
OtherPlayer = (PlayerObject *)GJBaseGameLayer::getOtherPlayer(this, v4);
GJBaseGameLayer::playExitDualEffect(this, OtherPlayer);
PlayerObject::playerDestroyed(OtherPlayer, 1);
}
if ( *((_BYTE *)this + 1968) )
{
v11 = 0;
*((_DWORD *)this + 3620) = 0x80000000;
*((_DWORD *)this + 3621) = 0x80000000;
}
else
{
v11 = 0;
if ( !*((_BYTE *)this + 12544) )
{
v11 = 1;
v44 = (GJGameLevel *)(*(__int64 (__fastcall **)(PlayerObject *))(*(_QWORD *)v4 + 192LL))(v4);
GJGameLevel::cellForPosition(v44, (const cocos2d::CCPoint *)&v71, &v72, v45);
if ( !(unsigned __int8)PlayLayer::dtCellKnown(this, v71, v72) )
{
v46 = v72;
if ( *((_DWORD *)this + 3620) != v71 || *((_DWORD *)this + 3621) != v72 )
{
*((_DWORD *)this + 3620) = v71;
v11 = 0;
*((_DWORD *)this + 3621) = v46;
}
}
}
}
if ( CurrentPercentInt < 0 )
CurrentPercentInt = 0;
if ( CurrentPercentInt > 99 )
CurrentPercentInt = 99;
if ( (unsigned __int8)PlayLayer::tracksPercent(this) )
{
if ( *((_BYTE *)this + 14185) || *((_BYTE *)this + 14186) )
goto LABEL_53;
v12 = (char *)this + 0x2000;
if ( *((_BYTE *)this + 12236) )
goto LABEL_39;
if ( !*((_BYTE *)this + 12544) && !v11 && *((int *)this + 236) > 29 )
{
GJGameLevel::recordDeath(
*((GJGameLevel **)this + 242),
*((_DWORD *)this + 3547),
CurrentPercentInt,
*((_QWORD *)this + 1554) != 0);
if ( !*((_QWORD *)this + 1554) && CurrentPercentInt > *((_DWORD *)this + 3617) )
*((_DWORD *)this + 3617) = CurrentPercentInt;
}
*(_DWORD *)(*((_QWORD *)this + 242) + 1536LL) = 2;
PlayLayer::dtCommitPlaytime(this);
}
if ( *((_BYTE *)this + 14185) || *((_BYTE *)this + 14186) )
goto LABEL_53;
v12 = (char *)this + 0x2000;
LABEL_39:
if ( v12[4044] || *((_BYTE *)this + 12544) || *((_QWORD *)this + 1554) || *((int *)this + 236) <= 29 )
{
LABEL_53:
v13 = 0;
goto LABEL_54;
}
v13 = 1;
if ( !v11 )
{
v14 = (GJGameLevel *)(*(__int64 (__fastcall **)(PlayerObject *))(*(_QWORD *)v4 + 192LL))(v4);
GJGameLevel::cellForPosition(v14, (const cocos2d::CCPoint *)&v71, &v72, v15);
PlayLayer::dtBumpCell(this, v71, v72, CurrentPercentInt);
*(_DWORD *)(*((_QWORD *)this + 242) + 1536LL) = 2;
*(_BYTE *)(*((_QWORD *)this + 242) + 1744LL) = 1;
}
LABEL_54:
if ( *((_BYTE *)this + 12616) || !(unsigned __int8)PlayLayer::tracksPercent(this) )
{
v21 = 0;
v22 = 0;
v23 = 0;
v70 = 0;
v24 = 0;
}
else
{
v51 = *((unsigned __int8 *)this + 12544);
v24 = false;
if ( !*((_BYTE *)this + 12544) )
{
v57 = CurrentPercentInt <= (int)GJGameLevel::getNormalPercent(*((GJGameLevel **)this + 242));
v51 = *((unsigned __int8 *)this + 12544);
if ( !v57 )
v24 = true;
}
v70 = 0;
if ( !v51 )
{
v52 = *((_DWORD **)this + 242);
if ( CurrentPercentInt <= v52[216] - v52[217] && *((_BYTE *)this + 14636) && !v24 )
{
v24 = CurrentPercentInt > v52[219] - v52[220];
v70 = CurrentPercentInt > v52[219] - v52[220];
}
}
TempMilliTime = PlayLayer::getTempMilliTime(this);
GJGameLevel::savePercentage(
*((GJGameLevel **)this + 242),
CurrentPercentInt,
*((_BYTE *)this + 12544),
*((_DWORD *)this + 3052),
(int)(TempMilliTime - *((double *)this + 1841) - *((double *)this + 1842)),
*((_BYTE *)this + 14024));
if ( *(_DWORD *)(*((_QWORD *)this + 242) + 1140LL) == 1 && !*((_BYTE *)this + 12238) )
{
v60 = (GameManager *)GameManager::sharedState((GameManager *)*((unsigned __int8 *)this + 12238));
GameManager::reportPercentageForLevel(
v60,
*(_DWORD *)(*((_QWORD *)this + 242) + 328LL) - *(_DWORD *)(*((_QWORD *)this + 242) + 332LL),
CurrentPercentInt,
*((_BYTE *)this + 12544));
}
if ( *((_BYTE *)this + 12544) )
{
v21 = 0;
v22 = 0;
v23 = 0;
goto LABEL_58;
}
v54 = (GameStatsManager *)(unsigned int)(*(_DWORD *)(*((_QWORD *)this + 242) + 948LL)
- *(_DWORD *)(*((_QWORD *)this + 242) + 952LL));
if ( (int)v54 <= 0 )
{
v21 = 0;
v22 = 0;
v23 = 0;
goto LABEL_57;
}
v55 = (GameStatsManager *)GameStatsManager::sharedState(v54);
v23 = GameStatsManager::awardCurrencyForLevel(v55, *((GJGameLevel **)this + 242));
HasDiamonds = (GameStatsManager *)(unsigned __int8)GJGameLevel::levelHasDiamonds(*((GJGameLevel **)this + 242));
if ( (_BYTE)HasDiamonds )
{
v68 = (GameStatsManager *)GameStatsManager::sharedState(HasDiamonds);
v22 = GameStatsManager::awardDiamondsForLevel(v68, *((GJGameLevel **)this + 242));
v21 = v23 + v22 > 0;
}
else
{
v22 = 0;
v21 = v23 > 0;
}
}
if ( !*((_BYTE *)this + 12544) )
LABEL_57:
*((_DWORD *)this + 3660) = CurrentPercentInt;
LABEL_58:
v25 = 0.0;
if ( v13 )
{
v58 = (const cocos2d::CCPoint *)(*(__int64 (__fastcall **)(PlayerObject *))(*(_QWORD *)v4 + 192LL))(v4);
PlayLayer::tryShowDeathMarkers(this, v58, CurrentPercentInt, v24);
v25 = v59;
}
if ( !*((_BYTE *)this + 1214) )
{
v26 = *((unsigned __int8 *)this + 12544);
if ( !*((_BYTE *)this + 12544) || (v26 = *((unsigned __int8 *)this + 12545), *((_BYTE *)this + 12545)) )
{
v48 = FMODAudioEngine::sharedEngine((FMODAudioEngine *)v26);
v26 = FMODAudioEngine::pauseAllMusic(v48, 0);
}
v27 = (FMOD::ChannelControl **)FMODAudioEngine::sharedEngine((FMODAudioEngine *)v26);
FMODAudioEngine::stopAllEffects(v27);
}
v28 = *((unsigned __int8 *)this + 1220);
if ( !*((_BYTE *)this + 1220) )
{
v29 = FMODAudioEngine::sharedEngine((FMODAudioEngine *)v28);
v75 = nullptr;
v76 = 0;
v77 = nullptr;
std::string::__init((__int64 *)&v75, "explode_11.ogg", 0xEu);
FMODAudioEngine::playEffect(v29, (char *)&v75, 1.0, 0.0, 0.65);
v28 = (unsigned __int8)v75;
if ( ((unsigned __int8)v75 & 1) != 0 )
operator delete(v77);
}
v30 = (GameManager *)GameManager::sharedState((GameManager *)v28);
if ( !(unsigned __int8)GameManager::getGameVariable(v30, "0026") )
{
v31 = *((unsigned __int8 *)this + 12544);
if ( !*((_BYTE *)this + 12544) )
{
if ( v21 )
v31 = PlayLayer::showNewBest(this, !v24, v23, v22, 0, 0, 0);
v32 = GameManager::sharedState((GameManager *)v31);
UILayer::disableMenu(*(UILayer **)(*(_QWORD *)(v32 + 544) + 13288LL));
v33 = *((float *)this + 304);
shouldRefreshBanner = 0;
if ( v33 <= 0.5 )
v33 = 0.5;
v34 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create((cocos2d::CCDelayTime *)&shouldRefreshBanner, v33);
v35 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCCallFunc::create(this, PlayLayer::showRetryLayer, 0);
v36 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v34, v35, 0);
cocos2d::CCNode::runAction(this, v36);
return _stack_chk_guard;
}
}
*((_BYTE *)this + 14638) = (unsigned __int8)&dword_0 + 1;
v37 = (GameManager *)GameManager::sharedState((GameManager *)((char *)&dword_0 + 1));
if ( (unsigned __int8)GameManager::getGameVariable(v37, "0052") )
v38 = 0.5;
else
v38 = 1.0;
if ( v25 <= 0.0 )
v25 = v38;
GameVariable = nullptr;
if ( *((_BYTE *)this + 12544) )
{
v61 = (GameManager *)GameManager::sharedState(nullptr);
GameVariable = (GameManager *)(unsigned __int8)GameManager::getGameVariable(v61, "0212");
}
if ( (v25 < *((float *)this + 304)) > (unsigned int)GameVariable )
v25 = *((float *)this + 304);
if ( !v21 && !v24 )
{
LABEL_84:
v40 = (cocos2d::CCDelayTime *)cocos2d::CCNode::stopActionByTag(this, 16);
v41 = (cocos2d::CCSequence *)cocos2d::CCDelayTime::create(v40, v25);
v42 = (cocos2d::CCFiniteTimeAction *)cocos2d::CCCallFunc::create(this, PlayLayer::delayedResetLevel, 0);
v43 = (cocos2d::CCAction *)cocos2d::CCSequence::create(v41, v42, 0);
(*(void (__fastcall **)(cocos2d::CCAction *, __int64))(*(_QWORD *)v43 + 72LL))(v43, 16);
cocos2d::CCNode::runAction(this, v43);
return _stack_chk_guard;
}
v62 = (GameManager *)GameManager::sharedState(GameVariable);
v63 = 0;
UGV = (unsigned __int8)GameManager::getUGV(v62, "17");
if ( !(_BYTE)UGV )
{
v69 = (GameStatsManager *)GameStatsManager::sharedState((GameStatsManager *)UGV);
UGV = GameStatsManager::getStat(v69, (const char *)&word_1217DE8);
v63 = (int)UGV > 500;
}
v65 = (GameStatsManager *)GameStatsManager::sharedState((GameStatsManager *)UGV);
v66 = GameStatsManager::awardSecretKey(v65);
v67 = (GameManager *)PlayLayer::showNewBest(this, !v24, v23, v22, v66, v63, v70);
if ( v25 < 1.4 )
v25 = 1.4;
if ( v21 )
{
if ( !v63 )
{
cocos2d::CCNode::stopActionByTag(this, 16);
return _stack_chk_guard;
}
}
else if ( !v63 )
{
goto LABEL_84;
}
v16 = (GameManager *)GameManager::sharedState(v67);
GameManager::setUGV(v16, "17", 1);
v73[0] = 0;
v73[1] = 0;
v74 = nullptr;
std::string::__init(v73, "The Shopkeeper", 0xEu);
v75 = nullptr;
v76 = 0;
v77 = nullptr;
std::string::__init((__int64 *)&v75, "I see you have a lot of orbs. You should visit my shop!", 0x47u);
v17 = (DialogLayer *)DialogObject::create(v73, &v75, 5, 0, 0xFFFFFF, 1.0);
v19 = (_QWORD *)DialogLayer::create(v17, (DialogObject *)((char *)&dword_0 + 1), v18);
if ( ((unsigned __int8)v75 & 1) != 0 )
operator delete(v77);
if ( (v73[0] & 1) != 0 )
operator delete(v74);
(*(void (__fastcall **)(PlayLayer *, _QWORD *, __int64))(*(_QWORD *)this + 464LL))(this, v19, 100);
(*(void (__fastcall **)(_QWORD *, _QWORD))(*v19 + 1168LL))(v19, 0);
v19[78] = (char *)this + 14008;
DialogLayer::updateChatPlacement(v19, 1);
DialogLayer::animateIn(v19, 4);
cocos2d::CCNode::stopActionByTag(this, 16);
return _stack_chk_guard;
}