mirror of
https://github.com/ChronosX88/mta-mono.git
synced 2024-11-22 02:02:23 +00:00
Добавление и удаление классов из пула
This commit is contained in:
parent
1dc1390070
commit
488bb0ed4c
@ -14,10 +14,15 @@
|
||||
|
||||
CMonoMTALib::CMonoMTALib( CMonoDomain* pDomain )
|
||||
{
|
||||
this->m_pClass = nullptr;
|
||||
this->m_pObject = nullptr;
|
||||
|
||||
this->m_pAssembly = nullptr;
|
||||
this->m_pImage = nullptr;
|
||||
this->m_pDomain = pDomain;
|
||||
|
||||
this->m_uiGCHandle = 0;
|
||||
|
||||
string strPath( CMonoInterface::GetBinariesDirectory() + "/" + pDomain->GetResource()->GetName() + "/MultiTheftAuto.dll" );
|
||||
|
||||
this->m_pAssembly = pDomain->OpenAssembly( strPath.c_str() );
|
||||
@ -32,15 +37,13 @@ CMonoMTALib::CMonoMTALib( CMonoDomain* pDomain )
|
||||
this->Vector2 = this->GetClass( "Vector2" );
|
||||
this->Vector3 = this->GetClass( "Vector3" );
|
||||
|
||||
MonoClass* pMonoClass = mono_class_from_name( this->m_pImage, "MultiTheftAuto", "MultiTheftAuto" );
|
||||
this->m_pClass = this->GetClass( "MultiTheftAuto" );
|
||||
|
||||
if( pMonoClass )
|
||||
if( this->m_pClass )
|
||||
{
|
||||
MonoObject* pMonoObject = this->m_pDomain->CreateObject( pMonoClass );
|
||||
|
||||
mono_gchandle_new( pMonoObject, false );
|
||||
|
||||
mono_runtime_object_init( pMonoObject );
|
||||
this->m_pObject = this->m_pClass->New();
|
||||
|
||||
//this->m_uiGCHandle = mono_gchandle_new( this->m_pObject, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -48,9 +51,22 @@ CMonoMTALib::CMonoMTALib( CMonoDomain* pDomain )
|
||||
|
||||
CMonoMTALib::~CMonoMTALib( void )
|
||||
{
|
||||
if( this->m_uiGCHandle )
|
||||
{
|
||||
mono_gchandle_free( this->m_uiGCHandle );
|
||||
|
||||
this->m_uiGCHandle = 0;
|
||||
}
|
||||
|
||||
SAFE_DELETE( this->Color );
|
||||
SAFE_DELETE( this->Vector2 );
|
||||
SAFE_DELETE( this->Vector3 );
|
||||
SAFE_DELETE( this->m_pClass );
|
||||
|
||||
this->m_pDomain = nullptr;
|
||||
this->m_pAssembly = nullptr;
|
||||
this->m_pImage = nullptr;
|
||||
this->m_pObject = nullptr;
|
||||
}
|
||||
|
||||
CMonoClass* CMonoMTALib::GetClass( const char* szName )
|
||||
|
@ -23,8 +23,12 @@ class CMonoMTALib
|
||||
private:
|
||||
MonoAssembly* m_pAssembly;
|
||||
MonoImage* m_pImage;
|
||||
MonoObject* m_pObject;
|
||||
CMonoClass* m_pClass;
|
||||
CMonoDomain* m_pDomain;
|
||||
|
||||
uint32_t m_uiGCHandle;
|
||||
|
||||
public:
|
||||
CMonoClass* Color;
|
||||
CMonoClass* Vector2;
|
||||
|
Loading…
Reference in New Issue
Block a user