//
// GJBaseGameLayer::teleportPlayer from 0x14020fdb0 to 0x1402107fc (2636 bytes)
//
// 4 xrefs:
// > GJBaseGameLayer::collisionCheckObjects @ 0x14021557a
// > PlayerObject::ringJump @ 0x140398fcd
// > EffectGameObject::triggerObject @ 0x1404a73f0
// > ??> @ 0x1406ccf0c
//
// 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=1
void GJBaseGameLayer::teleportPlayer(GJBaseGameLayer *a1, TeleportPortalObject *a2, PlayerObject *a3)
{
float v3; // xmm3_4
PlayerObject *m_player1; // rdi
int m_objectID; // r13d
TeleportPortalObject *m_orangePortal; // rcx
__int64 v9; // rbx
TeleportPortalObject *v10; // r14
int m_targetGroupID; // edx
cocos2d::CCArray *Group; // rbx
int v13; // eax
float v14; // xmm1_4
__int64 v15; // rax
double v16; // xmm0_8
float *v17; // rax
__int64 v18; // rbx
__int64 v19; // rax
int m_gravityMode; // eax
bool v21; // dl
bool *p_m_hasNoEffects; // rbx
float v23; // xmm8_4
bool *v24; // r12
float v25; // xmm8_4
float v26; // xmm6_4
__int64 v27; // rax
double v28; // xmm0_8
__int64 v29; // rcx
void (__fastcall **v30)(void *); // rax
void *v31; // rcx
__int64 v32; // rax
__int64 v33; // rbx
const cocos2d::CCPoint *v34; // rax
const cocos2d::CCPoint *v35; // r12
_BOOL8 v36; // rdx
__int64 v37; // rcx
cocos2d::CCPoint v38; // rax
cocos2d::CCPoint v39; // rbx
cocos2d::CCPoint v40; // rax
cocos2d::CCLightning *v41; // rbx
__int64 v42; // rbx
struct cocos2d::CCDelayTime *v43; // rax
struct cocos2d::CCSequence *v44; // rax
cocos2d::ccColor3B *v45; // r8
float v46; // xmm6_4
cocos2d::CCDirector *v47; // rax
float v48; // xmm10_4
bool m_staticForceAdditive; // bl
float v50; // xmm1_4
float v51; // xmm1_4
float *v52; // rax
__int64 v53; // rax
float v54; // xmm7_4
float y; // xmm8_4
float v56; // xmm6_4
float v57; // xmm0_4
float v58; // xmm9_4
float v59; // xmm6_4
float v60; // xmm0_4
__int64 v61; // rax
int v62; // eax
bool m_isSideways; // r8
int v64; // ecx
int v65; // ecx
int v66; // eax
float v67; // xmm0_4
bool v68; // dl
float v69; // [rsp+28h] [rbp-89h]
cocos2d::CCPoint v70; // [rsp+38h] [rbp-79h] BYREF
char v71[8]; // [rsp+40h] [rbp-71h] BYREF
cocos2d::CCPoint v72; // [rsp+48h] [rbp-69h] BYREF
cocos2d::CCPoint v73; // [rsp+50h] [rbp-61h] BYREF
cocos2d::CCPoint v74; // [rsp+58h] [rbp-59h] BYREF
cocos2d::CCPoint v75; // [rsp+60h] [rbp-51h] BYREF
cocos2d::CCPoint X; // [rsp+120h] [rbp+6Fh] BYREF
cocos2d::CCPoint v77; // [rsp+128h] [rbp+77h] BYREF
cocos2d::CCPoint v78; // [rsp+130h] [rbp+7Fh] BYREF
m_player1 = a3;
if ( !a3 )
m_player1 = a1->m_player1;
m_player1->m_wasTeleported = 1;
m_objectID = a2->m_objectID;
m_orangePortal = a2->m_orangePortal;
if ( m_orangePortal )
{
v9 = ((__int64 (__fastcall *)(TeleportPortalObject *, cocos2d::CCPoint *))m_orangePortal->getStartPos)(
m_orangePortal,
&X);
a2->m_teleportYOffset = *(float *)(v9 + 4)
- *(float *)(((__int64 (__fastcall *)(TeleportPortalObject *, cocos2d::CCPoint *))a2->getStartPos)(
a2,
&v77)
+ 4);
}
m_player1->getPosition_0(m_player1);
cocos2d::CCPoint::CCPoint(&v70);
v10 = a2->m_orangePortal;
if ( v10 )
goto LABEL_12;
m_targetGroupID = a2->m_targetGroupID;
if ( m_targetGroupID <= 0
|| (Group = GJBaseGameLayer::getGroup(a1, m_targetGroupID), v13 = cocos2d::CCArray::count(Group), v13 <= 0) )
{
v10 = nullptr;
goto LABEL_23;
}
if ( v13 == 1
|| (qword_1406C2EF8 = 214013 * qword_1406C2EF8 + 2531011,
v14 = (float)(((unsigned __int64)qword_1406C2EF8 >> 16) & 0x7FFF) / 32767.0,
v14 == 1.0) )
{
v14 = 0.0;
}
v10 = (TeleportPortalObject *)cocos2d::CCArray::objectAtIndex(Group, (int)(float)((float)v13 * v14));
if ( v10 )
{
LABEL_12:
a2->getPosition_0(a2);
cocos2d::CCPoint::CCPoint(&v77);
v16 = cocos2d::CCPoint::operator=(&m_player1->m_lastPortalPos, v15);
m_player1->m_lastActivatedPortal = a2;
m_player1->m_fallStartY = 0.0;
if ( a2->m_objectID == 747 )
{
((__int64 (__fastcall *)(TeleportPortalObject *, cocos2d::CCPoint *))a2->getRealPosition)(a2, &v77);
v17 = (float *)m_player1->getPosition_0(m_player1);
cocos2d::CCPoint::CCPoint(*(float *)&v16, *v17);
}
else
{
((void (__fastcall *)(TeleportPortalObject *, cocos2d::CCPoint *))v10->getRealPosition)(v10, &X);
}
if ( a2->m_saveOffset )
{
v18 = (__int64)m_player1->getPosition_0(m_player1);
v19 = ((__int64 (__fastcall *)(TeleportPortalObject *, cocos2d::CCPoint *))a2->getRealPosition)(a2, &v78);
cocos2d::CCPoint::operator-(v19, &v77, v18);
cocos2d::CCPoint::operator-(&X, &v78, &v77);
cocos2d::CCPoint::operator=(&X, &v78);
}
if ( a2->m_ignoreX )
X.x = m_player1->getPosition_0(m_player1)->x;
if ( a2->m_ignoreY )
X.y = m_player1->getPosition_0(m_player1)->y;
m_player1->setPosition_0(m_player1, &X);
}
LABEL_23:
m_gravityMode = a2->m_gravityMode;
if ( m_gravityMode <= 0 )
goto LABEL_31;
switch ( m_gravityMode )
{
case 1:
v21 = 0;
break;
case 2:
v21 = 1;
break;
case 3:
v21 = !m_player1->m_isUpsideDown;
break;
default:
goto LABEL_31;
}
PlayerObject::flipGravity(m_player1, v21, 1);
LABEL_31:
if ( m_objectID != 3022 )
{
GameObject::playShineEffect(a2);
a2->activatedByPlayer(a2, m_player1);
}
if ( v10 )
{
p_m_hasNoEffects = &a2->m_hasNoEffects;
if ( !a2->m_hasNoEffects )
{
LOWORD(X.x) = -256;
LOWORD(v77.x) = -256;
BYTE2(v77.x) = -1;
PlayerObject::spawnPortalCircle(m_player1, (cocos2d::ccColor3B *)&v77, 50.0);
}
v23 = 90.0;
v24 = &a2->m_hasNoEffects;
if ( v10->m_objectID == 38
|| v10->m_objectID == 747
|| v10->m_objectID == 749
|| v10->m_objectID == 2064
|| v10->m_objectID == 2902 )
{
v23 = 180.0;
v24 = &a2->m_hasNoEffects;
}
v25 = v23 - v10->getRotationX(v10);
v26 = (float)(v10->isFlipX(v10) ? 0xB4 : 0) + v25;
v10->getPosition_0(v10);
cocos2d::CCPoint::CCPoint(&X);
v28 = cocos2d::CCPoint::operator=(&m_player1->m_lastPortalPos, v27);
m_player1->m_lastActivatedPortal = v10;
GameObject::playShineEffect(v10);
if ( !*p_m_hasNoEffects )
{
LOWORD(X.x) = -14081;
LOWORD(v77.x) = -14081;
BYTE2(v77.x) = 0;
PlayerObject::spawnPortalCircle(m_player1, (cocos2d::ccColor3B *)&v77, 50.0);
p_m_hasNoEffects = v24;
}
PlayerObject::resetStreak(m_player1);
if ( m_player1->m_isDart )
PlayerObject::placeStreakPoint(m_player1);
if ( !*p_m_hasNoEffects )
{
if ( m_objectID == 3022 )
{
cocos2d::CCPoint::CCPoint(&X);
v30 = (void (__fastcall **)(void *))m_player1->GameObject::CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v31 = m_player1;
}
else
{
a2->getPosition_0(a2);
cocos2d::CCPoint::CCPoint(&X);
v30 = (void (__fastcall **)(void *))v10->RingObject::EffectGameObject::EnhancedGameObject::GameObject::CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v31 = v10;
}
v30[25](v31);
cocos2d::CCPoint::CCPoint(&v78);
LOWORD(v77.x) = *(_WORD *)&m_player1->m_playerColor1.r;
BYTE2(v77.x) = m_player1->m_playerColor1.b;
cocos2d::CCPoint::CCPoint(&v72);
v33 = v32;
cocos2d::CCPoint::CCPoint(&v73);
v35 = v34;
cocos2d::CCPoint::operator-(v33, v71, v34);
v37 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v74 = (cocos2d::CCPoint)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(*(_QWORD *)&v74);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v37 = qword_1406C2ED8;
}
if ( !*(_BYTE *)(v37 + 917) )
{
cocos2d::CCPoint::CCPoint(&v74);
v39 = v38;
cocos2d::CCPoint::CCPoint(&v75);
v41 = cocos2d::CCLightning::lightningWithStrikePoint(v40, v39, 0.2);
v41->setPosition_0(v41, v35);
v41->setColor(&v41->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v77);
v41->m_lineWidth = 4.0;
*(_WORD *)&v41->m_unkBool = 257;
v41->m_opacityModify = 1.0;
v41->m_displacement = 100;
a1->m_objectLayer->addChild_0(a1->m_objectLayer, v41, 0);
}
LOBYTE(v36) = 1;
a1->m_flashNode->setVisible(a1->m_flashNode, v36);
v42 = cocos2d::CCHide::create();
LODWORD(v28) = 1034147594;
v43 = cocos2d::CCDelayTime::create(0.079999998);
v44 = cocos2d::CCSequence::create(v43, v42, 0);
cocos2d::CCNode::runAction((CCLightFlash *)a1->m_flashNode, (cocos2d::CCPoint)v44, v45, v3, v69);
}
}
else
{
v46 = (float)(a2->isFlipX(a2) ? 0xB4 : 0);
*(float *)&v28 = a2->getRotationX(a2);
v26 = v46 - *(float *)&v28;
}
if ( a2->m_teleportEase )
a1->m_gameState.m_unkUint13 = 0.5;
v47 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v29);
cocos2d::CCDirector::getWinSize(v47);
v48 = 60.0;
if ( a2->m_teleportEase )
v48 = 180.0;
if ( v10 )
{
m_player1->m_isOnGround2 = 0;
v28 = cocos2d::CCPoint::operator=(&m_player1->m_lastGroundedPos, &stru_1406C2450);
PlayerObject::placeStreakPoint(m_player1);
}
if ( a2->m_redirectForceEnabled )
{
*(float *)&v28 = a2->m_redirectForceMax;
PlayerObject::redirectPlayerForce(m_player1, v26, a2->m_redirectForceMod, a2->m_redirectForceMin, *(float *)&v28);
}
else if ( a2->m_staticForceEnabled )
{
m_staticForceAdditive = a2->m_staticForceAdditive;
if ( a2->m_staticForce != 0.0 || m_staticForceAdditive )
{
cocos2d::ccpForAngle((cocos2d *)&X, v26 * 0.017453292);
v50 = (float)(X.y * X.y) + (float)(X.x * X.x);
if ( v50 < 0.0 )
*(float *)&v28 = sqrtf(v50);
else
*(float *)&v28 = fsqrt(v50);
if ( *(float *)&v28 > 0.0 )
{
cocos2d::CCPoint::operator*(&X, &v77);
cocos2d::CCPoint::operator=(&X, &v77);
if ( m_player1->m_isSideways )
{
v51 = X.x;
X.x = X.y;
X.y = v51;
}
cocos2d::CCPoint::CCPoint(&v77);
m_player1->m_isAccelerating = 1;
v28 = v52[1];
if ( m_staticForceAdditive )
v28 = v28 + m_player1->m_yVelocity;
m_player1->m_yVelocity = v28;
if ( m_player1->m_isPlatformer )
{
v28 = *v52;
if ( m_staticForceAdditive )
v28 = v28 + m_player1->m_platformerXVelocity;
m_player1->m_platformerXVelocity = v28;
m_player1->m_affectedByForces = 1;
}
}
}
else
{
m_player1->m_isAccelerating = 0;
m_player1->m_yVelocity = 0.0;
if ( m_player1->m_isPlatformer )
{
m_player1->m_platformerXVelocity = 0.0;
m_player1->m_affectedByForces = 0;
}
}
}
if ( a2->m_instantCamera )
*(_WORD *)&a1->m_gameState.m_unkBool28 = 257;
if ( a2->m_snapGround )
{
m_player1->getPosition_0(m_player1);
cocos2d::CCPoint::CCPoint(&X);
v28 = cocos2d::CCPoint::operator=(&m_player1->m_lastGroundedPos, v53);
}
if ( m_player1->m_isDashing && a2->m_redirectDash )
{
cocos2d::CCPoint::CCPoint(*(float *)&v28, m_player1->m_dashX);
v54 = X.x;
y = X.y;
v56 = (float)(v26 * 0.017453292) - atan2f(X.y, X.x);
v57 = GJBaseGameLayer::convertToClosestDirection(v56, 3.1415927);
v58 = v57;
if ( v57 != 0.0 )
{
v59 = cosf(v57);
v60 = sinf(v58);
cocos2d::CCPoint::CCPoint((float)(v60 * v54) + (float)(v59 * y), (float)(v59 * v54) - (float)(v60 * y));
cocos2d::CCPoint::operator=(&X, v61);
y = X.y;
v54 = X.x;
}
v62 = (int)(float)-(float)(atan2f(y, v54) * 57.29578);
m_isSideways = m_player1->m_isSideways;
v64 = v62 - 90;
if ( !m_isSideways )
v64 = v62;
v65 = v64 % 360;
v66 = v65 + 360;
if ( v65 >= 0 )
v66 = v65;
m_player1->m_dashAngle = (double)-v66;
if ( m_isSideways )
{
v67 = v54;
v54 = y;
X.x = y;
y = v67;
X.y = v67;
}
m_player1->m_dashX = v54;
m_player1->m_dashY = y;
if ( v54 >= 0.0 )
{
if ( v54 <= 0.0 )
{
LABEL_100:
PlayerObject::updateDashArt(m_player1);
goto LABEL_101;
}
v68 = m_isSideways;
}
else
{
v68 = !m_isSideways;
}
PlayerObject::doReversePlayer(m_player1, v68);
goto LABEL_100;
}
LABEL_101:
if ( v10 )
GJBaseGameLayer::checkCameraLimitAfterTeleport(a1, m_player1, v48);
GJBaseGameLayer::gameEventTriggered(a1, Teleported, 0, 0);
}