//
// PlayLayer::addObject from 0x100118854 to 0x1001193b0 (2908 bytes)
//
// 3 xrefs:
// > PlayLayer::processCreateObjectsFromSetup @ 0x100116770
// > PlayLayer::setupHasCompleted @ 0x1001171fc
// > PlayLayer::addObject @ 0x100118bfc
//
// 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
//
void __fastcall PlayLayer::addObject(PlayLayer *a1, GameObject *a2)
{
int v4; // w1
__n128 v5; // q0
int m_objectID; // w8
__int64 *v7; // x0
float v8; // s0
float TeleportXOff; // s0
TeleportPortalObject *v10; // x21
float v11; // s0
int v12; // w0
float v13; // s8
StartPosObject *m_startPosObject; // x0
int m_targetOrder; // w21
float v16; // s8
_BOOL4 v17; // w21
int v18; // w8
const char *v19; // x0
const char *v20; // x9
const char *v21; // x10
const char *v22; // x11
const char *v23; // x10
const char *v24; // x11
const char *v25; // x10
const char *v26; // x11
const char *v27; // x12
const char *v28; // x11
const char *v29; // x12
const char *BallFrame; // x0
GameObject *v31; // x21
int m_activeMainColorID; // w1
__n128 v33; // q1
__n128 v34; // q0
PlayerObject *m_player1; // x8
__int16 v36; // w9
GLubyte b; // w8
PlayerObject *v38; // x8
const char *v39; // x9
const char *v40; // x10
bool v41; // zf
GameObject *v42; // x22
__int64 *v43; // x0
float v44; // s0
int ObjectZOrder; // w0
int v46; // w8
int v47; // w21
__int64 v48; // x0
__int64 v49; // x0
float *v50; // x0
__int64 v51; // x9
int v52; // w8
int v53; // w9
cocos2d::CCPoint v54; // [xsp+0h] [xbp-50h] BYREF
cocos2d::CCPoint v55; // [xsp+8h] [xbp-48h] BYREF
cocos2d::CCPoint v56; // 0:kr08_8.8
if ( !a2 )
return;
if ( ((unsigned int (__fastcall *)(GameObject *))a2->getType)(a2) == 25 )
GameObject::determineSlopeDirection(a2);
else
GameObject::updateIsOriented(a2);
((void (__fastcall *)(GameObject *, _QWORD))a2->setVisible)(a2, 0);
((void (__fastcall *)(cocos2d::CCPoint *__return_ptr, GameObject *))a2->getStartPos)(&v55, a2);
if ( v55.x > a1->m_maxObjectX )
{
((void (__fastcall *)(cocos2d::CCPoint *__return_ptr, GameObject *, float))a2->getStartPos)(&v55, a2, v55.x);
a1->m_maxObjectX = v55.x;
}
if ( !GameObject::isSettingsObject(a2)
&& (((unsigned int (__fastcall *)(GameObject *))a2->getType)(a2) != 20
|| a2->m_classType == Effect && (LOBYTE(a2[1].m_sAdditionalTransform.b) & 1) != 0
|| a2->m_objectID == 2063) )
{
((void (__fastcall *)(PlayLayer *, GameObject *))a1->addToSection)(a1, a2);
}
else
{
a2->m_outerSectionIndex = -1;
}
sub_10024A2D0(a1->m_objects, a2);
GJBaseGameLayer::addToGroups(a1, a2, 1);
if ( a2->m_objectID == 1615 )
{
GJBaseGameLayer::addObjectCounter(a1, (LabelGameObject *)a2);
}
else if ( ((unsigned int (__fastcall *)(GameObject *))a2->getType)(a2) == 30
|| ((unsigned int (__fastcall *)(GameObject *))a2->getType)(a2) == 31 )
{
sub_10024A2D0(a1->m_collectibles, a2);
}
GameObject::getActiveColorForMode(a2, a2->m_activeMainColorID, 1);
if ( GameObject::hasSecondaryColor(a2) )
GameObject::getActiveColorForMode(a2, a2->m_activeDetailColorID, 0);
if ( a2->m_isTrigger
&& a2->m_classType == Effect
&& ((LOBYTE(a2[1].m_sAdditionalTransform.b) & 1) == 0 && BYTE1(a2[1].m_sAdditionalTransform.b) != 1
|| ((unsigned int (__fastcall *)(GameObject *))a2->isSpecialSpawnObject)(a2)) )
{
v5 = sub_10024A2D0(a1->m_spawnObjectsArray, a2);
}
if ( a1->m_isPlatformer )
a2->m_tempOffsetXRelated = 0;
m_objectID = a2->m_objectID;
if ( m_objectID == 747 )
{
v7 = (__int64 *)((__int64 (__fastcall *)(GameObject *, __n128))a2->getPosition)(a2, v5);
v8 = sub_1000229B8((__int64 *)&v55, v7);
v55.y = *(float *)(((__int64 (__fastcall *)(GameObject *, float))a2->getPosition)(a2, v8) + 4)
+ a2[1].m_sQuad.bl.texCoords.u;
TeleportXOff = TeleportPortalObject::getTeleportXOff((TeleportPortalObject *)a2, a1->m_gameLayerT1);
v55.x = TeleportXOff + v55.x;
v10 = TeleportPortalObject::create("portal_16_front_001.png", 0);
*(_QWORD *)&a2[1].m_sQuad.bl.vertices.y = v10;
v10->m_objectID = 749;
((void (__fastcall *)(TeleportPortalObject *))v10->customSetup)(v10);
v11 = sub_1000229B8((__int64 *)&v54, (__int64 *)&v55);
((void (__fastcall *)(TeleportPortalObject *, cocos2d::CCPoint *, float))v10->setStartPos)(v10, &v54, v11);
v10->m_unk40C = 1;
v10->m_zOrder = a2->m_zOrder;
v10->m_defaultZOrder = a2->m_defaultZOrder;
v12 = ((__int64 (__fastcall *)(GameObject *))a2->isFlipX)(a2);
((void (__fastcall *)(TeleportPortalObject *, _QWORD))v10->setFlipX)(v10, v12 ^ 1u);
v10->m_startFlipX = ((__int64 (__fastcall *)(GameObject *))a2->isFlipX)(a2) ^ 1;
v10->m_isDontEnter = a2->m_isDontEnter;
*(_WORD *)&v10->m_isDontFade = *(_WORD *)&a2->m_isDontFade;
v13 = ((float (__fastcall *)(GameObject *))a2->getRotation)(a2);
((void (__fastcall *)(TeleportPortalObject *))v10->setRotation)(v10);
v10->m_startRotationX = v13;
v10->m_startRotationY = v13;
GameObject::copyGroups(v10);
GameObject::updateCustomScaleX(v10, a2->m_scaleX);
GameObject::updateCustomScaleY(v10, a2->m_scaleY);
*(_QWORD *)&v10->m_mainColorKeyIndex = *(_QWORD *)&a2->m_mainColorKeyIndex;
if ( a2->m_isHide )
v10->m_isHide = 1;
((void (__fastcall *)(TeleportPortalObject *))v10->saveActiveColors)(v10);
PlayLayer::addObject(a1, v10);
m_objectID = a2->m_objectID;
}
if ( m_objectID > 285 )
{
if ( m_objectID > 1021 )
{
if ( m_objectID > 1815 )
{
if ( m_objectID <= 2063 )
{
if ( m_objectID == 1816 )
{
if ( BYTE5(a2[1].CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCRGBAProtocol::__vftable) == 1 )
sub_10024A2D0(a1->m_collisionBlocks, a2);
goto LABEL_156;
}
if ( m_objectID != 1933 )
goto LABEL_156;
}
else if ( m_objectID != 2064 && m_objectID != 2902 && m_objectID != 2926 )
{
goto LABEL_156;
}
goto LABEL_70;
}
if ( m_objectID > 1330 )
{
if ( m_objectID == 1331 )
goto LABEL_70;
if ( m_objectID != 1333 )
goto LABEL_156;
}
else if ( m_objectID != 1022 && m_objectID != 1330 )
{
goto LABEL_156;
}
LABEL_123:
GJBaseGameLayer::addGuideArt(a1, a2);
goto LABEL_156;
}
if ( m_objectID > 746 )
{
if ( (unsigned int)(m_objectID - 899) > 0x10 || ((1 << (m_objectID + 125)) & 0x10003) == 0 )
{
if ( m_objectID != 747 && m_objectID != 749 )
goto LABEL_156;
goto LABEL_70;
}
}
else
{
if ( m_objectID <= 743 )
{
if ( (unsigned int)(m_objectID - 286) >= 2 && m_objectID != 660 )
goto LABEL_156;
goto LABEL_70;
}
if ( m_objectID != 744 )
{
if ( m_objectID != 745 )
goto LABEL_156;
goto LABEL_70;
}
}
}
else
{
if ( m_objectID <= 35 )
{
if ( m_objectID > 14 )
{
if ( (unsigned int)(m_objectID - 15) < 3 )
{
BallFrame = GameObject::getBallFrame((GameObject *)(unsigned int)a1->m_pulseRodIndex, v4);
v31 = GameObject::createWithFrame(BallFrame);
v31->m_objectID = 37;
((void (__fastcall *)(GameObject *))v31->customSetup)(v31);
m_activeMainColorID = a2->m_activeMainColorID;
if ( m_activeMainColorID != 1004 )
GameObject::setMainColorMode(v31, m_activeMainColorID);
GameObject::setDefaultMainColorMode(a2, 0);
((void (__fastcall *)(GameObject *))a2->saveActiveColors)(a2);
((void (__fastcall *)(GameObject *))v31->saveActiveColors)(v31);
*(_QWORD *)&a2->m_mainColorKeyIndex = 0;
*(_QWORD *)&v31->m_mainColorKeyIndex = 0;
v33.n128_f32[0] = a2->m_obRect.size.height + 10.0;
sub_100022980((__n128)COERCE_UNSIGNED_INT(a2->m_obRect.size.width * 0.5), v33, &v54);
cocos2d::CCNode::convertToWorldSpace(a2, &v54);
v56 = cocos2d::CCNode::convertToNodeSpace(a1->m_gameBlendingLayerT1, &v55);
((void (__fastcall *)(GameObject *, cocos2d::CCPoint *, float, float))v31->setStartPos)(
v31,
&v54,
v56.x,
v56.y);
((void (__fastcall *)(GameObject *, float))v31->setScale)(v31, 0.1);
((void (__fastcall *)(PlayLayer *, GameObject *))a1->addToSection)(a1, v31);
v34 = sub_10024A2D0(a1->m_objects, v31);
((void (__fastcall *)(GameObject *, _QWORD, __n128))v31->setVisible)(v31, 0, v34);
GameObject::copyGroups(v31);
GJBaseGameLayer::addToGroups(a1, v31, 1);
goto LABEL_156;
}
if ( (unsigned int)(m_objectID - 29) >= 2 )
{
if ( m_objectID == 31 && (*(_BYTE *)(*(_QWORD *)&a2[1].m_sQuad.bl.vertices.y + 371LL) & 1) == 0 )
{
m_startPosObject = a1->m_startPosObject;
if ( m_startPosObject )
{
m_targetOrder = m_startPosObject->m_startSettings->m_targetOrder;
v16 = *(float *)((__int64 (__fastcall *)(StartPosObject *))m_startPosObject->getPosition)(m_startPosObject);
}
else
{
v16 = 0.0;
m_targetOrder = -1;
}
if ( (v50 = (float *)((__int64 (__fastcall *)(GameObject *))a2->getPosition)(a2),
v51 = *(_QWORD *)&a2[1].m_sQuad.bl.vertices.y,
v52 = *(_DWORD *)(v51 + 372),
v52 > m_targetOrder)
|| (v53 = *(unsigned __int8 *)(v51 + 370), *v50 > v16) && (v53 & 1) == 0 && v52 >= m_targetOrder
|| *v50 < v16 && v53 && v52 >= m_targetOrder )
{
GJBaseGameLayer::setStartPosObject(a1, (StartPosObject *)a2);
a1->m_isTestMode = 1;
}
}
goto LABEL_156;
}
goto LABEL_130;
}
if ( (unsigned int)(m_objectID - 10) >= 4 )
goto LABEL_156;
LABEL_70:
if ( a2->m_isHide )
goto LABEL_156;
v17 = GJBaseGameLayer::addGuideArt(a1, a2);
v18 = a2->m_objectID;
v19 = "portal_01_back_001.png";
if ( v18 <= 286 )
{
v20 = "portal_09_back_001.png";
v21 = "portal_10_back_001.png";
v22 = "portal_11_back_001.png";
if ( v18 != 286 )
v22 = "portal_01_back_001.png";
if ( v18 != 111 )
v21 = v22;
if ( v18 != 101 )
v20 = v21;
v23 = "portal_07_back_001.png";
v24 = "portal_08_back_001.png";
if ( v18 != 99 )
v24 = "portal_01_back_001.png";
if ( v18 != 47 )
v23 = v24;
if ( v18 <= 100 )
v20 = v23;
v25 = "portal_04_back_001.png";
v26 = "portal_05_back_001.png";
v27 = "portal_06_back_001.png";
if ( v18 != 46 )
v27 = "portal_01_back_001.png";
if ( v18 != 45 )
v26 = v27;
if ( v18 != 13 )
v25 = v26;
v28 = "portal_02_back_001.png";
v29 = "portal_03_back_001.png";
if ( v18 != 12 )
v29 = "portal_01_back_001.png";
if ( v18 != 11 )
v28 = v29;
if ( v18 <= 12 )
v25 = v28;
if ( v18 <= 46 )
v19 = v25;
else
v19 = v20;
goto LABEL_149;
}
if ( v18 > 1330 )
{
if ( v18 > 2063 )
{
if ( v18 == 2064 )
{
LABEL_145:
v19 = "portal_16_back_001.png";
goto LABEL_149;
}
if ( v18 != 2902 )
{
if ( v18 == 2926 )
v19 = "portal_19_back_001.png";
goto LABEL_149;
}
goto LABEL_144;
}
v39 = "portal_17_back_001.png";
v40 = "portal_18_back_001.png";
if ( v18 != 1933 )
v40 = "portal_01_back_001.png";
v41 = v18 == 1331;
}
else
{
if ( v18 > 744 )
{
if ( v18 == 745 )
{
v19 = "portal_14_back_001.png";
goto LABEL_149;
}
if ( v18 != 747 )
{
if ( v18 != 749 )
goto LABEL_149;
goto LABEL_145;
}
LABEL_144:
v19 = "portal_15_back_001.png";
goto LABEL_149;
}
v39 = "portal_12_back_001.png";
v40 = "portal_13_back_001.png";
if ( v18 != 660 )
v40 = "portal_01_back_001.png";
v41 = v18 == 287;
}
if ( v41 )
v19 = v39;
else
v19 = v40;
LABEL_149:
v42 = GameObject::createWithFrame(v19);
v42->m_objectID = 38;
((void (__fastcall *)(GameObject *, __int64))v42->setType)(v42, 7);
v42->m_isDecoration2 = 1;
((void (__fastcall *)(GameObject *))v42->customSetup)(v42);
v43 = (__int64 *)((__int64 (__fastcall *)(GameObject *))a2->getPosition)(a2);
v44 = sub_1000229B8((__int64 *)&v55, v43);
((void (__fastcall *)(GameObject *, cocos2d::CCPoint *, float))v42->setStartPos)(v42, &v55, v44);
v42->m_unk40C = 1;
v42->m_defaultZLayer = 4;
ObjectZOrder = GameObject::getObjectZOrder(a2);
if ( v17 )
v46 = -99;
else
v46 = -100;
v42->m_defaultZOrder = v46 + ObjectZOrder;
if ( v17 )
v47 = 13;
else
v47 = 12;
v48 = ((__int64 (__fastcall *)(GameObject *))a2->isFlipX)(a2);
((void (__fastcall *)(GameObject *, __int64))v42->setFlipX)(v42, v48);
v49 = ((__int64 (__fastcall *)(GameObject *))a2->isFlipY)(a2);
((void (__fastcall *)(GameObject *, __int64))v42->setFlipY)(v42, v49);
((void (__fastcall *)(GameObject *))a2->getRotationX)(a2);
((void (__fastcall *)(GameObject *))v42->setRotationX)(v42);
((void (__fastcall *)(GameObject *))a2->getRotationY)(a2);
((void (__fastcall *)(GameObject *))v42->setRotationY)(v42);
v42->m_startRotationX = a2->m_startRotationX;
v42->m_startRotationY = a2->m_startRotationY;
*(_WORD *)&v42->m_startFlipX = *(_WORD *)&a2->m_startFlipX;
GameObject::updateCustomScaleX(v42, a2->m_scaleX);
GameObject::updateCustomScaleY(v42, a2->m_scaleY);
v42->m_startScaleX = a2->m_startScaleX;
v42->m_startScaleY = a2->m_startScaleY;
v42->m_isDontEnter = a2->m_isDontEnter;
*(_WORD *)&v42->m_isDontFade = *(_WORD *)&a2->m_isDontFade;
((void (__fastcall *)(PlayLayer *, GameObject *))a1->addToSection)(a1, v42);
sub_10024A2D0(a1->m_objects, v42);
GameObject::copyGroups(v42);
GJBaseGameLayer::addToGroups(a1, v42, 1);
a2->m_unk40C = 1;
a2->m_defaultZOrder = v47;
((void (__fastcall *)(GameObject *))v42->saveActiveColors)(v42);
*(_QWORD *)&v42->m_mainColorKeyIndex = *(_QWORD *)&a2->m_mainColorKeyIndex;
goto LABEL_156;
}
if ( m_objectID <= 98 )
{
if ( (unsigned int)(m_objectID - 45) < 3 )
goto LABEL_70;
if ( m_objectID != 36 && m_objectID != 84 )
goto LABEL_156;
goto LABEL_123;
}
if ( m_objectID <= 104 )
{
if ( m_objectID != 99 && m_objectID != 101 )
goto LABEL_156;
goto LABEL_70;
}
if ( m_objectID != 105 )
{
if ( m_objectID == 111 )
goto LABEL_70;
if ( m_objectID != 141 )
goto LABEL_156;
goto LABEL_123;
}
}
LABEL_130:
if ( BYTE1(a2[1].m_sAdditionalTransform.tx) == 1 )
{
m_player1 = a1->m_player1;
v36 = *(_WORD *)&m_player1->m_playerColor1.r;
b = m_player1->m_playerColor1.b;
}
else
{
if ( BYTE2(a2[1].m_sAdditionalTransform.tx) != 1 )
goto LABEL_156;
v38 = a1->m_player1;
v36 = *(_WORD *)&v38->m_playerColor2.r;
b = v38->m_playerColor2.b;
}
BYTE2(a2[1].m_obAnchorPointInPoints.y) = b;
LOWORD(a2[1].m_obAnchorPointInPoints.y) = v36;
LABEL_156:
if ( GameObject::isSpeedObject(a2) && ((__int64)a2[1].m_pobTexture & 1) != 0
|| a2->m_classType == Effect && LOBYTE(a2[1].m_obRect.origin.y) == 1 && LOBYTE(a2[1].m_pobTexture) == 1 )
{
EffectGameObject::updateSpeedModType((EffectGameObject *)a2);
sub_10024A2D0(a1->m_speedObjects, a2);
}
}