//
// CCAnimatedSprite::loadType from 0x1002fd444 to 0x1002fd85c (1048 bytes)
//
// 1 xrefs:
// > CCAnimatedSprite::initWithType @ 0x1002fd3f4
//
// 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 CCAnimatedSprite::loadType(CCAnimatedSprite *a1, const char *a2, cocos2d::CCTexture2D *a3, bool a4)
{
bool v8; // w0
bool v9; // w22
ObjectManager *v10; // x0
cocos2d::CCDictionary *Definition; // x22
cocos2d::CCString *v12; // x23
char *CString; // x0
cocos2d::CCTextureCache *v14; // x0
std::string *p_p; // x1
cocos2d::CCString *v16; // x24
cocos2d::CCString *v17; // x25
_BOOL4 v18; // w26
cocos2d::CCString *v19; // x0
const char *v20; // x0
std::string *p_m_currentAnim; // x24
cocos2d::CCSprite *v22; // x26
float v23; // s8
__n128 v24; // q1
__n128 v25; // q0
cocos2d::CCString *v26; // x0
const char *v27; // x22
CCPartAnimSprite *v28; // x21
float v29; // s8
__n128 v30; // q1
__n128 v31; // q0
SpriteAnimationManager *m_animationManager; // x0
CCPartAnimSprite *m_paSprite; // x0
cocos2d::CCSprite *m_fbfSprite; // x0
SpriteAnimationManager *v35; // x20
void *v36[2]; // [xsp+8h] [xbp-98h] BYREF
char v37; // [xsp+1Fh] [xbp-81h]
void *v38[2]; // [xsp+20h] [xbp-80h] BYREF
char v39; // [xsp+37h] [xbp-69h]
std::string __p; // [xsp+38h] [xbp-68h] BYREF
sub_100009900(&__p, (char *)a2);
v8 = sub_1000045BC(&a1->m_unkString1.m_data.m_long.capacitym1, &__p);
v9 = v8;
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
{
operator delete(__p.__r_.__value_.__l.__data_);
if ( v9 )
return;
}
else if ( v8 )
{
return;
}
CCAnimatedSprite::cleanupSprite(a1);
v10 = ObjectManager::instance();
Definition = ObjectManager::getDefinition(v10, a2);
if ( !a3 )
{
sub_100009900(&__p, "spriteSheet");
v12 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey_1(Definition, &__p);
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__p.__r_.__value_.__l.__data_);
CString = (char *)cocos2d::CCString::getCString(v12);
sub_100009900(&__p, CString);
std::string::append(&__p, ".png");
v14 = cocos2d::CCTextureCache::sharedTextureCache();
if ( (__p.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
p_p = &__p;
else
p_p = (std::string *)__p.__r_.__value_.__r.__words[0];
a3 = cocos2d::CCTextureCache::addImage(v14, (const char *)p_p, 0);
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__p.__r_.__value_.__l.__data_);
}
sub_100009900(&__p, "useFBF");
v16 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey_1(Definition, &__p);
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__p.__r_.__value_.__l.__data_);
sub_100009900(&__p, "usePA");
v17 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey_1(Definition, &__p);
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
{
operator delete(__p.__r_.__value_.__l.__data_);
if ( v16 )
{
LABEL_17:
v18 = cocos2d::CCString::boolValue(v16);
if ( !v17 )
goto LABEL_19;
goto LABEL_18;
}
}
else if ( v16 )
{
goto LABEL_17;
}
v18 = 0;
if ( v17 )
LABEL_18:
LODWORD(v17) = cocos2d::CCString::boolValue(v17);
LABEL_19:
sub_100009900(&__p, "defaultAnimation");
v19 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey_1(Definition, &__p);
v20 = cocos2d::CCString::getCString(v19);
p_m_currentAnim = &a1->m_currentAnim;
std::string::assign((std::string *)&a1->m_currentAnim, v20);
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
{
operator delete(__p.__r_.__value_.__l.__data_);
if ( !v18 )
{
LABEL_21:
if ( !(_DWORD)v17 )
goto LABEL_31;
LABEL_28:
sub_100009900(&__p, "animDesc");
v26 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey_1(Definition, &__p);
v27 = cocos2d::CCString::getCString(v26);
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__p.__r_.__value_.__l.__data_);
v28 = CCPartAnimSprite::createWithAnimDesc(v27, a3, a4);
a1->m_paSprite = v28;
v29 = *(float *)((__int64 (__fastcall *)(CCAnimatedSprite *))a1->getContentSize)(a1) * 0.5;
v30.n128_f32[0] = *(float *)(((__int64 (__fastcall *)(CCAnimatedSprite *))a1->getContentSize)(a1) + 4) * 0.5;
v31.n128_f32[0] = v29;
sub_100022980(v31, v30, &__p);
((void (__fastcall *)(CCPartAnimSprite *, std::string *))v28->setPosition)(v28, &__p);
((void (__fastcall *)(CCAnimatedSprite *, CCPartAnimSprite *))a1->addChild)(a1, a1->m_paSprite);
a1->m_sprite = a1->m_paSprite;
goto LABEL_31;
}
}
else if ( !v18 )
{
goto LABEL_21;
}
sub_100022990((float *)&__p, 0.0, 0.0, 0.0, 0.0);
v22 = cocos2d::CCSprite::createWithTexture(a3, (const cocos2d::CCRect *)&__p);
a1->m_fbfSprite = v22;
v23 = *(float *)((__int64 (__fastcall *)(CCAnimatedSprite *))a1->getContentSize)(a1) * 0.5;
v24.n128_f32[0] = *(float *)(((__int64 (__fastcall *)(CCAnimatedSprite *))a1->getContentSize)(a1) + 4) * 0.5;
v25.n128_f32[0] = v23;
sub_100022980(v25, v24, &__p);
((void (__fastcall *)(cocos2d::CCSprite *, std::string *))v22->setPosition)(v22, &__p);
((void (__fastcall *)(CCAnimatedSprite *, cocos2d::CCSprite *))a1->addChild)(a1, a1->m_fbfSprite);
a1->m_sprite = a1->m_fbfSprite;
if ( (_DWORD)v17 )
goto LABEL_28;
LABEL_31:
a1->m_spriteMode = 0;
sub_100009900(v38, (char *)a2);
m_animationManager = (SpriteAnimationManager *)SpriteAnimationManager::createWithOwner(a1, v38);
a1->m_animationManager = m_animationManager;
if ( v39 < 0 )
{
operator delete(v38[0]);
m_animationManager = a1->m_animationManager;
}
cocos2d::CCObject::retain(m_animationManager);
m_paSprite = a1->m_paSprite;
if ( m_paSprite )
((void (__fastcall *)(CCPartAnimSprite *, _QWORD))m_paSprite->setVisible)(m_paSprite, 0);
m_fbfSprite = a1->m_fbfSprite;
if ( m_fbfSprite )
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))m_fbfSprite->setVisible)(m_fbfSprite, 0);
((void (__fastcall *)(CCAnimatedSprite *, __int64))a1->setVisible)(a1, 1);
v35 = a1->m_animationManager;
if ( a1->m_currentAnim.m_data.m_short.shortStorage.__elems_[22] < 0 )
p_m_currentAnim = (std::string *)p_m_currentAnim->m_data.m_long.capacitym1;
sub_100009900(v36, (char *)p_m_currentAnim);
SpriteAnimationManager::runAnimation(v35, v36);
if ( v37 < 0 )
operator delete(v36[0]);
}