//
// LevelEditorLayer::rotationForSlopeNearObject from 0x10035a740 to 0x10035a8d0 (400 bytes)
//
// 3 xrefs:
// > EditorUI::getSnapAngle @ 0x1003f62c8
// > EditorUI::getSnapAngle @ 0x1003f6308
// > EditorUI::transformObject @ 0x1003f7188
//
// 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 __fastcall LevelEditorLayer::rotationForSlopeNearObject(LevelEditorLayer *a1, GameObject *a2)
{
double v4; // d0
cocos2d::CCArray *v5; // x21
float v6; // s8
unsigned int v7; // w22
GameObject *v8; // x20
int v9; // w8
signed int v10; // w21
float v12; // s1
float v13; // s2
float v14; // s3
_QWORD v15[2]; // [xsp+0h] [xbp-50h] BYREF
_QWORD v16[2]; // [xsp+10h] [xbp-40h] BYREF
cocos2d::CCRect v17; // 0:kr00_16.16
GameObject::updateStartPos(a2);
((void (__fastcall *)(_QWORD *__return_ptr, GameObject *, float, float))a2->getObjectRect_0)(v16, a2, 1.0, 1.0);
v4 = sub_100022B98(v15, (__int64)v16);
v17.origin.x = *(float *)&v4;
v17.origin.y = v12;
v17.size.width = v13;
v17.size.height = v14;
v5 = LevelEditorLayer::objectsInRect(a1, v17, (bool)v15);
v6 = -1.0;
if ( (unsigned int)sub_10024A36C((__int64)v5) )
{
v7 = 0;
while ( 1 )
{
v8 = (GameObject *)sub_10024A388((__int64)v5, v7);
if ( ((unsigned int (__fastcall *)(GameObject *))v8->getType)(v8) == 25 )
break;
if ( ++v7 >= (unsigned int)sub_10024A36C((__int64)v5) )
return v6;
}
GameObject::determineSlopeDirection(v8);
v9 = (int)(float)(GameObject::getSlopeAngle(v8) * 57.296);
if ( v8->m_slopeUphill )
v10 = -v9;
else
v10 = v9;
if ( GameObject::slopeFloorTop(v8) && !((unsigned int (__fastcall *)(GameObject *))a2->isFlipY)(a2)
|| !GameObject::slopeFloorTop(v8) && ((unsigned int (__fastcall *)(GameObject *))a2->isFlipY)(a2) )
{
if ( v10 < 1 )
return (float)(signed int)(v10 - 180 + 360 * ((180 - v10) / 0x168u));
else
return (float)((v10 + 180) % 0x168u);
}
return (float)v10;
}
return v6;
}