mirror of
https://github.com/ChronosX88/mta-mono.git
synced 2024-11-25 11:42:26 +00:00
Исправлено приведение типов с классами элементов
This commit is contained in:
parent
272f16a912
commit
915be1c34c
@ -70,16 +70,48 @@ CMonoClass* CMonoMTALib::GetClass( const char* szNameSpace, const char* szName )
|
|||||||
return this->GetDomain()->FindOrAdd( mono_class_from_name( this->m_pImage, szBuffer, szName ) );
|
return this->GetDomain()->FindOrAdd( mono_class_from_name( this->m_pImage, szBuffer, szName ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string CMonoMTALib::GetElementType( void* pUseData )
|
||||||
|
{
|
||||||
|
CResource* pResource = this->GetDomain()->GetResource();
|
||||||
|
|
||||||
|
assert( pResource );
|
||||||
|
|
||||||
|
string strTypeName;
|
||||||
|
|
||||||
|
if( CLuaFunctionDefinitions::IsElement( pResource->GetLua(), pUseData ) )
|
||||||
|
{
|
||||||
|
strTypeName = CLuaFunctionDefinitions::GetElementType( pResource->GetLua(), pUseData );
|
||||||
|
|
||||||
|
strTypeName[ 0 ] = toupper( strTypeName[ 0 ] );
|
||||||
|
|
||||||
|
if( strTypeName == "Root" )
|
||||||
|
{
|
||||||
|
strTypeName = "Element";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return strTypeName;
|
||||||
|
}
|
||||||
|
|
||||||
MonoObject* CMonoMTALib::RegisterElement( void* pUseData )
|
MonoObject* CMonoMTALib::RegisterElement( void* pUseData )
|
||||||
{
|
{
|
||||||
CMonoClass* pClass = this->GetClass( "Element" );
|
string strType = this->GetElementType( pUseData );
|
||||||
|
|
||||||
|
if( strType.length() == 0 )
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
CMonoClass* pClass = this->GetClass( strType.c_str() );
|
||||||
|
|
||||||
if( !pClass )
|
if( !pClass )
|
||||||
{
|
{
|
||||||
return false;
|
this->GetDomain()->GetResource()->ErrorPrintf( "[mono] Could not find the 'MultiTheftAuto.%s' class\n", strType.c_str() );
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMonoMethod* pMethod = pClass->GetMethod( "FindOrCreate", 0 );
|
CMonoMethod* pMethod = pClass->GetMethod( "Find", 0 );
|
||||||
|
|
||||||
if( !pMethod )
|
if( !pMethod )
|
||||||
{
|
{
|
||||||
@ -99,5 +131,10 @@ MonoObject* CMonoMTALib::RegisterElement( void* pUseData )
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !pObject )
|
||||||
|
{
|
||||||
|
pObject = pClass->New( Args, 1 );
|
||||||
|
}
|
||||||
|
|
||||||
return pObject;
|
return pObject;
|
||||||
}
|
}
|
@ -39,6 +39,8 @@ public:
|
|||||||
CMonoClass* GetClass ( const char* szName );
|
CMonoClass* GetClass ( const char* szName );
|
||||||
CMonoClass* GetClass ( const char* szNameSpace, const char* szName );
|
CMonoClass* GetClass ( const char* szNameSpace, const char* szName );
|
||||||
|
|
||||||
|
string GetElementType ( void* pUserData );
|
||||||
|
|
||||||
MonoObject* RegisterElement ( void* pUserData );
|
MonoObject* RegisterElement ( void* pUserData );
|
||||||
|
|
||||||
CMonoDomain* GetDomain ( void ) { return this->m_pDomain; }
|
CMonoDomain* GetDomain ( void ) { return this->m_pDomain; }
|
||||||
|
Loading…
Reference in New Issue
Block a user