//
// PlayLayer::addObject from 0x310cf8 to 0x3115c4 (2252 bytes)
//
// 3 xrefs:
// > PlayLayer::addObject @ 0x310fae
// > PlayLayer::setupHasCompleted @ 0x31c2c8
// > PlayLayer::processCreateObjectsFromSetup @ 0x31c898
//
// 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 PlayLayer::addObject(PlayLayer *a1, GameObject *a2)
{
int v4; // r1
const cocos2d::CCPoint *v5; // r0
const cocos2d::CCPoint *v6; // r0
cocos2d::CCSpriteBatchNode *m_gameLayerT1; // r1
float TeleportXOff; // r0
TeleportPortalObject *v9; // r0
GameObject *v10; // r5
void (__fastcall *setStartPos)(GameObject *__hidden, cocos2d::CCPoint); // r10
int m_zOrder; // r3
void (__fastcall *setFlipX)(GameObject *__hidden, bool); // r9
bool v14; // r0
int v15; // r9
int m_objectID; // r5
bool v17; // zf
bool v18; // zf
int v19; // r3
PlayerObject *m_player1; // r3
GLubyte r; // r1
GLubyte g; // r2
GLubyte b; // r3
PlayerObject *v24; // r3
const char *BallFrame; // r0
GameObject *v26; // r0
GameObject *v27; // r5
int m_activeMainColorID; // r1
float width; // s13
float height; // s14
void (__fastcall *v31)(GameObject *__hidden, cocos2d::CCPoint); // r11
_BOOL4 v32; // r0
int v33; // r5
_BOOL4 v34; // r9
const char *v35; // r0
GameObject *v36; // r0
GameObject *v37; // r5
GameObject_vtbl *v38; // r3
void (__fastcall *v39)(GameObject *__hidden, cocos2d::CCPoint); // r11
const cocos2d::CCPoint *v40; // r0
int ObjectZOrder; // r0
void (__fastcall *v42)(GameObject *__hidden, bool); // r7
bool (__fastcall *isFlipX)(GameObject *__hidden); // r3
int v44; // r0
void (__fastcall *setFlipY)(GameObject *__hidden, bool); // r7
int v46; // r0
void (__fastcall *setRotationX)(GameObject *__hidden, float); // r7
int v48; // r0
void (__fastcall *setRotationY)(GameObject *__hidden, float); // r7
int v50; // r0
float m_scaleX; // r1
GameObject_vtbl *v52; // r3
StartPosObject *m_startPosObject; // r0
int m_targetOrder; // r5
float x; // s16
const cocos2d::CCPoint *v56; // r0
float m_fTlVertexMod; // r2
int v58; // r3
int v59; // r2
float v60; // s15
cocos2d::CCPoint v61; // [sp+4h] [bp-18h] BYREF
cocos2d::CCPoint v62; // [sp+Ch] [bp-10h] BYREF
if ( !a2 )
return;
if ( a2->getType(a2) == Slope )
GameObject::determineSlopeDirection(a2);
else
GameObject::updateIsOriented(a2);
a2->setVisible(a2, 0);
a2->getStartPos(&v62, a2);
if ( v62.x > a1->m_maxObjectX )
{
a2->getStartPos(&v62, a2);
a1->m_maxObjectX = v62.x;
}
if ( !GameObject::isSettingsObject(a2)
&& (a2->getType(a2) != Modifier
|| a2->m_classType == Effect && LOBYTE(a2[1].m_sAdditionalTransform.d)
|| a2->m_objectID == 2063) )
{
a1->addToSection(a1, a2);
}
else
{
a2->m_outerSectionIndex = -1;
}
cocos2d::CCArray::addObject(a1->m_objects, a2);
GJBaseGameLayer::addToGroups(a1, a2, 1);
if ( a2->m_objectID == 1615 )
{
GJBaseGameLayer::addObjectCounter(a1, (LabelGameObject *)a2);
}
else if ( a2->getType(a2) == Collectible || a2->getType(a2) == (Collectible|0x1) )
{
cocos2d::CCArray::addObject(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.d) && !BYTE1(a2[1].m_sAdditionalTransform.d)
|| ((int (__fastcall *)(GameObject *))a2->isSpecialSpawnObject)(a2)) )
{
cocos2d::CCArray::addObject(a1->m_spawnObjectsArray, a2);
}
if ( a1->m_isPlatformer )
a2->m_tempOffsetXRelated = 0;
if ( a2->m_objectID == 747 )
{
v5 = a2->getPosition(a2);
cocos2d::CCPoint::CCPoint(&v61, v5);
v6 = a2->getPosition(a2);
m_gameLayerT1 = a1->m_gameLayerT1;
v61.y = v6->y + a2[1].m_fBrVertexMod;
TeleportXOff = TeleportPortalObject::getTeleportXOff((TeleportPortalObject *)a2, m_gameLayerT1);
v61.x = v61.x + TeleportXOff;
v9 = TeleportPortalObject::create("portal_16_front_001.png", 0);
LODWORD(a2[1].m_fTrVertexMod) = v9;
v10 = v9;
v9->m_objectID = 749;
v9->customSetup(v9);
setStartPos = v10->setStartPos;
cocos2d::CCPoint::CCPoint(&v62, &v61);
((void (__fastcall *)(GameObject *, cocos2d::CCPoint *))setStartPos)(v10, &v62);
m_zOrder = a2->m_zOrder;
v10->m_unk40C = 1;
v10->m_zOrder = m_zOrder;
v10->m_defaultZOrder = a2->m_defaultZOrder;
setFlipX = v10->setFlipX;
v14 = a2->isFlipX(a2);
setFlipX(v10, !v14);
v10->m_startFlipX = ((int (__fastcall *)(GameObject *))a2->isFlipX)(a2) ^ 1;
v10->m_isDontEnter = a2->m_isDontEnter;
v10->m_isDontFade = a2->m_isDontFade;
v10->m_hasNoEffects = a2->m_hasNoEffects;
v15 = ((int (__fastcall *)(GameObject *))a2->getRotation)(a2);
((void (__fastcall *)(GameObject *, int))v10->setRotation)(v10, v15);
LODWORD(v10->m_startRotationX) = v15;
LODWORD(v10->m_startRotationY) = v15;
GameObject::copyGroups(v10);
GameObject::updateCustomScaleX(v10, a2->m_scaleX);
GameObject::updateCustomScaleY(v10, a2->m_scaleY);
v10->m_mainColorKeyIndex = a2->m_mainColorKeyIndex;
v10->m_detailColorKeyIndex = a2->m_detailColorKeyIndex;
if ( a2->m_isHide )
v10->m_isHide = 1;
v10->saveActiveColors(v10);
PlayLayer::addObject(a1, v10);
}
m_objectID = a2->m_objectID;
if ( m_objectID >= 288 )
{
if ( m_objectID == 1022 )
goto LABEL_151;
if ( m_objectID > 1022 )
{
if ( m_objectID == 1816 )
{
if ( BYTE1(a2[1].m_sBlendFunc.dst) )
cocos2d::CCArray::addObject(a1->m_collisionBlocks, a2);
goto LABEL_152;
}
if ( m_objectID <= 1816 )
{
if ( m_objectID == 1331 )
goto LABEL_88;
if ( m_objectID == 1333 )
goto LABEL_151;
v17 = m_objectID == 1330;
goto LABEL_52;
}
if ( m_objectID == 2064 )
goto LABEL_88;
if ( m_objectID > 2064 )
{
if ( m_objectID == 2902 )
goto LABEL_88;
v19 = 2926;
}
else
{
v19 = 1933;
}
}
else
{
if ( m_objectID == 747 )
goto LABEL_88;
if ( m_objectID < 748 )
{
if ( m_objectID != 744 )
{
if ( m_objectID == 745 )
goto LABEL_88;
v18 = m_objectID == 660;
goto LABEL_77;
}
goto LABEL_80;
}
if ( m_objectID > 900 )
{
if ( m_objectID != 915 )
goto LABEL_152;
goto LABEL_80;
}
if ( m_objectID >= 899 )
{
LABEL_80:
if ( BYTE1(a2[1].m_sTransform.a) )
{
m_player1 = a1->m_player1;
r = m_player1->m_playerColor1.r;
g = m_player1->m_playerColor1.g;
b = m_player1->m_playerColor1.b;
}
else
{
if ( !BYTE2(a2[1].m_sTransform.a) )
goto LABEL_152;
v24 = a1->m_player1;
r = v24->m_playerColor2.r;
g = v24->m_playerColor2.g;
b = v24->m_playerColor2.b;
}
LOBYTE(a2[1].m_obAnchorPoint.y) = r;
BYTE1(a2[1].m_obAnchorPoint.y) = g;
BYTE2(a2[1].m_obAnchorPoint.y) = b;
goto LABEL_152;
}
v19 = 749;
}
v18 = m_objectID == v19;
goto LABEL_77;
}
if ( m_objectID >= 286 )
goto LABEL_88;
if ( m_objectID == 36 )
goto LABEL_151;
if ( m_objectID > 36 )
{
if ( m_objectID == 99 )
goto LABEL_88;
if ( m_objectID <= 99 )
{
if ( m_objectID < 45 )
goto LABEL_152;
if ( m_objectID <= 47 )
{
LABEL_88:
if ( a2->m_isHide )
goto LABEL_152;
v32 = GJBaseGameLayer::addGuideArt(a1, a2);
v33 = a2->m_objectID;
v34 = v32;
if ( v33 == 286 )
{
v35 = "portal_11_back_001.png";
goto LABEL_136;
}
if ( v33 <= 286 )
{
if ( v33 == 46 )
{
v35 = "portal_06_back_001.png";
goto LABEL_136;
}
if ( v33 > 46 )
{
if ( v33 == 99 )
{
v35 = "portal_08_back_001.png";
goto LABEL_136;
}
if ( v33 > 99 )
{
if ( v33 == 101 )
{
v35 = "portal_09_back_001.png";
goto LABEL_136;
}
if ( v33 == 111 )
{
v35 = "portal_10_back_001.png";
goto LABEL_136;
}
}
else if ( v33 == 47 )
{
v35 = "portal_07_back_001.png";
goto LABEL_136;
}
}
else
{
if ( v33 == 12 )
{
v35 = "portal_03_back_001.png";
goto LABEL_136;
}
if ( v33 > 12 )
{
if ( v33 == 13 )
{
v35 = "portal_04_back_001.png";
goto LABEL_136;
}
if ( v33 == 45 )
{
v35 = "portal_05_back_001.png";
goto LABEL_136;
}
}
else if ( v33 == 11 )
{
v35 = "portal_02_back_001.png";
LABEL_136:
v36 = GameObject::createWithFrame(v35);
v36->m_objectID = 38;
v37 = v36;
v36->setType(v36, Decoration);
v38 = v37->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v37->m_isDecoration2 = 1;
v38->customSetup(v37);
v39 = v37->setStartPos;
v40 = a2->getPosition(a2);
cocos2d::CCPoint::CCPoint(&v62, v40);
((void (__fastcall *)(GameObject *, cocos2d::CCPoint *))v39)(v37, &v62);
v37->m_unk40C = 1;
v37->m_defaultZLayer = 4;
ObjectZOrder = GameObject::getObjectZOrder(a2);
v42 = v37->setFlipX;
isFlipX = a2->isFlipX;
v37->m_defaultZOrder = ObjectZOrder - 100 + v34;
v44 = ((int (__fastcall *)(GameObject *))isFlipX)(a2);
v42(v37, v44);
setFlipY = v37->setFlipY;
v46 = ((int (__fastcall *)(GameObject *))a2->isFlipY)(a2);
setFlipY(v37, v46);
setRotationX = v37->setRotationX;
v48 = ((int (__fastcall *)(GameObject *))a2->getRotationX)(a2);
((void (__fastcall *)(GameObject *, int))setRotationX)(v37, v48);
setRotationY = v37->setRotationY;
v50 = ((int (__fastcall *)(GameObject *))a2->getRotationY)(a2);
((void (__fastcall *)(GameObject *, int))setRotationY)(v37, v50);
v37->m_startRotationX = a2->m_startRotationX;
v37->m_startRotationY = a2->m_startRotationY;
m_scaleX = a2->m_scaleX;
v37->m_startFlipX = a2->m_startFlipX;
v37->m_startFlipY = a2->m_startFlipY;
GameObject::updateCustomScaleX(v37, m_scaleX);
GameObject::updateCustomScaleY(v37, a2->m_scaleY);
v37->m_startScaleX = a2->m_startScaleX;
v37->m_startScaleY = a2->m_startScaleY;
v37->m_isDontEnter = a2->m_isDontEnter;
v37->m_isDontFade = a2->m_isDontFade;
v37->m_hasNoEffects = a2->m_hasNoEffects;
a1->addToSection(a1, v37);
cocos2d::CCArray::addObject(a1->m_objects, v37);
GameObject::copyGroups(v37);
GJBaseGameLayer::addToGroups(a1, v37, 1);
a2->m_defaultZOrder = v34 + 12;
v52 = v37->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a2->m_unk40C = 1;
v52->saveActiveColors(v37);
v37->m_mainColorKeyIndex = a2->m_mainColorKeyIndex;
v37->m_detailColorKeyIndex = a2->m_detailColorKeyIndex;
goto LABEL_152;
}
}
LABEL_135:
v35 = "portal_01_back_001.png";
goto LABEL_136;
}
if ( v33 != 749 )
{
if ( v33 <= 749 )
{
if ( v33 == 660 )
{
v35 = "portal_13_back_001.png";
goto LABEL_136;
}
if ( v33 <= 660 )
{
if ( v33 == 287 )
{
v35 = "portal_12_back_001.png";
goto LABEL_136;
}
goto LABEL_135;
}
if ( v33 == 745 )
{
v35 = "portal_14_back_001.png";
goto LABEL_136;
}
if ( v33 != 747 )
goto LABEL_135;
LABEL_132:
v35 = "portal_15_back_001.png";
goto LABEL_136;
}
if ( v33 != 2064 )
{
if ( v33 <= 2064 )
{
if ( v33 == 1331 )
{
v35 = "portal_17_back_001.png";
goto LABEL_136;
}
if ( v33 == 1933 )
{
v35 = "portal_18_back_001.png";
goto LABEL_136;
}
goto LABEL_135;
}
if ( v33 != 2902 )
{
if ( v33 == 2926 )
{
v35 = "portal_19_back_001.png";
goto LABEL_136;
}
goto LABEL_135;
}
goto LABEL_132;
}
}
v35 = "portal_16_back_001.png";
goto LABEL_136;
}
v17 = m_objectID == 84;
LABEL_52:
if ( !v17 )
goto LABEL_152;
LABEL_151:
GJBaseGameLayer::addGuideArt(a1, a2);
goto LABEL_152;
}
if ( m_objectID != 105 )
{
if ( m_objectID > 105 )
{
if ( m_objectID == 111 )
goto LABEL_88;
v17 = m_objectID == 141;
goto LABEL_52;
}
v18 = m_objectID == 101;
LABEL_77:
if ( v18 )
goto LABEL_88;
goto LABEL_152;
}
goto LABEL_80;
}
if ( m_objectID > 17 )
{
if ( m_objectID < 29 )
goto LABEL_152;
if ( m_objectID > 30 )
{
if ( m_objectID != 31 || *(_BYTE *)(LODWORD(a2[1].m_fTlVertexMod) + 311) )
goto LABEL_152;
m_startPosObject = a1->m_startPosObject;
if ( m_startPosObject )
{
m_targetOrder = m_startPosObject->m_startSettings->m_targetOrder;
x = m_startPosObject->getPosition(m_startPosObject)->x;
}
else
{
x = 0.0;
m_targetOrder = -1;
}
v56 = a2->getPosition(a2);
m_fTlVertexMod = a2[1].m_fTlVertexMod;
v58 = *(_DWORD *)(LODWORD(m_fTlVertexMod) + 312);
v59 = *(unsigned __int8 *)(LODWORD(m_fTlVertexMod) + 310);
v60 = v56->x;
if ( v58 > m_targetOrder )
goto LABEL_161;
if ( v60 <= x )
{
if ( v60 >= x || !v59 )
goto LABEL_152;
}
else if ( v59 && v60 >= x )
{
goto LABEL_152;
}
if ( v58 >= m_targetOrder )
{
LABEL_161:
GJBaseGameLayer::setStartPosObject(a1, (StartPosObject *)a2);
a1->m_isTestMode = 1;
}
goto LABEL_152;
}
goto LABEL_80;
}
if ( m_objectID >= 15 )
{
BallFrame = GameObject::getBallFrame((GameObject *)a1->m_pulseRodIndex, v4);
v26 = GameObject::createWithFrame(BallFrame);
v26->m_objectID = 37;
v27 = v26;
v26->customSetup(v26);
m_activeMainColorID = a2->m_activeMainColorID;
if ( m_activeMainColorID != 1004 )
GameObject::setMainColorMode(v27, m_activeMainColorID);
GameObject::setDefaultMainColorMode(a2, 0);
a2->saveActiveColors(a2);
v27->saveActiveColors(v27);
width = a2->m_obRect.size.width;
a2->m_mainColorKeyIndex = 0;
a2->m_detailColorKeyIndex = 0;
height = a2->m_obRect.size.height;
v27->m_mainColorKeyIndex = 0;
v27->m_detailColorKeyIndex = 0;
cocos2d::CCPoint::CCPoint(&v62, width * 0.5, height + 10.0);
cocos2d::CCNode::convertToWorldSpace(&v61, a2, &v62);
v31 = v27->setStartPos;
cocos2d::CCNode::convertToNodeSpace(&v62, a1->m_gameBlendingLayerT1, &v61);
((void (__fastcall *)(GameObject *, cocos2d::CCPoint *))v31)(v27, &v62);
((void (__fastcall *)(GameObject *, int))v27->setScale)(v27, 1036831949);
a1->addToSection(a1, v27);
cocos2d::CCArray::addObject(a1->m_objects, v27);
v27->setVisible(v27, 0);
GameObject::copyGroups(v27);
GJBaseGameLayer::addToGroups(a1, v27, 1);
goto LABEL_152;
}
if ( (unsigned int)(m_objectID - 10) <= 3 )
goto LABEL_88;
LABEL_152:
if ( GameObject::isSpeedObject(a2) && LOBYTE(a2[1].m_sQuad.bl.texCoords.v)
|| a2->m_classType == Effect && LOBYTE(a2[1].m_sQuad.tr.vertices.z) && LOBYTE(a2[1].m_sQuad.bl.texCoords.v) )
{
EffectGameObject::updateSpeedModType((EffectGameObject *)a2);
cocos2d::CCArray::addObject(a1->m_speedObjects, a2);
}
}