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