//
// PlayerObject::updateShipRotation from 0x140390c40 to 0x14039101e (990 bytes)
//
// 4 xrefs:
// > PlayerObject::updateRotation_1 @ 0x1403911d1
// > ??> @ 0x140697834
// > ??> @ 0x140697868
// > ??> @ 0x1406d6134
//
// 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 PlayerObject::updateShipRotation(PlayerObject *a1, float a2)
{
float v4; // xmm4_4
bool v5; // bl
float v6; // xmm1_4
float v7; // xmm3_4
float v8; // xmm6_4
double v9; // xmm0_8
bool m_isBird; // al
float v11; // xmm5_4
float v12; // xmm2_4
float v13; // xmm0_4
int v14; // edx
int v15; // ecx
float v16; // xmm4_4
PlayerObject_vtbl *v17; // rbx
cocos2d::CCPoint v18; // [rsp+70h] [rbp+8h] BYREF
if ( !a1->m_isOnSlope && !a1->m_isDashing )
{
((void (*)(void))a1->getPosition_0)();
cocos2d::CCPoint::CCPoint(&v18);
v4 = a2 * 1.2;
v5 = *(_WORD *)&a1->m_isShip || a1->m_isSwing || a1->m_isDart;
if ( a1->m_isSideways )
{
v6 = v5 && a1->m_isGoingLeft ? fabs(v18.y - a1->m_shipRotation.y) : v18.y - a1->m_shipRotation.y;
v7 = v18.x - a1->m_shipRotation.x;
}
else
{
v6 = v5 && a1->m_isGoingLeft ? fabs(v18.x - a1->m_shipRotation.x) : v18.x - a1->m_shipRotation.x;
v7 = -(float)(v18.y - a1->m_shipRotation.y);
}
if ( (float)((float)((float)(v6 - 0.0) * (float)(v6 - 0.0)) + (float)((float)(v7 - 0.0) * (float)(v7 - 0.0))) >= v4
|| a1->m_isPlatformer && (a1->m_isShip || a1->m_isBird) )
{
v8 = atan2f(v7, v6);
v9 = ((double (__fastcall *)(PlayerObject *))a1->getRotation)(a1);
m_isBird = a1->m_isBird;
v11 = *(float *)&v9 * 0.017453292;
if ( m_isBird )
v8 = v8 * -0.40000001;
v12 = 0.15000001;
if ( a1->m_isCollidingWithSlope && (a1->m_isShip || m_isBird || a1->m_isDart || a1->m_isSwing) )
v8 = 0.0;
if ( v5 && a1->m_isGoingLeft )
v8 = v8 * -1.0;
if ( m_isBird )
{
v12 = 0.07;
if ( a1->m_isGoingLeft == a1->m_isUpsideDown )
v13 = fmaxf(-0.1, v8);
else
v13 = fminf(0.1, v8);
v8 = v13;
if ( a1->m_isPlatformer && (fabs(a1->m_platformerXVelocity) <= 0.5 || a1->m_isOnGround2) )
v8 = 0.0;
}
else if ( a1->m_isDart )
{
if ( a1->m_vehicleSize == 1.0 )
v12 = 0.25;
else
v12 = 0.40000001;
}
else if ( a1->m_isPlatformer && a1->m_isShip )
{
if ( a1->m_holdingLeft || a1->m_holdingRight || a1->m_platformerMovingLeft || a1->m_platformerMovingRight )
{
v14 = -1;
v15 = -1;
v12 = 0.07;
if ( a1->m_isUpsideDown == a1->m_isSideways )
v15 = 1;
if ( !a1->m_isGoingLeft )
v14 = 1;
v16 = (float)v15 * (float)v14;
v8 = v16 * 0.52359879;
if ( (float)(fabs(v16 * 0.52359879) - fabs(*(float *)&v9 * 0.017453292)) < 0.1 )
{
v12 = 0.015;
v8 = v16 * 0.78539819;
}
}
else
{
v12 = 0.059999999;
v8 = 0.0;
}
}
if ( a1->m_isCollidingWithSlope && (a1->m_isShip || a1->m_isBird || a1->m_isDart || a1->m_isSwing) )
v12 = v12 * 0.25;
v17 = a1->GameObject::CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
sub_140071EF0(v11, v8, fminf(a2, v12 * a2));
((void (__fastcall *)(PlayerObject *))v17->setRotation)(a1);
}
}
}