//
// PlayerObject::toggleRobotMode from 0x10022b0d0 to 0x10022b384 (692 bytes)
//
// 5 xrefs:
// > GJBaseGameLayer::switchToRobotMode @ 0x1001e668c
// > PlayerObject::switchedToMode @ 0x1002270fc
// > PlayerObject::switchedToMode @ 0x10022717c
// > PlayerObject::copyAttributes @ 0x10022d32c
// > MenuGameLayer::resetPlayer @ 0x10039b16c
//
// 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 PlayerObject::toggleRobotMode(PlayerObject *a1, bool a2, bool a3)
{
_BOOL4 v3; // w20
cocos2d::CCNode_vtbl *v5; // x8
GameManager *v7; // x0
int v8; // w8
cocos2d::CCString *v9; // x0
char *CString; // x0
cocos2d::CCSprite *m_iconSprite; // x22
cocos2d::CCSpriteFrameCache *v12; // x0
void **v13; // x1
cocos2d::CCSpriteFrame *v14; // x0
GJRobotSprite *m_robotSprite; // x22
void **p_dst; // x8
PlayerObject *v17; // x0
int m_maybeSavedPlayerFrame; // w1
GJRobotSprite *v19; // x22
__int128 __dst; // [xsp+10h] [xbp-80h] BYREF
char *longStorage; // [xsp+20h] [xbp-70h]
_QWORD v22[2]; // [xsp+30h] [xbp-60h] BYREF
char v23; // [xsp+47h] [xbp-49h]
void *__p[2]; // [xsp+48h] [xbp-48h] BYREF
char v25; // [xsp+5Fh] [xbp-31h]
if ( a1->m_isRobot != a2 )
{
v3 = a2;
a1->m_gameModeChangedTime = a1->m_totalTime;
a1->m_isRobot = a2;
v5 = a1->m_mainLayer->__vftable;
if ( !a2 )
{
((void (*)(void))v5->removeChild_0)();
((void (__fastcall *)(cocos2d::CCSprite *, __int64))a1->m_iconSprite->setVisible)(a1->m_iconSprite, 1);
SpriteAnimationManager::stopAnimations(a1->m_robotSprite->m_animationManager);
if ( a1->m_vehicleSize == 1.0 || !a1->m_defaultMiniIcon )
{
m_maybeSavedPlayerFrame = a1->m_maybeSavedPlayerFrame;
v17 = a1;
}
else
{
v17 = a1;
m_maybeSavedPlayerFrame = 0;
}
PlayerObject::updatePlayerFrame(v17, m_maybeSavedPlayerFrame);
LABEL_29:
PlayerObject::updatePlayerGlow(a1);
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
if ( v3 )
{
PlayerObject::updatePlayerArt(a1);
PlayerObject::updateDashArt(a1);
}
return;
}
((void (*)(void))v5->addChild_0)();
PlayerObject::switchedToMode(a1, RobotPortal);
a1->m_accelerationOrSpeed = 1.5;
*(_WORD *)&a1->m_isRotating = 0;
a1->m_isBallRotating = 0;
a1->m_rotationSpeed = 0.0;
((void (__fastcall *)(PlayerObject *, float))a1->setRotation)(a1, 0.0);
v7 = GameManager::sharedState();
v8 = v7->m_playerRobot.random - v7->m_playerRobot.seed;
if ( v8 >= 68 )
v8 = 68;
if ( v8 <= 1 )
v8 = 1;
v9 = (cocos2d::CCString *)sub_100268F4C("robot_%02d_01_001.png", v8);
CString = (char *)cocos2d::CCString::getCString(v9);
sub_100009900(__p, CString);
m_iconSprite = a1->m_iconSprite;
v12 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
if ( v25 >= 0 )
v13 = __p;
else
v13 = (void **)__p[0];
v14 = cocos2d::CCSpriteFrameCache::spriteFrameByName(v12, (const char *)v13);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCSpriteFrame *))m_iconSprite->setDisplayFrame)(
m_iconSprite,
v14);
if ( a1->m_isPlatformer && a1->m_platformerXVelocity == 0.0 )
{
m_robotSprite = a1->m_robotSprite;
sub_100009900(v22, "idle01");
CCAnimatedSprite::runAnimation(m_robotSprite, v22);
if ( (v23 & 0x80000000) == 0 )
{
LABEL_25:
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))a1->m_iconSprite->setVisible)(a1->m_iconSprite, 0);
if ( !a3 )
PlayerObject::spawnPortalCircle(a1, (cocos2d::ccColor3B)3289855, 50.0);
GJActionManager::stopInternalAction(a1->m_actionManager, 6);
((void (__fastcall *)(PlayerObject *, float))a1->setScaleX)(a1, a1->m_vehicleSize);
((void (__fastcall *)(PlayerObject *, float))a1->setScaleY)(a1, a1->m_vehicleSize);
if ( v25 < 0 )
operator delete(__p[0]);
goto LABEL_29;
}
p_dst = (void **)v22;
}
else
{
v19 = a1->m_robotSprite;
if ( a1->m_currentRobotAnimation.m_data.m_short.shortStorage.__elems_[22] < 0 )
{
sub_1000097D0(
&__dst,
(void *)a1->m_currentRobotAnimation.m_data.m_long.capacitym1,
a1->m_currentRobotAnimation.m_data.m_long.size);
}
else
{
__dst = *(_OWORD *)&a1->m_currentRobotAnimation.m_data.m_short.sizex2;
longStorage = a1->m_currentRobotAnimation.m_data.m_long.longStorage;
}
CCAnimatedSprite::runAnimation(v19, &__dst);
if ( (SHIBYTE(longStorage) & 0x80000000) == 0 )
goto LABEL_25;
p_dst = (void **)&__dst;
}
operator delete(*p_dst);
goto LABEL_25;
}
}