//
// PlayLayer::applyEnterEffect from 0x1403b1660 to 0x1403b1c50 (1520 bytes)
//
// 4 xrefs:
// > PlayLayer::updateVisibility @ 0x1403affc2
// > ??> @ 0x140699910
// > ??> @ 0x140699920
// > ??> @ 0x1406d6df4
//
// 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 PlayLayer::applyEnterEffect(PlayLayer *a1, GameObject *a2, int a3, bool a4)
{
cocos2d::CCPoint *p_m_enterEffectPosition; // r14
cocos2d *v9; // rcx
float v10; // xmm0_4
float v11; // xmm9_4
bool v12; // al
__int64 m_enterType; // rcx
__int16 m_exitType; // ax
bool v15; // zf
cocos2d::CCDirector *v16; // rax
float y; // xmm2_4
float v18; // xmm0_4
int v19; // eax
cocos2d::CCDirector *v20; // rax
cocos2d::CCPoint v21; // [rsp+A0h] [rbp+30h] BYREF
char v22; // [rsp+A8h] [rbp+38h] BYREF
p_m_enterEffectPosition = &a1->m_enterEffectPosition;
cocos2d::CCPoint::CCPoint(&v21);
v10 = cocos2d::clampf(v9, 0.0, 1.0);
v11 = v10;
v12 = a2->m_ignoreEnter || v10 == 1.0;
if ( a4 )
m_enterType = (unsigned __int16)a2->m_enterType;
else
m_enterType = (unsigned __int16)a2->m_exitType;
if ( (_WORD)m_enterType != 0xFFFF && (a3 != -14 || (_WORD)m_enterType == 0xFFF2) )
{
if ( v12 )
{
a2->m_unk3E8 = 1;
if ( a4 )
{
a2->m_enterType = -1;
m_exitType = -1;
LABEL_15:
switch ( m_exitType )
{
case -13:
case -12:
case -11:
case -10:
case -9:
cocos2d::ccpForAngle((cocos2d *)&v21, (float)(*(float *)&a2->m_unk3D8 - 90.0) * 0.017453292);
cocos2d::CCPoint::CCPoint((float)(1.0 - v11) * 100.0, v21.x * (float)((float)(1.0 - v11) * 100.0));
cocos2d::CCPoint::operator+(p_m_enterEffectPosition, &v22);
a2->setPosition_0(a2, (const cocos2d::CCPoint *)&v22);
goto LABEL_59;
case -8:
cocos2d::CCPoint::CCPoint(v10, (float)(1.0 - v11) * 100.0);
cocos2d::CCPoint::operator+(p_m_enterEffectPosition, &v21);
a2->setPosition_0(a2, &v21);
goto LABEL_59;
case -7:
cocos2d::CCPoint::CCPoint(v10, (float)(1.0 - v11) * -100.0);
cocos2d::CCPoint::operator+(p_m_enterEffectPosition, &v21);
a2->setPosition_0(a2, &v21);
goto LABEL_59;
case -6:
case -5:
cocos2d::CCPoint::CCPoint(v10, 0.0);
cocos2d::CCPoint::operator+(p_m_enterEffectPosition, &v21);
a2->setPosition_0(a2, &v21);
goto LABEL_59;
case -4:
if ( !a2->m_usesAudioScale || a2->m_hasNoAudioScale )
{
((void (__fastcall *)(GameObject *))a2->setRScaleX)(a2);
((void (__fastcall *)(GameObject *))a2->setRScaleY)(a2);
}
goto LABEL_53;
case -3:
if ( !a2->m_usesAudioScale || a2->m_hasNoAudioScale )
{
((void (__fastcall *)(GameObject *))a2->setRScaleX)(a2);
((void (__fastcall *)(GameObject *))a2->setRScaleY)(a2);
}
LABEL_53:
a2->setPosition_0(a2, p_m_enterEffectPosition);
break;
default:
a2->setPosition_0(a2, p_m_enterEffectPosition);
LABEL_59:
if ( !a2->m_usesAudioScale || a2->m_hasNoAudioScale )
{
((void (__fastcall *)(GameObject *))a2->setRScaleX)(a2);
((void (__fastcall *)(GameObject *))a2->setRScaleY)(a2);
}
break;
}
if ( v11 == 0.0 )
{
a2->m_unk3E8 = 1;
if ( a4 )
a2->m_enterType = -1;
else
a2->m_exitType = -1;
}
return;
}
a2->m_exitType = -1;
LABEL_14:
m_exitType = a2->m_exitType;
goto LABEL_15;
}
LABEL_44:
if ( a4 )
{
m_exitType = a2->m_enterType;
goto LABEL_15;
}
goto LABEL_14;
}
if ( !v12 )
{
if ( a4 )
a2->m_enterType = a3;
else
a2->m_exitType = a3;
if ( (unsigned int)(a3 + 13) <= 1 )
{
v20 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(m_enterType);
cocos2d::CCDirector::getWinSize(v20);
if ( a1->m_enterEffectPosition.y <= (float)((float)(v21.y * 0.5) + a1->m_gameState.m_cameraPosition2.y) )
v10 = 0.0;
else
v10 = 180.0;
*(float *)&a2->m_unk3D8 = v10;
if ( a3 != -13 )
goto LABEL_44;
v10 = v10 + 180.0;
}
else if ( a3 == -11 )
{
v19 = rand();
v10 = (float)((float)((float)((float)v19 / 32767.0) + (float)((float)v19 / 32767.0)) - 1.0) * 180.0;
}
else
{
if ( (unsigned int)(a3 + 10) > 1 )
goto LABEL_44;
v16 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(m_enterType);
cocos2d::CCDirector::getWinSize(v16);
y = a1->m_enterEffectPosition.y;
v18 = (float)(v21.y * 0.5) + a1->m_gameState.m_cameraPosition2.y;
if ( a3 == -10 )
{
if ( y <= v18 )
v10 = -45.0;
else
v10 = -135.0;
}
else if ( y <= v18 )
{
v10 = 45.0;
}
else
{
v10 = 135.0;
}
}
*(float *)&a2->m_unk3D8 = v10;
goto LABEL_44;
}
a2->getPosition_0(a2);
cocos2d::CCPoint::CCPoint(&v21);
if ( p_m_enterEffectPosition->x != v21.x || a1->m_enterEffectPosition.y != v21.y )
a2->setPosition_0(a2, p_m_enterEffectPosition);
if ( a2->m_unk3E8 )
{
v15 = !a2->m_usesAudioScale;
a2->m_unk3E8 = 0;
if ( v15 || a2->m_hasNoAudioScale )
{
((void (__fastcall *)(GameObject *))a2->setRScaleX)(a2);
((void (__fastcall *)(GameObject *))a2->setRScaleY)(a2);
}
}
}