//
// BrowseSmartTemplateLayer::onTemplateObject from 0x14045b0d0 to 0x14045b38a (698 bytes)
//
// 2 xrefs:
// > BrowseSmartTemplateLayer::addPrefabMenuItem @ 0x14045a71d
// > ??> @ 0x1406dabb0
//
// 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
//
// Hidden C++ exception states: #wind=2
void BrowseSmartTemplateLayer::onTemplateObject(BrowseSmartTemplateLayer *a1, cocos2d::CCObject *a2)
{
__int64 v3; // r14
cocos2d::CCArray *v4; // rdi
__int64 v5; // rcx
__int64 v6; // rax
cocos2d::CCTouchDispatcher *v7; // rax
_BOOL8 v8; // rdx
__int64 v9; // r15
GJSmartTemplate *m_template; // rbx
char *v11; // rdi
__int64 v12; // rax
void (*v13)(FLAlertLayer *); // rdx
__int64 v14; // rax
BrowseSmartTemplateLayer_vtbl *v15; // rbx
__int64 v16; // rdx
__int64 v17; // r8
cocos2d::CCNode *v18; // rax
char v19[16]; // [rsp+30h] [rbp-40h] BYREF
__int64 v20; // [rsp+40h] [rbp-30h]
__int64 v21; // [rsp+48h] [rbp-28h]
__int128 v22; // [rsp+50h] [rbp-20h] BYREF
__int64 v23; // [rsp+60h] [rbp-10h]
__int64 v24; // [rsp+68h] [rbp-8h]
__int64 v25; // [rsp+A0h] [rbp+30h]
v3 = ((__int64 (__fastcall *)(cocos2d::CCObject *))a2->__vftable[13].copyWithZone)(a2) + 320;
v25 = sub_14003BDB0((__int64)&v22, v3);
v4 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(a1->m_template->m_prefabArrays, v25);
sub_14003A830(v25);
if ( v4 && cocos2d::CCArray::count(v4) )
{
v6 = cocos2d::CCDirector::sharedDirector(v5);
v7 = (cocos2d::CCTouchDispatcher *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v6 + 144LL))(v6);
cocos2d::CCTouchDispatcher::unregisterForcePrio(v7, a1);
a1->setKeypadEnabled(a1, 0);
LOBYTE(v8) = 1;
a1->removeFromParentAndCleanup(a1, v8);
v9 = sub_14003BDB0((__int64)&v22, v3);
m_template = a1->m_template;
v11 = (char *)operator new(0x2D0u);
BrowseSmartTemplateLayer::BrowseSmartTemplateLayer((BrowseSmartTemplateLayer *)v11);
*(_QWORD *)v11 = &BrowseSmartKeyLayer::`vftable';
*((_QWORD *)v11 + 40) = &BrowseSmartKeyLayer::`vftable';
*((_QWORD *)v11 + 41) = &BrowseSmartKeyLayer::`vftable';
*((_QWORD *)v11 + 42) = &BrowseSmartKeyLayer::`vftable';
*((_QWORD *)v11 + 43) = &BrowseSmartKeyLayer::`vftable';
*((_QWORD *)v11 + 44) = &BrowseSmartKeyLayer::`vftable';
*((_QWORD *)v11 + 51) = &BrowseSmartKeyLayer::`vftable';
*((_QWORD *)v11 + 54) = &BrowseSmartKeyLayer::`vftable';
*(_OWORD *)(v11 + 680) = 0;
*((_QWORD *)v11 + 87) = 0;
*((_QWORD *)v11 + 88) = 15;
v11[680] = 0;
*((_DWORD *)v11 + 178) = 0;
v12 = sub_14003BDB0((__int64)v19, v9);
if ( (unsigned __int8)BrowseSmartKeyLayer::init(v11, m_template, v12) )
{
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v11);
}
else
{
(*(void (__fastcall **)(char *, __int64))(*(_QWORD *)v11 + 8LL))(v11, 1);
v11 = nullptr;
}
sub_14003A830(v9);
*((_DWORD *)v11 + 178) = a1->m_page;
v13 = *(void (**)(FLAlertLayer *))(*(_QWORD *)v11 + 1040LL);
if ( v13 == FLAlertLayer::show )
FLAlertLayer::show((FLAlertLayer *)v11);
else
v13((FLAlertLayer *)v11);
}
else
{
v14 = sub_14003BDB0((__int64)&v22, v3);
BrowseSmartTemplateLayer::createPrefab((__int64)a1, v14, 0);
v22 = 0;
v23 = 0;
v24 = 15;
LOBYTE(v22) = 0;
v20 = 15;
v21 = 15;
strcpy(v19, "Added to editor");
v15 = a1->FLAlertLayer::cocos2d::CCLayerColor::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v18 = TextAlertPopup::create((__int64)v19, v16, v17, 150, (__int64)&v22);
v15->addChild_0(a1, v18, 100);
}
}