//
// LevelEditorLayer::addSpecial from 0x670488 to 0x6709b4 (1324 bytes)
//
// 8 xrefs:
// > LevelEditorLayer::addObjectFromVector @ 0x670a30
// > LevelEditorLayer::createObject @ 0x671f38
// > LevelEditorLayer::handleAction @ 0x6726d8
// > LevelEditorLayer::handleAction @ 0x6727c8
// > LevelEditorLayer::refreshSpecial @ 0x672a90
// > EditorUI::createNewKeyframeAnim @ 0x6bf1c8
// > EditorUI::onCreateObject @ 0x6c01ac
// > ??> @ 0x52038
//
// 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)
{
int m_objectID; // w21
bool v5; // cc
int v6; // w0
float *v7; // x21
LevelSettingsObject *m_levelSettings; // x0
const cocos2d::CCPoint *v9; // x0
float u; // s0
int v11; // w21
GameObject *Object; // x23
void (__fastcall *setFlipX)(GameObject *__hidden, bool); // x24
bool v14; // w0
void (__fastcall *update)(GameObject *__hidden, float); // x24
int v16; // w1
void (__fastcall *encodeWithCoder)(cocos2d::CCObject *__hidden, DS_Dictionary *); // x24
unsigned int GroupID; // w0
int v19; // w21
float v20; // s0
int v21; // w21
float v22; // s0
cocos2d::CCPoint v23; // [xsp+58h] [xbp+58h] BYREF
cocos2d::CCPoint v24; // [xsp+60h] [xbp+60h] BYREF
cocos2d::CCPoint v25; // 0:s0.4,4:s1.4
GJBaseGameLayer::applyLevelSettings(a1, a2);
if ( a2->m_isStartPos )
{
LevelEditorLayer::updateObjectLabel(a2);
m_objectID = a2->m_objectID;
v5 = m_objectID <= 1329;
if ( m_objectID != 1329 )
goto LABEL_3;
LABEL_40:
v21 = a1->m_coinCount.random - a1->m_coinCount.seed + 1;
a1->m_coinCount.value = v21;
v22 = (float)((float)rand() * 4.6566e-10) * 1000.0;
a1->m_coinCount.seed = (int)v22;
a1->m_coinCount.random = v21 + (int)v22;
m_objectID = a2->m_objectID;
goto LABEL_7;
}
v19 = a1->m_objectCount.random - a1->m_objectCount.seed + 1;
a1->m_objectCount.value = v19;
v20 = (float)((float)rand() * 4.6566e-10) * 1000.0;
a1->m_objectCount.seed = (int)v20;
a1->m_objectCount.random = v19 + (int)v20;
LevelEditorLayer::updateObjectLabel(a2);
m_objectID = a2->m_objectID;
v5 = m_objectID <= 1329;
if ( m_objectID == 1329 )
goto LABEL_40;
LABEL_3:
if ( v5 )
{
if ( m_objectID == 747 )
{
v9 = a2->getPosition(a2);
cocos2d::CCPoint::CCPoint(&v23, v9);
u = a2[1].m_sQuad.bl.texCoords.u;
if ( u == 0.0 )
u = 100.0;
v11 = 0;
v23.y = v23.y + u;
v23.x = v23.x - 10.0;
cocos2d::CCPoint::CCPoint(&v24, &v23);
Object = LevelEditorLayer::createObject(a1, 749, v25, (bool)&v24);
setFlipX = Object->setFlipX;
v14 = a2->isFlipX(a2);
setFlipX(Object, !v14);
update = Object->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable[1].update;
a2->getRotation(a2);
((void (__fastcall *)(GameObject *))update)(Object);
GameObject::copyGroups(Object);
if ( a2->m_groupCount > 0 )
{
do
{
v16 = v11++;
encodeWithCoder = Object->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable[1].encodeWithCoder;
GroupID = GameObject::getGroupID(a2, v16);
encodeWithCoder(Object, (DS_Dictionary *)GroupID);
}
while ( a2->m_groupCount > v11 );
}
*(_QWORD *)&a2[1].m_sQuad.bl.vertices.y = Object;
m_objectID = a2->m_objectID;
Object[1].m_sQuad.bl.colors.r = 1;
}
LABEL_7:
if ( m_objectID != 1049 )
goto LABEL_8;
goto LABEL_24;
}
if ( m_objectID != 2065 )
{
if ( m_objectID == 3032 )
{
cocos2d::CCArray::addObject(a1->m_keyframeObjects, a2);
a1->addKeyframe(a1, (KeyframeGameObject *)a2);
m_objectID = a2->m_objectID;
}
goto LABEL_7;
}
LevelEditorLayer::updatePreviewParticle(a1, (ParticleGameObject *)a2);
cocos2d::CCArray::addObject(a1->m_particleObjects, a2);
if ( a2->m_objectID != 1049 )
{
LABEL_8:
if ( !a2->m_isTrigger )
goto LABEL_9;
goto LABEL_25;
}
LABEL_24:
EffectGameObject::updateSpecialColor((EffectGameObject *)a2);
if ( !a2->m_isTrigger )
{
LABEL_9:
if ( a2->getType(a2) != Slope )
goto LABEL_10;
LABEL_26:
GameObject::determineSlopeDirection(a2);
if ( a2->m_classType != Effect )
goto LABEL_11;
goto LABEL_27;
}
LABEL_25:
DrawGridLayer::addToEffects(a1->m_drawGridLayer, (EffectGameObject *)a2);
if ( a2->getType(a2) == Slope )
goto LABEL_26;
LABEL_10:
if ( a2->m_classType != Effect )
goto LABEL_11;
LABEL_27:
LevelEditorLayer::tryUpdateSpeedObject(a1, (EffectGameObject *)a2, 0);
LABEL_11:
v6 = a2->m_objectID;
if ( v6 == 1814 )
goto LABEL_58;
if ( v6 > 1814 )
{
if ( v6 == 2067 )
goto LABEL_58;
if ( v6 <= 2067 )
{
if ( v6 != 1912 )
{
if ( v6 == 2016 )
{
v7 = &a1->m_varianceValues.__elems_[1975];
cocos2d::CCArray::addObject(a1->m_cameraGuideTriggers, a2);
goto LABEL_44;
}
goto LABEL_52;
}
}
else
{
if ( v6 == 3016 )
goto LABEL_58;
if ( v6 == 3642 )
{
v7 = &a1->m_varianceValues.__elems_[1975];
DrawGridLayer::addAudioLineObject(a1->m_drawGridLayer, (AudioLineGuideGameObject *)a2);
goto LABEL_44;
}
if ( v6 != 2068 )
goto LABEL_52;
}
goto LABEL_54;
}
if ( v6 == 1007 )
{
v7 = &a1->m_varianceValues.__elems_[1975];
cocos2d::CCArray::addObject(a1->m_alphaTriggers, a2);
a1->m_alphaTriggersChanged = 1;
goto LABEL_44;
}
if ( v6 <= 1007 )
{
if ( v6 != 901 )
{
if ( v6 == 1006 )
{
v7 = &a1->m_varianceValues.__elems_[1975];
cocos2d::CCArray::addObject(a1->m_pulseTriggers, a2);
a1->m_pulseTriggersChanged = 1;
if ( a2->m_isSpawnOrderTrigger )
goto LABEL_18;
LABEL_45:
if ( a2->m_activateTriggerInEditor )
goto LABEL_46;
goto LABEL_19;
}
goto LABEL_52;
}
LABEL_58:
v7 = &a1->m_varianceValues.__elems_[1975];
cocos2d::CCArray::addObject(a1->m_moveTriggers, a2);
goto LABEL_44;
}
if ( v6 == 1268 )
{
LABEL_54:
v7 = &a1->m_varianceValues.__elems_[1975];
cocos2d::CCArray::addObject(a1->m_spawnTriggers, a2);
a1->m_spawnTriggersChanged = 1;
goto LABEL_44;
}
if ( v6 >= 1268 && (unsigned int)(v6 - 1346) <= 1 )
goto LABEL_58;
LABEL_52:
v7 = &a1->m_varianceValues.__elems_[1975];
if ( GameObject::isColorTrigger(a2) )
{
cocos2d::CCArray::addObject(a1->m_colorTriggers, a2);
a1->m_colorTriggersChanged = 1;
}
LABEL_44:
if ( !a2->m_isSpawnOrderTrigger )
goto LABEL_45;
LABEL_18:
cocos2d::CCArray::addObject(a1->m_spawnOrderObjects, a2);
*((_BYTE *)v7 + 2112) = 1;
if ( a2->m_activateTriggerInEditor )
goto LABEL_46;
LABEL_19:
if ( !a2->isSpecialSpawnObject(a2) )
{
if ( a2->m_dontIgnoreDuration )
goto LABEL_21;
goto LABEL_47;
}
LABEL_46:
cocos2d::CCArray::addObject(a1->m_playtestTriggers, a2);
if ( a2->m_dontIgnoreDuration )
{
LABEL_21:
cocos2d::CCArray::addObject(a1->m_durationObjects, a2);
m_levelSettings = a1->m_levelSettings;
if ( !m_levelSettings )
goto LABEL_22;
goto LABEL_48;
}
LABEL_47:
m_levelSettings = a1->m_levelSettings;
if ( !m_levelSettings )
goto LABEL_22;
LABEL_48:
if ( m_levelSettings->m_platformerMode )
{
a2->m_tempOffsetXRelated = 0;
goto LABEL_50;
}
LABEL_22:
a2->m_tempOffsetXRelated = GameObject::shouldLockX(a2);
LABEL_50:
cocos2d::CCArray::addObject(a1->m_objects, a2);
GJBaseGameLayer::addToGroups(a1, a2, 0);
GJBaseGameLayer::addToGroupParents(a1, a2);
GJBaseGameLayer::reAddToStickyGroup(a1, a2);
*((_BYTE *)v7 + 2826) = 1;
}