//
// LevelEditorLayer::rotationForSlopeNearObject from 0x1000b02f0 to 0x1000b046e (382 bytes)
//
// 3 xrefs:
// > EditorUI::getSnapAngle @ 0x10060f0d5
// > EditorUI::getSnapAngle @ 0x10060f110
// > EditorUI::transformObject @ 0x10060faf1
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:20:19 +0000
//
float __fastcall LevelEditorLayer::rotationForSlopeNearObject(__int64 a1, __int64 a2)
{
__int64 v2; // r15
float result; // xmm0_4
unsigned int v4; // r12d
_BYTE *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
GameObject::updateStartPos(a2);
(*(void (__fastcall **)(_BYTE *, __int64, float, float))(*(_QWORD *)a2 + 1336LL))(v10, a2, 1.0, 1.0);
sub_1002787F0(v11, v10);
v2 = LevelEditorLayer::objectsInRect(a1, v11, 1);
result = -1.0;
if ( (unsigned int)sub_1007FEF90(v2) )
{
v4 = 0;
while ( 1 )
{
v5 = (_BYTE *)sub_1007FEFE0(v2, v4);
if ( (*(unsigned int (__fastcall **)(_BYTE *, double))(*(_QWORD *)v5 + 1800LL))(v5, COERCE_DOUBLE(3212836864LL)) == 25 )
break;
if ( ++v4 >= (unsigned int)sub_1007FEF90(v2) )
return -1.0;
}
GameObject::determineSlopeDirection(v5);
v6 = (int)(float)(GameObject::getSlopeAngle(v5) * 57.29578);
v7 = -v6;
if ( !v5[1080] )
v7 = v6;
if ( (unsigned __int8)GameObject::slopeFloorTop(v5)
&& !(*(unsigned __int8 (__fastcall **)(__int64))(*(_QWORD *)a2 + 1432LL))(a2)
|| !(unsigned __int8)GameObject::slopeFloorTop(v5)
&& (*(unsigned __int8 (__fastcall **)(__int64))(*(_QWORD *)a2 + 1432LL))(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;
}