//
// LevelEditorLayer::addSpecial from 0x370a14 to 0x370d9a (902 bytes)
//
// 7 xrefs:
// > LevelEditorLayer::addObjectFromVector @ 0x370dfc
// > LevelEditorLayer::createObject @ 0x371490
// > LevelEditorLayer::handleAction @ 0x3716fc
// > LevelEditorLayer::handleAction @ 0x3717e8
// > LevelEditorLayer::refreshSpecial @ 0x3719ca
// > EditorUI::createNewKeyframeAnim @ 0x3a3604
// > EditorUI::onCreateObject @ 0x3a3d4a
//
// 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; // r3
int v5; // r6
int v6; // s15
const cocos2d::CCPoint *v7; // r0
float m_fBrVertexMod; // s14
cocos2d::CCPoint v9; // r2
GameObject *Object; // r6
void (__fastcall *setFlipX)(GameObject *__hidden, bool); // r8
bool v12; // r0
void (__fastcall *update)(GameObject *__hidden, float); // r8
int v14; // r0
int v15; // r8
int v16; // r1
void (__fastcall *encodeWithCoder)(cocos2d::CCObject *__hidden, DS_Dictionary *); // r9
int GroupID; // r0
int v19; // r3
int v20; // r3
int v21; // r3
LevelSettingsObject *m_levelSettings; // r3
bool v23; // [sp+0h] [bp-1Ch]
cocos2d::CCPoint v24; // [sp+4h] [bp-18h] BYREF
cocos2d::CCPoint v25; // [sp+Ch] [bp-10h] BYREF
GJBaseGameLayer::applyLevelSettings(a1, a2);
if ( !a2->m_isStartPos )
LevelEditorLayer::setObjectCount(a1, a1->m_objectCount.random - a1->m_objectCount.seed + 1);
LevelEditorLayer::updateObjectLabel(a2);
m_objectID = a2->m_objectID;
if ( m_objectID == 1329 )
{
v5 = a1->m_coinCount.random - a1->m_coinCount.seed + 1;
a1->m_coinCount.value = v5;
v6 = (int)(float)(vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0);
a1->m_coinCount.seed = v6;
a1->m_coinCount.random = v6 + v5;
}
else if ( m_objectID > 1329 )
{
if ( m_objectID == 2065 )
{
LevelEditorLayer::updatePreviewParticle(a1, (ParticleGameObject *)a2);
cocos2d::CCArray::addObject(a1->m_particleObjects, a2);
}
else if ( m_objectID == 3032 )
{
cocos2d::CCArray::addObject(a1->m_keyframeObjects, a2);
a1->addKeyframe(a1, (KeyframeGameObject *)a2);
}
}
else if ( m_objectID == 747 )
{
v7 = a2->getPosition(a2);
cocos2d::CCPoint::CCPoint(&v24, v7);
m_fBrVertexMod = a2[1].m_fBrVertexMod;
if ( m_fBrVertexMod == 0.0 )
m_fBrVertexMod = 100.0;
v24.y = v24.y + m_fBrVertexMod;
v24.x = v24.x - 10.0;
cocos2d::CCPoint::CCPoint(&v25, &v24);
LODWORD(v9.x) = &v25;
LODWORD(v9.y) = 1;
Object = LevelEditorLayer::createObject(a1, 749, v9, v23);
setFlipX = Object->setFlipX;
v12 = a2->isFlipX(a2);
setFlipX(Object, !v12);
update = Object->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable[1].update;
v14 = ((int (__fastcall *)(GameObject *))a2->getRotation)(a2);
((void (__fastcall *)(GameObject *, int))update)(Object, v14);
GameObject::copyGroups(Object);
if ( a2->m_groupCount > 0 )
{
v15 = 0;
while ( v15 < a2->m_groupCount )
{
v16 = v15++;
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);
}
}
LODWORD(a2[1].m_fTrVertexMod) = Object;
LOBYTE(Object[1].m_fBlVertexMod) = 1;
}
if ( a2->m_objectID == 1049 )
EffectGameObject::updateSpecialColor((EffectGameObject *)a2);
if ( a2->m_isTrigger )
DrawGridLayer::addToEffects(a1->m_drawGridLayer, (EffectGameObject *)a2);
if ( a2->getType(a2) == Slope )
GameObject::determineSlopeDirection(a2);
if ( a2->m_classType == Effect )
LevelEditorLayer::tryUpdateSpeedObject(a1, (EffectGameObject *)a2, 0);
v19 = a2->m_objectID;
if ( v19 == 1814 )
goto LABEL_47;
if ( v19 > 1814 )
{
if ( v19 == 2067 )
goto LABEL_47;
if ( v19 > 2067 )
{
if ( v19 == 3016 )
goto LABEL_47;
if ( v19 == 3642 )
{
DrawGridLayer::addAudioLineObject(a1->m_drawGridLayer, (AudioLineGuideGameObject *)a2);
goto LABEL_55;
}
if ( v19 != 2068 )
goto LABEL_52;
}
else if ( v19 != 1912 )
{
if ( v19 != 2016 )
goto LABEL_52;
v21 = 11816;
LABEL_50:
cocos2d::CCArray::addObject(
*(cocos2d::CCArray **)((char *)&a1->GJBaseGameLayer::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable
+ v21),
a2);
goto LABEL_55;
}
LABEL_49:
cocos2d::CCArray::addObject(a1->m_spawnTriggers, a2);
v20 = 11872;
goto LABEL_54;
}
if ( v19 == 1007 )
{
cocos2d::CCArray::addObject(a1->m_alphaTriggers, a2);
v20 = 11871;
goto LABEL_54;
}
if ( v19 >= 1008 )
{
if ( v19 != 1268 )
{
if ( v19 < 1268 || (unsigned int)(v19 - 1346) > 1 )
goto LABEL_52;
goto LABEL_47;
}
goto LABEL_49;
}
if ( v19 == 901 )
{
LABEL_47:
v21 = 11812;
goto LABEL_50;
}
if ( v19 == 1006 )
{
cocos2d::CCArray::addObject(a1->m_pulseTriggers, a2);
v20 = 11870;
goto LABEL_54;
}
LABEL_52:
if ( !GameObject::isColorTrigger(a2) )
goto LABEL_55;
cocos2d::CCArray::addObject(a1->m_colorTriggers, a2);
v20 = 11869;
LABEL_54:
*((_BYTE *)&a1->GJBaseGameLayer::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable
+ v20) = 1;
LABEL_55:
if ( a2->m_isSpawnOrderTrigger )
{
cocos2d::CCArray::addObject(a1->m_spawnOrderObjects, a2);
a1->m_spawnOrderObjectsChanged = 1;
}
if ( a2->m_activateTriggerInEditor || ((int (__fastcall *)(GameObject *))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;
a2->m_tempOffsetXRelated = (!m_levelSettings || !m_levelSettings->m_platformerMode) && GameObject::shouldLockX(a2);
cocos2d::CCArray::addObject(a1->m_objects, a2);
GJBaseGameLayer::addToGroups(a1, a2, 0);
GJBaseGameLayer::addToGroupParents(a1, a2);
GJBaseGameLayer::reAddToStickyGroup(a1, a2);
a1->m_unk3b22 = 1;
}