//
// LevelEditorLayer::rotationForSlopeNearObject from 0x1402d4ec0 to 0x1402d5047 (391 bytes)
//
// 6 xrefs:
// > EditorUI::transformObjectCall_1 @ 0x1401202b9
// > EditorUI::transformObjectCall_1 @ 0x1401202e8
// > EditorUI::transformObjectCall_1 @ 0x140120585
// > EditorUI::transformObjectCall_1 @ 0x140120600
// > EditorUI::transformObject @ 0x140120a3d
// > ??> @ 0x1406d2fc0
//
// 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
//
float LevelEditorLayer::rotationForSlopeNearObject(LevelEditorLayer *a1, GameObject *a2)
{
cocos2d::CCRect *v4; // rax
cocos2d::CCArray *v5; // rsi
unsigned int v6; // ebx
GameObject *v7; // rdi
const struct cocos2d::CCRect *v9; // rax
int v10; // esi
int v11; // eax
int v12; // ebx
unsigned int m_slopeDirection; // eax
unsigned int v14; // eax
int v15; // ebx
cocos2d::CCRect v16; // [rsp+20h] [rbp-28h] BYREF
struct cocos2d::CCRect v17; // [rsp+30h] [rbp-18h] BYREF
GameObject::updateStartPos(a2);
((void (__fastcall *)(GameObject *, struct cocos2d::CCRect *))a2->getObjectRect)(a2, &v17);
v4 = (cocos2d::CCRect *)cocos2d::CCRect::CCRect(&v16, &v17);
v5 = LevelEditorLayer::objectsInRect(a1, v4, 1);
v6 = 0;
if ( !cocos2d::CCArray::count(v5) )
return -1.0;
while ( 1 )
{
v7 = (GameObject *)cocos2d::CCArray::objectAtIndex(v5, v6);
if ( v7->getType(v7) == Slope )
break;
if ( ++v6 >= cocos2d::CCArray::count(v5) )
return -1.0;
}
GameObject::determineSlopeDirection(v7);
v9 = v7->getObjectRect_0(v7);
cocos2d::CCRect::CCRect(&v16, v9);
v10 = 106;
v11 = (int)(float)(atanf(v16.size.height / v16.size.width) * 57.29578);
v12 = -v11;
if ( !v7->m_slopeUphill )
v12 = v11;
m_slopeDirection = v7->m_slopeDirection;
if ( m_slopeDirection <= 6 && _bittest(&v10, m_slopeDirection) && !a2->isFlipY(a2)
|| ((v14 = v7->m_slopeDirection, v14 > 6) || !_bittest(&v10, v14)) && a2->isFlipY(a2) )
{
if ( v12 <= 0 )
v15 = v12 - 180;
else
v15 = v12 + 180;
return (float)(v15 % 360);
}
return (float)v12;
}