//
// EditorUI::convertKeyBasedOnNeighbors from 0x536460 to 0x536762 (770 bytes)
//
// 2 xrefs:
// > EditorUI::processSmartObjectsFromType @ 0x37e308
// > EditorUI::processSmartObjectsFromType @ 0x37e398
//
// 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
//
int EditorUI::convertKeyBasedOnNeighbors(EditorUI *a1, int a2, int a3, cocos2d::CCPoint a4, cocos2d::CCArray *a5)
{
float x; // r11
int v8; // r4
cocos2d::CCPoint v9; // r2
cocos2d::CCPoint v10; // r2
_BOOL4 v11; // r6
cocos2d::CCPoint v12; // r2
_BOOL4 v13; // r5
cocos2d::CCPoint v14; // r2
_BOOL4 v15; // r7
int result; // r0
int v17; // r2
float v18; // r0
_BOOL4 v19; // r2
cocos2d::CCArray *v20; // [sp+4h] [bp-10h]
cocos2d::CCArray *v21; // [sp+4h] [bp-10h]
cocos2d::CCArray *v22; // [sp+4h] [bp-10h]
cocos2d::CCArray *v23; // [sp+4h] [bp-10h]
_BOOL4 v24; // [sp+Ch] [bp-8h]
cocos2d::CCPoint v25; // [sp+14h] [bp+0h] BYREF
x = a4.x;
v8 = EditorUI::convertToBaseKey(a1, a2);
cocos2d::CCPoint::CCPoint(&v25, (const cocos2d::CCPoint *)LODWORD(x));
LODWORD(v9.x) = &v25;
LODWORD(v9.y) = 1;
v24 = EditorUI::getNeighbor(a1, a3, v9, SLODWORD(a4.y), v20) != nullptr;
cocos2d::CCPoint::CCPoint(&v25, (const cocos2d::CCPoint *)LODWORD(x));
LODWORD(v10.x) = &v25;
LODWORD(v10.y) = 2;
v11 = EditorUI::getNeighbor(a1, a3, v10, SLODWORD(a4.y), v21) != nullptr;
cocos2d::CCPoint::CCPoint(&v25, (const cocos2d::CCPoint *)LODWORD(x));
LODWORD(v12.x) = &v25;
LODWORD(v12.y) = 3;
v13 = EditorUI::getNeighbor(a1, a3, v12, SLODWORD(a4.y), v22) != nullptr;
cocos2d::CCPoint::CCPoint(&v25, (const cocos2d::CCPoint *)LODWORD(x));
LODWORD(v14.x) = &v25;
LODWORD(v14.y) = 4;
v15 = EditorUI::getNeighbor(a1, a3, v14, SLODWORD(a4.y), v23) != nullptr;
if ( v8 == 2838 )
{
if ( v24 )
{
if ( v11 )
return v8;
result = 2846;
}
else
{
result = 2842;
}
goto LABEL_100;
}
if ( v8 > 2838 )
{
if ( v8 != 2840 )
{
if ( v8 < 2840 )
{
if ( v24 && v11 || v15 )
{
return 2839;
}
else if ( v24 )
{
result = 2847;
if ( v11 )
return 2839;
}
else
{
return 2843;
}
}
else
{
if ( v8 != 2841 || v24 && v11 )
return v8;
if ( v15 )
{
return 2841;
}
else if ( v24 )
{
result = 2849;
if ( v11 )
return 2841;
}
else
{
return 2845;
}
}
return result;
}
if ( v24 )
{
if ( !v11 )
{
if ( v13 )
return 2840;
else
return 2848;
}
return v8;
}
result = 2844;
LABEL_100:
if ( v13 )
return v8;
return result;
}
if ( v8 == 2703 )
{
if ( v24 )
{
if ( v11 )
{
if ( v13 )
{
result = 2811;
if ( v15 )
return 2703;
return result;
}
result = 2812;
v17 = 2810;
}
else
{
if ( !v13 )
{
result = 2819;
if ( v15 )
return 2816;
return result;
}
result = 2817;
v17 = 2809;
}
}
else if ( v11 )
{
if ( v13 )
{
result = 2815;
v17 = 2808;
}
else
{
result = 2818;
v17 = 2814;
}
}
else if ( v13 )
{
result = 2821;
v17 = 2813;
}
else
{
result = 2822;
v17 = 2820;
}
LABEL_49:
if ( v15 )
return v17;
return result;
}
if ( v8 == 2704 )
{
if ( v24 )
{
if ( v11 )
{
if ( v13 )
{
result = 2826;
if ( v15 )
return 2704;
return result;
}
result = 2827;
v17 = 2825;
}
else
{
if ( v13 )
{
result = 2824;
if ( !v15 )
return 2832;
return result;
}
result = 2834;
v17 = 2831;
}
}
else if ( v11 )
{
if ( v13 )
{
result = 2830;
v17 = 2823;
}
else
{
result = 2833;
v17 = 2829;
}
}
else if ( v13 )
{
result = 2836;
v17 = 2828;
}
else
{
result = 2837;
v17 = 2835;
}
goto LABEL_49;
}
if ( v8 != 869 )
return v8;
v18 = (float)sub_535B50();
v19 = (float)(v18 / 32767.0) > 0.5;
if ( v24 )
{
if ( v11 )
{
if ( v13 )
{
if ( v15 )
return v8;
goto LABEL_88;
}
goto LABEL_84;
}
goto LABEL_83;
}
if ( v11 )
{
LABEL_83:
if ( !v13 )
{
LABEL_84:
result = 1266;
if ( v19 )
return 871;
return result;
}
goto LABEL_87;
}
if ( !v13 )
{
if ( !v15 )
{
if ( (float)(v18 / 32767.0) <= 0.5 )
return 868;
else
return 867;
}
goto LABEL_84;
}
LABEL_87:
if ( !v15 )
{
LABEL_88:
if ( (float)(v18 / 32767.0) <= 0.5 )
return 1267;
else
return 872;
}
result = 870;
if ( v19 )
return 869;
return result;
}