//
// LevelEditorLayer::copyObjectState from 0x661b00 to 0x661d20 (544 bytes)
//
// 4 xrefs:
// > EditorUI::onCopyState @ 0x6b5894
// > CustomizeObjectLayer::onCopy @ 0x83fa40
// > SetGroupIDLayer::onCopy @ 0x9746cc
// > ??> @ 0xc2c40
//
// 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::copyObjectState(LevelEditorLayer *a1, GameObject *a2)
{
GameObject *m_copyStateObject; // x0
GameObject *v5; // x0
GameObject_vtbl *v6; // x1
GameObject *v7; // x22
char *v8; // x0
GameObject *v9; // x24
void (__fastcall *setupCustomSprites)(GameObject *__hidden, std::string); // x25
char *v11; // x0
unsigned int *v12; // x1
int v13; // w2
unsigned int *v14; // x1
int v15; // w2
_QWORD v16[2]; // [xsp+0h] [xbp+0h] BYREF
char *v17; // [xsp+60h] [xbp+60h] BYREF
if ( a2 )
{
m_copyStateObject = a1->m_copyStateObject;
if ( !m_copyStateObject )
{
v5 = GameObject::createWithKey((int)&qword_C8 + 7);
v6 = v5->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_copyStateObject = v5;
((void (*)(void))v6->customSetup)();
v7 = a1->m_copyStateObject;
sub_D153B8((unsigned int)v16 + 96, "lightsquare_01_01_001.png");
GameObject::addColorSprite(v7, &v17);
v8 = v17 - 24;
if ( v17 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v12 = (unsigned int *)(v17 - 8);
do
v13 = __ldaxr(v12);
while ( __stlxr(v13 - 1, v12) );
}
else
{
v13 = *((_DWORD *)v17 - 2);
*((_DWORD *)v17 - 2) = v13 - 1;
}
if ( v13 <= 0 )
operator delete(v8);
}
v9 = a1->m_copyStateObject;
setupCustomSprites = v9->setupCustomSprites;
sub_D153B8((unsigned int)v16 + 96, "lightsquare_01_01_001.png");
((void (__fastcall *)(GameObject *, char **))setupCustomSprites)(v9, &v17);
v11 = v17 - 24;
if ( v17 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v14 = (unsigned int *)(v17 - 8);
do
v15 = __ldaxr(v14);
while ( __stlxr(v15 - 1, v14) );
}
else
{
v15 = *((_DWORD *)v17 - 2);
*((_DWORD *)v17 - 2) = v15 - 1;
}
if ( v15 <= 0 )
operator delete(v11);
}
cocos2d::CCObject::retain(a1->m_copyStateObject);
m_copyStateObject = a1->m_copyStateObject;
}
GameObject::setDefaultMainColorMode(m_copyStateObject, 0);
GameObject::setDefaultSecondaryColorMode(a1->m_copyStateObject, 0);
GameObject::duplicateColorMode(a1->m_copyStateObject);
GameObject::duplicateAttributes(a1->m_copyStateObject);
LevelEditorLayer::applyGroupState(a1, a1->m_copyStateObject, a2);
}
}