//
// PlayerObject::toggleGhostEffect from 0x14039ee30 to 0x14039f0fc (716 bytes)
//
// 13 xrefs:
// > PlayerObject::playCompleteEffect @ 0x1403840e5
// > PlayerObject::resetObject @ 0x140397418
// > PlayerObject::playerDestroyed @ 0x140397ddc
// > PlayerObject::loadFromCheckpoint @ 0x1403a2a6d
// > PlayLayer::playEndAnimationToPos @ 0x1403abccd
// > PlayLayer::playPlatformerEndAnimationToPos @ 0x1403ac56c
// > PlayLayer::removeAllObjects @ 0x1403bae6b
// > PlayLayer::removeAllObjects @ 0x1403baefc
// > EffectGameObject::triggerObject @ 0x1404a61e3
// > EffectGameObject::triggerObject @ 0x1404a61fe
// > EffectGameObject::triggerObject @ 0x1404a6262
// > EffectGameObject::triggerObject @ 0x1404a627d
// > ??> @ 0x1406d67c4
//
// 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=4
void PlayerObject::toggleGhostEffect(PlayerObject *a1, GhostType a2)
{
GhostTrailEffect *m_ghostTrail; // rdi
void (__fastcall ***m_delegate)(_QWORD, GhostTrailEffect *); // rcx
const cocos2d::ccColor3B *v5; // rax
GhostTrailEffect *v6; // rax
GhostTrailEffect *v7; // rcx
GhostTrailEffect *v8; // rcx
__int64 v9; // rdx
GhostTrailEffect *v10; // rax
GhostTrailEffect *v11; // rcx
GhostTrailEffect *v12; // rcx
__int64 *v13; // rax
__int64 v14; // rdx
void *v15; // [rsp+30h] [rbp+8h]
if ( a1->m_ghostType != a2 )
{
a1->m_ghostType = a2;
m_ghostTrail = a1->m_ghostTrail;
if ( m_ghostTrail )
{
m_delegate = (void (__fastcall ***)(_QWORD, GhostTrailEffect *))m_ghostTrail->m_delegate;
if ( m_delegate )
(**m_delegate)(m_delegate, m_ghostTrail);
cocos2d::CCNode::unscheduleAllSelectors(m_ghostTrail);
cocos2d::CCNode::stopAllActions(m_ghostTrail);
m_ghostTrail->removeMeAndCleanup(m_ghostTrail);
a1->m_ghostTrail = nullptr;
}
if ( a1->m_ghostType == Enabled )
{
v5 = a1->m_iconSprite->getColor(&a1->m_iconSprite->cocos2d::CCRGBAProtocol);
if ( *(_WORD *)&v5->r || v5->b )
{
v10 = GhostTrailEffect::create();
a1->m_ghostTrail = v10;
v10->m_playerObject = a1;
a1->m_ghostTrail->m_blendFunc = (cocos2d::ccBlendFunc)0x100000302LL;
a1->m_ghostTrail->m_playerScale = a1->m_vehicleSize;
a1->m_ghostTrail->m_opacity = 200.0;
v11 = a1->m_ghostTrail;
*(_WORD *)&v11->m_color.r = *(_WORD *)&a1->m_playerColor1.r;
v11->m_color.b = a1->m_playerColor1.b;
v12 = a1->m_ghostTrail;
v12->m_iconSprite = a1->m_iconSprite;
v12->m_snapshotInterval = 0.050000001;
v12->m_fadeInterval = 0.40000001;
v12->m_ghostScale = 0.60000002;
v12->m_scaleTwice = 0;
cocos2d::CCNode::schedule(v12, GhostTrailEffect::trailSnapshot);
v9 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
LABEL_12:
v15 = operator new(0x668u);
v13 = (__int64 *)sub_14017AB00((__int64)v15);
v14 = *v13;
qword_1406C2ED8 = (__int64)v13;
(*(void (__fastcall **)(__int64 *))(v14 + 72))(v13);
v9 = qword_1406C2ED8;
}
}
else
{
v6 = GhostTrailEffect::create();
a1->m_ghostTrail = v6;
v6->m_playerObject = a1;
a1->m_ghostTrail->m_playerScale = a1->m_vehicleSize;
a1->m_ghostTrail->m_opacity = 200.0;
v7 = a1->m_ghostTrail;
*(_WORD *)&v7->m_color.r = 0;
v7->m_color.b = 0;
v8 = a1->m_ghostTrail;
v8->m_iconSprite = a1->m_iconSprite;
v8->m_snapshotInterval = 0.050000001;
v8->m_fadeInterval = 0.40000001;
v8->m_ghostScale = 0.60000002;
v8->m_scaleTwice = 0;
cocos2d::CCNode::schedule(v8, GhostTrailEffect::trailSnapshot);
v9 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
goto LABEL_12;
}
a1->m_ghostTrail->m_objectLayer = *(cocos2d::CCLayer **)(*(_QWORD *)(v9 + 520) + 4072LL);
(*(void (__fastcall **)(_QWORD, GhostTrailEffect *))(**(_QWORD **)(*(_QWORD *)(v9 + 520) + 4072LL) + 448LL))(
*(_QWORD *)(*(_QWORD *)(v9 + 520) + 4072LL),
a1->m_ghostTrail);
}
}
}