//
// LevelEditorLayer::addSpecial from 0x1402d7bc0 to 0x1402d830e (1870 bytes)
//
// 12 xrefs:
// > EditorUI::onCreateObject @ 0x14010fa74
// > EditorUI::createNewKeyframeAnim @ 0x1401195c4
// > EditorUI::createLoop @ 0x140119929
// > EditorUI::createLoop @ 0x140119c38
// > LevelEditorLayer::createObjectsFromSetup @ 0x1402d3e3b
// > LevelEditorLayer::createObjectsFromString @ 0x1402d453b
// > LevelEditorLayer::createObject @ 0x1402d4902
// > LevelEditorLayer::handleAction @ 0x1402d6614
// > LevelEditorLayer::handleAction @ 0x1402d6764
// > ??> @ 0x14068e4b4
// > ??> @ 0x14068e510
// > ??> @ 0x1406d3110
//
// 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 LevelEditorLayer::addSpecial(LevelEditorLayer *a1, GameObject *a2)
{
GameObjectType m_objectType; // eax
int v5; // ecx
bool v6; // al
bool v7; // zf
int v8; // ebx
float v9; // xmm0_4
int m_objectID; // eax
std::_List_unchecked_const_iterator>>, std::_Iterator_base0>::_Nodeptr v11; // rbp
int v12; // ebx
float v13; // xmm0_4
float z; // xmm1_4
float v15; // xmm0_4
cocos2d::CCPoint v16; // rax
GameObject *Object; // r14
GameObject_vtbl *v18; // rbx
_BOOL8 v19; // rdx
GameObject_vtbl *v20; // rbx
int v21; // r12d
__int64 v22; // r15
unsigned __int64 v23; // rbx
std::array *m_groups; // rax
__int64 v25; // rdx
int m_groupCount; // ecx
int v27; // r12d
__int64 v28; // r15
unsigned __int64 v29; // rbx
std::array *v30; // rax
__int64 v31; // rdx
DrawGridLayer *m_drawGridLayer; // rbx
int v33; // ecx
cocos2d::CCArray *m_moveTriggers; // rcx
LevelSettingsObject *m_levelSettings; // rax
bool v36; // al
int v37; // ecx
int v38; // ecx
int v39; // ecx
int v40; // ecx
std::unordered_map *p_m_audioLineObjects; // rcx
cocos2d::CCArray *v42; // rax
cocos2d::CCArray *v43; // r15
unsigned int v44; // ebx
int v45; // r14d
unsigned int m_uniqueID; // r8d
std::_Vector_val>>>>>::pointer Myfirst; // rdx
std::_List_unchecked_const_iterator>>, std::_Iterator_base0>::_Nodeptr Ptr; // rax
int v49; // ebx
cocos2d::CCArray *v50; // rax
_BYTE v51[16]; // [rsp+20h] [rbp-38h] BYREF
cocos2d::CCPoint v52; // [rsp+60h] [rbp+8h] BYREF
cocos2d::CCPoint v53; // [rsp+68h] [rbp+10h] BYREF
v6 = a1->m_allowStaticRotate
|| (m_objectType = a2->m_objectType, (unsigned int)m_objectType > Slope)
|| (v5 = 35651585, !_bittest(&v5, m_objectType))
|| a2->m_isNoTouch;
a2->m_canRotateFree = v6;
if ( a2->m_isMirroredByScale != a1->m_fixNegativeScale )
a2->m_isObjectRectDirty = 1;
v7 = !a2->m_isStartPos;
a2->m_isMirroredByScale = a1->m_fixNegativeScale;
if ( v7 )
{
v8 = a1->m_objectCount.random - a1->m_objectCount.seed + 1;
a1->m_objectCount.value = v8;
v9 = (float)((float)rand() / 32767.0) * 1000.0;
a1->m_objectCount.seed = (int)v9;
a1->m_objectCount.random = v8 + (int)v9;
}
LevelEditorLayer::updateObjectLabel(a2);
m_objectID = a2->m_objectID;
v11 = nullptr;
switch ( m_objectID )
{
case 747:
a2->getPosition_0(a2);
cocos2d::CCPoint::CCPoint(&v52);
z = a2[1].m_sQuad.tr.vertices.z;
if ( z == 0.0 )
v15 = v52.y + 100.0;
else
v15 = v52.y + z;
v52.y = v15;
v52.x = v52.x + -10.0;
cocos2d::CCPoint::CCPoint(&v53);
Object = LevelEditorLayer::createObject(a1, 749, v16, 1);
v18 = Object->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
LOBYTE(v19) = !a2->isFlipX(a2);
v18->setFlipX(Object, v19);
v20 = Object->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a2->getRotation(a2);
((void (__fastcall *)(GameObject *))v20[1].encodeWithCoder)(Object);
if ( a2->m_groupCount > 0 )
{
v21 = 0;
v22 = 0;
v23 = 0;
do
{
if ( v23 <= 9 && (m_groups = a2->m_groups) != nullptr )
v25 = (unsigned int)m_groups->_Elems[v22];
else
v25 = 0;
Object->addToGroup(Object, v25);
m_groupCount = a2->m_groupCount;
++v21;
++v23;
++v22;
}
while ( v21 < m_groupCount );
if ( (__int16)m_groupCount > 0 )
{
v27 = 0;
v28 = 0;
v29 = 0;
do
{
if ( v29 <= 9 && (v30 = a2->m_groups) != nullptr )
v31 = (unsigned int)v30->_Elems[v28];
else
v31 = 0;
((void (__fastcall *)(GameObject *, __int64))Object->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable[1].canEncode)(
Object,
v31);
++v27;
++v29;
++v28;
}
while ( v27 < a2->m_groupCount );
}
}
*(_QWORD *)&a2[1].m_sQuad.bl.texCoords.v = Object;
LOBYTE(Object[1].m_sQuad.tr.vertices.y) = 1;
break;
case 1329:
v12 = a1->m_coinCount.random - a1->m_coinCount.seed + 1;
a1->m_coinCount.value = v12;
v13 = (float)((float)rand() / 32767.0) * 1000.0;
a1->m_coinCount.seed = (int)v13;
a1->m_coinCount.random = v12 + (int)v13;
break;
case 2065:
LevelEditorLayer::updatePreviewParticle(a1, (ParticleGameObject *)a2);
cocos2d::CCArray::addObject(a1->m_particleObjects, a2);
break;
case 3032:
cocos2d::CCArray::addObject(a1->m_keyframeObjects, a2);
a1->addKeyframe(a1, (KeyframeGameObject *)a2);
break;
}
if ( a2->m_objectID == 1049 )
EffectGameObject::updateSpecialColor((EffectGameObject *)a2);
if ( a2->m_isTrigger )
{
m_drawGridLayer = a1->m_drawGridLayer;
if ( !cocos2d::CCArray::containsObject(m_drawGridLayer->m_effectGameObjects, a2) )
{
cocos2d::CCArray::addObject(m_drawGridLayer->m_effectGameObjects, a2);
m_drawGridLayer->m_sortEffects = 1;
}
}
if ( a2->getType(a2) == Slope )
GameObject::determineSlopeDirection(a2);
if ( a2->m_classType == Effect )
LevelEditorLayer::tryUpdateSpeedObject(a1, (EffectGameObject *)a2, 0);
v33 = a2->m_objectID;
if ( v33 <= 1814 )
{
if ( v33 != 1814 )
{
if ( v33 <= 1268 )
{
if ( v33 != 1268 )
{
if ( v33 != 901 )
{
if ( v33 == 1006 )
{
cocos2d::CCArray::addObject(a1->m_pulseTriggers, a2);
a1->m_pulseTriggersChanged = 1;
goto LABEL_57;
}
if ( v33 == 1007 )
{
cocos2d::CCArray::addObject(a1->m_alphaTriggers, a2);
a1->m_alphaTriggersChanged = 1;
goto LABEL_57;
}
goto LABEL_77;
}
goto LABEL_55;
}
LABEL_74:
cocos2d::CCArray::addObject(a1->m_spawnTriggers, a2);
a1->m_spawnTriggersChanged = 1;
goto LABEL_57;
}
if ( v33 != 1346 && v33 != 1347 )
goto LABEL_77;
}
LABEL_55:
m_moveTriggers = a1->m_moveTriggers;
LABEL_56:
cocos2d::CCArray::addObject(m_moveTriggers, a2);
goto LABEL_57;
}
if ( v33 <= 2068 )
{
if ( v33 == 2068 || v33 == 1912 )
goto LABEL_74;
if ( v33 == 2016 )
{
m_moveTriggers = a1->m_cameraGuideTriggers;
goto LABEL_56;
}
if ( v33 != 2067 )
goto LABEL_77;
goto LABEL_55;
}
if ( v33 == 3016 )
goto LABEL_55;
if ( v33 == 3642 )
{
p_m_audioLineObjects = &a1->m_drawGridLayer->m_audioLineObjects;
LODWORD(v52.x) = a2->m_uniqueID;
*(_QWORD *)(*(_QWORD *)sub_1402F0BB0(p_m_audioLineObjects, v51, &v52) + 24LL) = a2;
goto LABEL_57;
}
LABEL_77:
if ( v33 <= 744 )
{
if ( v33 != 744 )
{
v37 = v33 - 29;
if ( v37 )
{
v38 = v37 - 1;
if ( v38 )
{
if ( v38 != 75 )
goto LABEL_57;
}
}
}
LABEL_86:
cocos2d::CCArray::addObject(a1->m_colorTriggers, a2);
a1->m_colorTriggersChanged = 1;
goto LABEL_57;
}
v39 = v33 - 899;
if ( !v39 )
goto LABEL_86;
v40 = v39 - 1;
if ( !v40 || v40 == 15 )
goto LABEL_86;
LABEL_57:
if ( a2->m_isSpawnOrderTrigger )
{
cocos2d::CCArray::addObject(a1->m_spawnOrderObjects, a2);
a1->m_spawnOrderObjectsChanged = 1;
}
if ( a2->m_activateTriggerInEditor || a2->isSpecialSpawnObject(a2) )
cocos2d::CCArray::addObject(a1->m_playtestTriggers, a2);
if ( a2->m_dontIgnoreDuration )
cocos2d::CCArray::addObject(a1->m_durationObjects, a2);
m_levelSettings = a1->m_levelSettings;
v36 = (!m_levelSettings || !m_levelSettings->m_platformerMode) && GameObject::shouldLockX(a2);
a2->m_tempOffsetXRelated = v36;
cocos2d::CCArray::addObject(a1->m_objects, a2);
GJBaseGameLayer::addToGroups(a1, a2, 0);
if ( a2->m_hasGroupParentsString )
{
v42 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(
a1->m_removedParentGroupIDs,
(unsigned int)a2->m_uniqueID);
v43 = v42;
if ( v42 )
{
a2->m_hasGroupParentsString = 0;
v44 = 0;
if ( cocos2d::CCArray::count(v42) )
{
do
{
v45 = (int)cocos2d::CCArray::objectAtIndex(v43, v44)[1].__vftable;
if ( !cocos2d::CCDictionary::objectForKey(a1->m_parentGroupsDict, v45) )
GJBaseGameLayer::setGroupParent(a1, a2, v45);
++v44;
}
while ( v44 < cocos2d::CCArray::count(v43) );
}
cocos2d::CCDictionary::removeObjectForKey(a1->m_removedParentGroupIDs, (unsigned int)a2->m_uniqueID);
}
}
m_uniqueID = a2->m_uniqueID;
Myfirst = a1->m_stickyGroups._Vec._Mypair._Myval2._Myfirst;
Ptr = Myfirst[2
* ((0x100000001B3LL
* (((unsigned __int64)m_uniqueID >> 24)
^ (0x100000001B3LL
* (BYTE2(m_uniqueID)
^ (0x100000001B3LL
* ((0x100000001B3LL * ((unsigned __int8)m_uniqueID ^ 0xCBF29CE484222325uLL)) ^ BYTE1(m_uniqueID)))))))
& a1->m_stickyGroups._Mask)
+ 1]._Ptr;
if ( Ptr != a1->m_stickyGroups._List._Mypair._Myval2._Myhead )
{
if ( m_uniqueID == *((_DWORD *)Ptr + 4) )
{
LABEL_100:
v11 = Ptr;
}
else
{
while ( Ptr != Myfirst[2
* ((0x100000001B3LL
* (((unsigned __int64)(unsigned int)a2->m_uniqueID >> 24)
^ (0x100000001B3LL
* ((unsigned __int8)BYTE2(a2->m_uniqueID)
^ (0x100000001B3LL
* ((0x100000001B3LL * ((unsigned __int8)m_uniqueID ^ 0xCBF29CE484222325uLL))
^ (unsigned __int8)BYTE1(a2->m_uniqueID)))))))
& a1->m_stickyGroups._Mask)]._Ptr )
{
Ptr = *((std::_List_unchecked_const_iterator>>, std::_Iterator_base0>::_Nodeptr *)Ptr
+ 1);
if ( m_uniqueID == *((_DWORD *)Ptr + 4) )
goto LABEL_100;
}
}
}
if ( v11 )
{
if ( !a2->m_linkedGroup )
{
LODWORD(v52.x) = a2->m_uniqueID;
v49 = *(_DWORD *)(*(_QWORD *)sub_1401795B0(
&a1->m_stickyGroups._Traitsobj._Mypair._Myval2._Myval2,
(__int64)v51,
(unsigned __int8 *)&v52)
+ 20LL);
v50 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(a1->m_linkedGroupDict, v49);
if ( v50 )
{
cocos2d::CCArray::addObject(v50, a2);
LODWORD(v52.x) = a2->m_uniqueID;
a2->m_linkedGroup = v49;
sub_14005D780(&a1->m_stickyGroups._Traitsobj._Mypair._Myval2._Myval2, (unsigned __int8 *)&v52);
}
}
}
a1->m_unk3b22 = 1;
}