//
// SetupSmartBlockLayer::onPasteTemplate from 0xb15c44 to 0xb15e64 (544 bytes)
//
// 3 xrefs:
// > ??> @ 0x52d68
// > SetupSmartBlockLayer::init @ 0xb15194
// > ??> @ 0x1541cc8
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:01:31 +0000
//
__int64 __fastcall SetupSmartBlockLayer::onPasteTemplate(cocos2d::CCArray **this, cocos2d::CCObject *a2)
{
GameManager *v3; // x0
__int64 v4; // x1
__int64 v5; // x21
cocos2d::CCArray *v6; // x21
GameManager *v7; // x0
__int64 v8; // x0
cocos2d::CCDirector *v9; // x0
cocos2d::CCDirector *v10; // x0
GameManager *WinSize; // x0
GameManager *v12; // x0
float v13; // s9
cocos2d::CCNode *v14; // x25
__int64 v15; // x0
GameManager *v16; // x0
__int64 v17; // x25
GameManager *v18; // x0
__int64 v19; // x22
GameLevelManager *v20; // x0
GameLevelManager *v21; // x0
GameManager *ActiveSmartTemplate; // x0
__int64 v23; // x0
float v25; // [xsp+60h] [xbp+60h]
GJSmartTemplate *v26; // [xsp+60h] [xbp+60h]
__int64 v27; // [xsp+70h] [xbp+70h] BYREF
__int64 v28; // [xsp+78h] [xbp+78h] BYREF
float v29; // [xsp+80h] [xbp+80h] BYREF
_BYTE v30[8]; // [xsp+88h] [xbp+88h] BYREF
GameManager *v31[2]; // [xsp+90h] [xbp+90h] BYREF
void *v32; // [xsp+A0h] [xbp+A0h]
v3 = *(GameManager **)(GameManager::sharedState(_stack_chk_guard) + 552);
if ( v3 )
{
v4 = *(_QWORD *)(GameManager::sharedState(v3) + 552);
v31[0] = nullptr;
v5 = *(_QWORD *)(v4 + 14248);
v31[1] = nullptr;
v32 = nullptr;
std::string::__init((__int64 *)v31, a12895236453195, 0x175Fu);
v6 = (cocos2d::CCArray *)EditorUI::pasteObjects(v5, (int)v31);
v7 = (GameManager *)LOBYTE(v31[0]);
if ( ((__int64)v31[0] & 1) != 0 )
operator delete(v32);
v8 = GameManager::sharedState(v7);
EditorBuildStats::noteAction(*(_QWORD *)(v8 + 552) + 14704LL);
if ( v6 )
{
v9 = (cocos2d::CCDirector *)cocos2d::CCArray::count(v6);
if ( (_DWORD)v9 )
{
v10 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v9);
WinSize = (GameManager *)cocos2d::CCDirector::getWinSize(&v27, v10);
v12 = *(GameManager **)(GameManager::sharedState(WinSize) + 552);
v13 = *((float *)&v27 + 1);
v14 = *((cocos2d::CCNode **)v12 + 490);
v25 = *(float *)&v27 * 0.5;
v15 = GameManager::sharedState(v12);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)v30,
v25,
(float)(*(float *)(*(_QWORD *)(*(_QWORD *)(v15 + 552) + 14248LL) + 856LL) * 0.5) + (float)(v13 * 0.5));
v16 = (GameManager *)cocos2d::CCNode::convertToNodeSpace(&v28, v14, (const cocos2d::CCPoint *)v30);
v17 = *(_QWORD *)(*(_QWORD *)(GameManager::sharedState(v16) + 552) + 14248LL);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v29, (const cocos2d::CCPoint *)&v28);
EditorUI::getGridSnappedPos(v17, &v29, (__int64)v30);
cocos2d::CCPoint::operator=(&v28, v30);
v19 = *(_QWORD *)(*(_QWORD *)(GameManager::sharedState(v18) + 552) + 14248LL);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v30, (const cocos2d::CCPoint *)&v28);
v20 = (GameLevelManager *)EditorUI::repositionObjectsToCenter(v19, v6, v30, 0);
v21 = (GameLevelManager *)GameLevelManager::sharedState(v20);
ActiveSmartTemplate = (GameManager *)GameLevelManager::getActiveSmartTemplate(v21);
if ( ActiveSmartTemplate )
{
v26 = ActiveSmartTemplate;
v23 = GameManager::sharedState(ActiveSmartTemplate);
EditorUI::createSmartObjectsFromTemplate(
*(EditorUI **)(*(_QWORD *)(v23 + 552) + 14248LL),
v26,
v6,
0,
1u,
1u,
0);
}
}
}
}
SetupSmartBlockLayer::onClose(this, nullptr);
return _stack_chk_guard;
}