//
// BrowseSmartTemplateLayer::onTemplateObject from 0x1405f0be0 to 0x1405f0ead (717 bytes)
//
// 2 xrefs:
// > BrowseSmartTemplateLayer::addPrefabMenuItem @ 0x1405f01e6
// > ??> @ 0x14092f264
//
// This function is hookable on this platform (idp: pc, 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 11:35:05 +0000
//
// Hidden C++ exception states: #wind=2
__int64 __fastcall BrowseSmartTemplateLayer::onTemplateObject(__int64 a1, __int64 a2)
{
__int64 v3; // r14
cocos2d::CCArray *v4; // rdi
__int64 v5; // rcx
__int64 v6; // rax
cocos2d::CCTouchDispatcher *v7; // rax
__int64 v8; // rdx
__int64 v9; // r15
__int64 v10; // rbx
char *v11; // rdi
__int64 v12; // rax
__int64 (__fastcall *v13)(__int64); // rdx
__int64 v15; // rax
__int64 v16; // rbx
__int64 v17; // rdx
__int64 v18; // r8
cocos2d::CCNode *v19; // rax
char v20[16]; // [rsp+30h] [rbp-40h] BYREF
__int64 v21; // [rsp+40h] [rbp-30h]
__int64 v22; // [rsp+48h] [rbp-28h]
__int128 v23; // [rsp+50h] [rbp-20h] BYREF
__int64 v24; // [rsp+60h] [rbp-10h]
__int64 v25; // [rsp+68h] [rbp-8h]
__int64 v26; // [rsp+A0h] [rbp+30h]
v3 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a2 + 952LL))(a2) + 320;
v26 = sub_14003F4F0((__int64)&v23, v3);
v4 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(*(_QWORD *)(*(_QWORD *)(a1 + 664) + 56LL), v26);
sub_14003D310(v26);
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, (struct cocos2d::CCObject *)a1);
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a1 + 992LL))(a1, 0);
LOBYTE(v8) = 1;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 520LL))(a1, v8);
v9 = sub_14003F4F0((__int64)&v23, v3);
v10 = *(_QWORD *)(a1 + 664);
v11 = (char *)operator new(0x2F0u);
BrowseSmartTemplateLayer::BrowseSmartTemplateLayer((__int64)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';
*((_QWORD *)v11 + 68) = &BrowseSmartKeyLayer::`vftable';
*(_OWORD *)(v11 + 712) = 0;
*((_QWORD *)v11 + 91) = 0;
*((_QWORD *)v11 + 92) = 15;
v11[712] = 0;
*((_DWORD *)v11 + 186) = 0;
v12 = sub_14003F4F0((__int64)v20, v9);
if ( (unsigned __int8)BrowseSmartKeyLayer::init(v11, v10, v12) )
{
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v11);
}
else
{
(*(void (__fastcall **)(char *, __int64))(*(_QWORD *)v11 + 8LL))(v11, 1);
v11 = nullptr;
}
sub_14003D310(v9);
*((_DWORD *)v11 + 186) = *(_DWORD *)(a1 + 680);
v13 = *(__int64 (__fastcall **)(__int64))(*(_QWORD *)v11 + 1064LL);
if ( v13 == FLAlertLayer::show )
return FLAlertLayer::show((__int64)v11);
else
return v13((__int64)v11);
}
else
{
v15 = sub_14003F4F0((__int64)&v23, v3);
BrowseSmartTemplateLayer::createPrefab(a1, v15, 0);
v23 = 0;
v24 = 0;
v25 = 15;
LOBYTE(v23) = 0;
v21 = 15;
v22 = 15;
strcpy(v20, "Added to editor");
v16 = *(_QWORD *)a1;
v19 = TextAlertPopup::create((__int64)v20, v17, v18, 150, (__int64)&v23);
return (*(__int64 (__fastcall **)(__int64, cocos2d::CCNode *, __int64))(v16 + 456))(a1, v19, 100);
}
}