//
// LevelEditorLayer::rotationForSlopeNearObject from 0x1000e0af0 to 0x1000e0c6e (382 bytes)
//
// 3 xrefs:
// > EditorUI::getSnapAngle @ 0x10004a855
// > EditorUI::getSnapAngle @ 0x10004a890
// > EditorUI::transformObject @ 0x10004bb71
//
// 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)
{
cocos2d::CCArray *v2; // r15
float result; // xmm0_4
unsigned int v4; // r12d
GameObject *v5; // r14
int v6; // eax
int v7; // r15d
unsigned int v8; // r15d
unsigned int v9; // eax
_BYTE v10[16]; // [rsp+0h] [rbp-40h] BYREF
_BYTE v11[48]; // [rsp+10h] [rbp-30h] BYREF
cocos2d::CCRect v12; // 0:xmm0_8.8,8:xmm1_8.8
GameObject::updateStartPos(a2);
v12.size = (cocos2d::CCSize)1065353216LL;
((void (__fastcall *)(_BYTE *, GameObject *, float, float))a2->getObjectRect_0)(v10, a2, 1.0, 1.0);
*(double *)&v12.origin = sub_10028D180(v11);
v2 = LevelEditorLayer::objectsInRect(a1, v12, (bool)v11);
result = -1.0;
if ( (unsigned int)sub_100720070(v2) )
{
v4 = 0;
while ( 1 )
{
v5 = (GameObject *)sub_1007200C0(v2, v4);
if ( ((unsigned int (__fastcall *)(GameObject *, double))v5->getType)(v5, COERCE_DOUBLE(3212836864LL)) == 25 )
break;
if ( ++v4 >= (unsigned int)sub_100720070(v2) )
return -1.0;
}
GameObject::determineSlopeDirection(v5);
v6 = (int)(float)(GameObject::getSlopeAngle(v5) * 57.29578);
v7 = -v6;
if ( !v5->m_slopeUphill )
v7 = v6;
if ( GameObject::slopeFloorTop(v5) && !((unsigned __int8 (__fastcall *)(GameObject *))a2->isFlipY)(a2)
|| !GameObject::slopeFloorTop(v5) && ((unsigned __int8 (__fastcall *)(GameObject *))a2->isFlipY)(a2) )
{
if ( v7 <= 0 )
{
v9 = 180 - v7;
v8 = 360 * ((180 - v7) / 0x168u);
}
else
{
v8 = v7 + 180;
v9 = 360 * (v8 / 0x168);
}
return (float)(int)(v8 - v9);
}
return (float)v7;
}
return result;
}