//
// GJBaseGameLayer::getPortalTarget from 0x470db0 to 0x470e52 (162 bytes)
//
// 1 xrefs:
// > GJBaseGameLayer::teleportPlayer @ 0x49128e
//
// 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
//
TeleportPortalObject *GJBaseGameLayer::getPortalTarget(GJBaseGameLayer *a1, TeleportPortalObject *a2)
{
int m_targetGroupID; // r1
cocos2d::CCArray *Group; // r6
int v5; // r0
unsigned int v6; // r2
float v7; // s15
if ( a2->m_orangePortal )
return a2->m_orangePortal;
m_targetGroupID = a2->m_targetGroupID;
if ( m_targetGroupID <= 0 )
return nullptr;
Group = GJBaseGameLayer::getGroup(a1, m_targetGroupID);
v5 = cocos2d::CCArray::count(Group);
if ( v5 <= 0 )
return nullptr;
if ( v5 == 1 )
{
v7 = 0.0;
}
else
{
v6 = (unsigned int)(214013 * qword_AC68B8 + 2531011) >> 16;
qword_AC68B8 = 214013 * qword_AC68B8 + 2531011;
v7 = (float)(v6 & 0x7FFF) / 32767.0;
if ( v7 == 1.0 )
v7 = 0.0;
}
return (TeleportPortalObject *)cocos2d::CCArray::objectAtIndex(Group, (int)(float)((float)v5 * v7));
}