//
// LevelEditorLayer::addSpecial from 0x1000dfce0 to 0x1000e02d0 (1520 bytes)
//
// 9 xrefs:
// > EditorUI::onCreateObject @ 0x1000351b6
// > EditorUI::createNewKeyframeAnim @ 0x1000456a2
// > LevelEditorLayer::createObjectsFromSetup @ 0x1000dd253
// > LevelEditorLayer::addObjectFromVector @ 0x1000df353
// > LevelEditorLayer::createObjectsFromString @ 0x1000df8ee
// > LevelEditorLayer::createObject @ 0x1000e04d2
// > LevelEditorLayer::handleAction @ 0x1000e2e3b
// > LevelEditorLayer::handleAction @ 0x1000e2ea8
// > LevelEditorLayer::refreshSpecial @ 0x1000ea8ec
//
// 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 LevelEditorLayer::addSpecial(LevelEditorLayer *a1, GameObject *a2)
{
int v3; // r15d
float v4; // xmm0_4
int m_objectID; // eax
int v6; // r15d
float v7; // xmm0_4
int v8; // eax
float v9; // xmm0_4
__m128 u_low; // xmm0
__m128 v11; // xmm1
GameObject *Object; // r15
unsigned __int8 v13; // al
int v14; // r12d
unsigned int GroupID; // eax
int v16; // ecx
DrawGridLayer *m_drawGridLayer; // r15
int v18; // eax
cocos2d::CCArray *m_cameraGuideTriggers; // rdi
std::unordered_map *p_m_audioLineObjects; // rdi
LevelSettingsObject *m_levelSettings; // rax
bool shouldLockX; // al
int m_uniqueID; // [rsp+8h] [rbp-38h] BYREF
int *p_m_uniqueID; // [rsp+10h] [rbp-30h] BYREF
_BYTE v25[33]; // [rsp+1Fh] [rbp-21h] BYREF
GJBaseGameLayer::applyLevelSettings(a1, a2);
if ( !a2->m_isStartPos )
{
v3 = a1->m_objectCount.random - a1->m_objectCount.seed;
a1->m_objectCount.value = v3 + 1;
v4 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
a1->m_objectCount.seed = (int)v4;
a1->m_objectCount.random = v3 + (int)v4 + 1;
}
LevelEditorLayer::updateObjectLabel(a2);
m_objectID = a2->m_objectID;
if ( m_objectID <= 2064 )
{
if ( m_objectID == 747 )
{
((void (__fastcall *)(GameObject *))a2->getPosition)(a2);
sub_10028CC60(&p_m_uniqueID);
u_low = (__m128)LODWORD(a2[1].m_sQuad.bl.texCoords.u);
v11 = _mm_cmpneq_ss((__m128)0LL, u_low);
_mm_storel_ps(
(double *)&p_m_uniqueID,
_mm_add_ps(
_mm_insert_ps(
(__m128)xmmword_1008164C0,
_mm_or_ps(_mm_andnot_ps(v11, (__m128)0x42C80000u), _mm_and_ps(u_low, v11)),
16),
(__m128)(unsigned __int64)p_m_uniqueID));
*(double *)u_low.i64 = sub_10028CC60(&m_uniqueID);
Object = LevelEditorLayer::createObject(a1, 749, *(cocos2d::CCPoint *)u_low.f32, (bool)&m_uniqueID);
v13 = ((__int64 (__fastcall *)(GameObject *))a2->isFlipX)(a2);
((void (__fastcall *)(GameObject *, _QWORD))Object->setFlipX)(Object, v13 ^ 1u);
((void (__fastcall *)(GameObject *))a2->getRotation)(a2);
((void (__fastcall *)(GameObject *))Object->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable[1].update)(Object);
GameObject::copyGroups(Object);
if ( a2->m_groupCount > 0 )
{
v14 = 0;
do
{
GroupID = GameObject::getGroupID(a2, v14);
((void (__fastcall *)(GameObject *, _QWORD))Object->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable[1].encodeWithCoder)(
Object,
GroupID);
++v14;
}
while ( v14 < a2->m_groupCount );
}
*(_QWORD *)&a2[1].m_sQuad.bl.vertices.y = Object;
Object[1].m_sQuad.bl.colors.r = 1;
}
else
{
if ( m_objectID != 1329 )
goto LABEL_25;
v6 = a1->m_coinCount.random - a1->m_coinCount.seed;
a1->m_coinCount.value = v6 + 1;
v7 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
a1->m_coinCount.seed = (int)v7;
a1->m_coinCount.random = v6 + (int)v7 + 1;
}
goto LABEL_24;
}
if ( m_objectID != 3032 )
{
if ( m_objectID != 2065 )
goto LABEL_25;
if ( a1->m_previewParticles )
{
BYTE1(a2[1].m_obRect.size.width) = 0;
if ( ((unsigned __int8 (__fastcall *)(GameObject *))a2->isVisible)(a2) )
((void (__fastcall *)(GameObject *))a2->claimParticle)(a2);
v8 = 50;
v9 = 0.0;
if ( a1->m_hideParticleIcons )
goto LABEL_23;
}
else
{
BYTE1(a2[1].m_obRect.size.width) = 1;
((void (__fastcall *)(GameObject *))a2->unclaimParticle)(a2);
v8 = 255;
}
v16 = 0;
if ( a1->m_playbackMode != Playing )
v16 = v8;
v9 = (float)v16;
LABEL_23:
ParticleGameObject::updateParticlePreviewArtOpacity((ParticleGameObject *)a2, v9);
sub_10071FCD0(a1->m_particleObjects, a2);
goto LABEL_24;
}
sub_10071FCD0(a1->m_keyframeObjects, a2);
((void (__fastcall *)(LevelEditorLayer *, GameObject *))a1->addKeyframe)(a1, a2);
LABEL_24:
m_objectID = a2->m_objectID;
LABEL_25:
if ( m_objectID == 1049 )
EffectGameObject::updateSpecialColor((EffectGameObject *)a2);
if ( a2->m_isTrigger )
{
m_drawGridLayer = a1->m_drawGridLayer;
if ( !(unsigned __int8)sub_100720160(m_drawGridLayer->m_effectGameObjects, a2) )
{
sub_10071FCD0(m_drawGridLayer->m_effectGameObjects, a2);
m_drawGridLayer->m_sortEffects = 1;
}
}
if ( ((unsigned int (__fastcall *)(GameObject *))a2->getType)(a2) == 25 )
{
GameObject::determineSlopeDirection(a2);
if ( a2->m_classType != Effect )
{
LABEL_32:
v18 = a2->m_objectID;
if ( v18 <= 1911 )
goto LABEL_33;
LABEL_41:
if ( v18 > 2067 )
{
if ( v18 != 2068 )
{
if ( v18 == 3642 )
{
p_m_audioLineObjects = &a1->m_drawGridLayer->m_audioLineObjects;
m_uniqueID = a2->m_uniqueID;
p_m_uniqueID = &m_uniqueID;
*(_QWORD *)(sub_10010D1B0(p_m_audioLineObjects, &m_uniqueID, &unk_100816708, &p_m_uniqueID, v25) + 24) = a2;
if ( !a2->m_isSpawnOrderTrigger )
goto LABEL_51;
goto LABEL_67;
}
if ( v18 != 3016 )
goto LABEL_49;
goto LABEL_56;
}
}
else if ( v18 != 1912 )
{
if ( v18 == 2016 )
{
m_cameraGuideTriggers = a1->m_cameraGuideTriggers;
LABEL_57:
sub_10071FCD0(m_cameraGuideTriggers, a2);
if ( !a2->m_isSpawnOrderTrigger )
goto LABEL_51;
goto LABEL_67;
}
if ( v18 != 2067 )
goto LABEL_49;
LABEL_56:
m_cameraGuideTriggers = a1->m_moveTriggers;
goto LABEL_57;
}
LABEL_59:
sub_10071FCD0(a1->m_spawnTriggers, a2);
a1->m_spawnTriggersChanged = 1;
if ( !a2->m_isSpawnOrderTrigger )
goto LABEL_51;
goto LABEL_67;
}
}
else if ( a2->m_classType != Effect )
{
goto LABEL_32;
}
LevelEditorLayer::tryUpdateSpeedObject(a1, (EffectGameObject *)a2, 0);
v18 = a2->m_objectID;
if ( v18 > 1911 )
goto LABEL_41;
LABEL_33:
if ( v18 > 1267 )
{
if ( (unsigned int)(v18 - 1346) < 2 )
goto LABEL_56;
if ( v18 != 1268 )
{
if ( v18 != 1814 )
goto LABEL_49;
goto LABEL_56;
}
goto LABEL_59;
}
if ( v18 == 901 )
goto LABEL_56;
if ( v18 != 1006 )
{
if ( v18 == 1007 )
{
sub_10071FCD0(a1->m_alphaTriggers, a2);
a1->m_alphaTriggersChanged = 1;
if ( a2->m_isSpawnOrderTrigger )
goto LABEL_67;
LABEL_51:
if ( a2->m_activateTriggerInEditor )
goto LABEL_72;
goto LABEL_68;
}
LABEL_49:
if ( GameObject::isColorTrigger(a2) )
{
sub_10071FCD0(a1->m_colorTriggers, a2);
a1->m_colorTriggersChanged = 1;
if ( a2->m_isSpawnOrderTrigger )
goto LABEL_67;
}
else if ( a2->m_isSpawnOrderTrigger )
{
goto LABEL_67;
}
goto LABEL_51;
}
sub_10071FCD0(a1->m_pulseTriggers, a2);
a1->m_pulseTriggersChanged = 1;
if ( !a2->m_isSpawnOrderTrigger )
goto LABEL_51;
LABEL_67:
sub_10071FCD0(a1->m_spawnOrderObjects, a2);
a1->m_spawnOrderObjectsChanged = 1;
if ( a2->m_activateTriggerInEditor )
goto LABEL_72;
LABEL_68:
if ( !((unsigned __int8 (__fastcall *)(GameObject *))a2->isSpecialSpawnObject)(a2) )
{
if ( !a2->m_dontIgnoreDuration )
goto LABEL_70;
goto LABEL_73;
}
LABEL_72:
sub_10071FCD0(a1->m_playtestTriggers, a2);
if ( !a2->m_dontIgnoreDuration )
{
LABEL_70:
m_levelSettings = a1->m_levelSettings;
if ( !m_levelSettings )
goto LABEL_76;
goto LABEL_74;
}
LABEL_73:
sub_10071FCD0(a1->m_durationObjects, a2);
m_levelSettings = a1->m_levelSettings;
if ( !m_levelSettings )
{
LABEL_76:
shouldLockX = GameObject::shouldLockX(a2);
goto LABEL_77;
}
LABEL_74:
if ( !m_levelSettings->m_platformerMode )
goto LABEL_76;
shouldLockX = 0;
LABEL_77:
a2->m_tempOffsetXRelated = shouldLockX;
sub_10071FCD0(a1->m_objects, a2);
GJBaseGameLayer::addToGroups(a1, a2, 0);
GJBaseGameLayer::addToGroupParents(a1, a2);
GJBaseGameLayer::reAddToStickyGroup(a1, a2);
a1->m_unk3b22 = 1;
}