//
// BrowseSmartTemplateLayer::onTemplateObject from 0x1004ea0e0 to 0x1004ea322 (578 bytes)
//
// 1 xrefs:
// > BrowseSmartTemplateLayer::addPrefabMenuItem @ 0x1004e9ce4
//
// 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 BrowseSmartTemplateLayer::onTemplateObject(BrowseSmartTemplateLayer *a1, cocos2d::CCObject *a2)
{
__int128 v2; // xmm0
__int64 v3; // rax
__int64 v4; // r14
GJSmartTemplate *m_template; // r15
__int64 v6; // r12
__int64 Prefabs; // r15
cocos2d::CCDirector *v8; // rax
cocos2d::CCTouchDispatcher *v9; // rax
GJSmartTemplate *v10; // r15
cocos2d::CCObject *v11; // rax
_DWORD *v12; // r14
__int128 v13; // [rsp+8h] [rbp-A8h] BYREF
void *v14; // [rsp+18h] [rbp-98h]
__int128 v15; // [rsp+20h] [rbp-90h] BYREF
void *__p; // [rsp+30h] [rbp-80h]
__int128 v17; // [rsp+40h] [rbp-70h] BYREF
void *v18; // [rsp+50h] [rbp-60h]
__int128 v19; // [rsp+60h] [rbp-50h] BYREF
void *v20; // [rsp+70h] [rbp-40h]
char v21; // [rsp+78h] [rbp-38h] BYREF
_BYTE v22[46]; // [rsp+79h] [rbp-37h] BYREF
v3 = ((__int64 (__fastcall *)(cocos2d::CCObject *))a2->__vftable[13].~CCObject_0)(a2);
v4 = v3;
m_template = a1->m_template;
v6 = v3 + 320;
if ( (*(_BYTE *)(v3 + 320) & 1) != 0 )
{
sub_100006B70(&v15, *(const void **)(v3 + 336), *(_QWORD *)(v3 + 328), *(double *)&v2);
}
else
{
__p = *(void **)(v3 + 336);
v2 = *(_OWORD *)v6;
v15 = *(_OWORD *)v6;
}
Prefabs = GJSmartTemplate::getPrefabs((__int64)m_template, (char *)&v15);
if ( (v15 & 1) != 0 )
operator delete(__p);
if ( Prefabs && (unsigned int)sub_100720070(Prefabs) )
{
v8 = cocos2d::CCDirector::sharedDirector();
v9 = (cocos2d::CCTouchDispatcher *)((__int64 (__fastcall *)(cocos2d::CCDirector *))v8->getTouchDispatcher)(v8);
cocos2d::CCTouchDispatcher::unregisterForcePrio(v9, a1);
((void (__fastcall *)(BrowseSmartTemplateLayer *, _QWORD))a1->setKeypadEnabled)(a1, 0);
((void (__fastcall *)(BrowseSmartTemplateLayer *, __int64))a1->removeFromParentAndCleanup)(a1, 1);
v10 = a1->m_template;
if ( (*(_BYTE *)v6 & 1) != 0 )
{
sub_100006B70(&v17, *(const void **)(v4 + 336), *(_QWORD *)(v4 + 328), *(double *)&v2);
}
else
{
v18 = *(void **)(v6 + 16);
v17 = *(_OWORD *)v6;
}
v12 = (_DWORD *)BrowseSmartKeyLayer::create(v10, &v17);
if ( (v17 & 1) != 0 )
operator delete(v18);
v12[176] = a1->m_page;
(*(void (__fastcall **)(_DWORD *))(*(_QWORD *)v12 + 1288LL))(v12);
}
else
{
if ( (*(_BYTE *)v6 & 1) != 0 )
{
sub_100006B70(&v19, *(const void **)(v4 + 336), *(_QWORD *)(v4 + 328), *(double *)&v2);
}
else
{
v20 = *(void **)(v6 + 16);
v19 = *(_OWORD *)v6;
}
BrowseSmartTemplateLayer::createPrefab(a1, &v19, 0);
if ( (v19 & 1) != 0 )
operator delete(v20);
v21 = 30;
strcpy(v22, "Added to editor");
LOWORD(v13) = 0;
v11 = TextAlertPopup::create((__int64)&v21, 0x96u, &v13, (__m128)0x3F000000u, 0.60000002);
((void (__fastcall *)(BrowseSmartTemplateLayer *, cocos2d::CCObject *, __int64))a1->addChild_0)(a1, v11, 100);
if ( (v13 & 1) != 0 )
operator delete(v14);
if ( (v21 & 1) != 0 )
operator delete(*(void **)&v22[15]);
}
}