//
// SecretLayer2::onDoor from 0x10049fb10 to 0x10049fcd3 (451 bytes)
//
// 1 xrefs:
// > SecretLayer2::init @ 0x10049db35
//
// 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 SecretLayer2::onDoor(SecretLayer2 *a1, cocos2d::CCObject *a2)
{
__m128 v2; // xmm0
GameManager *v3; // rax
cocos2d::CCDirector *v4; // rbx
cocos2d::CCScene *v5; // rax
cocos2d::CCTransitionFade *v6; // rax
int m_doorDialogIndex; // eax
int v8; // eax
__m128 v9; // xmm1
unsigned int v10; // ecx
char *v11; // rax
DialogLayer *v12; // r14
std::string v13; // [rsp+0h] [rbp-60h] BYREF
__int128 v14; // [rsp+20h] [rbp-40h] BYREF
void *v15; // [rsp+30h] [rbp-30h]
std::string v16; // [rsp+38h] [rbp-28h] BYREF
v3 = GameManager::sharedState();
if ( GameManager::getUGV(v3, "4") )
{
v4 = cocos2d::CCDirector::sharedDirector();
v5 = SecretLayer3::scene();
v6 = cocos2d::CCTransitionFade::create_1(0.5, v5);
cocos2d::CCDirector::replaceScene(v4, v6);
}
else
{
v16.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)22;
strcpy(v16.__r_.__value_.__s.__data_, "Not allowed");
m_doorDialogIndex = a1->m_doorDialogIndex;
if ( m_doorDialogIndex < 0 )
{
v2.f32[0] = (float)((float)rand() * 4.6566129e-10) * 10.0;
v9 = _mm_or_ps(_mm_and_ps((__m128)xmmword_1008150B0, v2), (__m128)xmmword_1008150C0);
v9.f32[0] = v9.f32[0] + v2.f32[0];
v2.i64[0] = _mm_round_ss((__m128)0LL, v9, 11).u64[0];
v8 = (int)v2.f32[0];
}
else
{
v8 = m_doorDialogIndex + 1;
}
v10 = 0;
if ( v8 < 11 )
v10 = v8;
a1->m_doorDialogIndex = v10;
if ( v10 <= 0xA )
std::string::assign(&v16, (const std::string::value_type *)&unk_10081D41C + *((int *)&unk_10081D41C + v10));
LOBYTE(v14) = 26;
strcpy((char *)&v14 + 1, "The Keymaster");
if ( (*(_BYTE *)&v16.__r_.__value_.__s.0 & 1) != 0 )
sub_100006B70(&v13, v16.__r_.__value_.__l.__data_, v16.__r_.__value_.__l.__size_, *(double *)v2.i64);
else
v13 = v16;
v11 = DialogObject::create(&v14, &v13, 2, 0, 0xFFFFFF, 1.0);
v12 = DialogLayer::create((DialogObject *)v11, 2);
if ( (*(_BYTE *)&v13.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v13.__r_.__value_.__l.__data_);
if ( (v14 & 1) != 0 )
operator delete(v15);
((void (__fastcall *)(SecretLayer2 *, DialogLayer *, __int64))a1->addChild_0)(a1, v12, 100);
DialogLayer::updateChatPlacement(v12, Center);
DialogLayer::animateInRandomSide(v12);
if ( (*(_BYTE *)&v16.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v16.__r_.__value_.__l.__data_);
}
}