mirror of
https://github.com/ChronosX88/mta-mono.git
synced 2024-11-21 17:52:23 +00:00
Added CElement::GetParent.
Creating the GC Handler for new elements.
This commit is contained in:
parent
399d7fd307
commit
27e2ee61f7
@ -45,6 +45,8 @@ CElement::CElement( CElementManager* pManager, MonoObject* pObject, PVOID pUserd
|
||||
|
||||
this->m_iType = eElementType::Unknown;
|
||||
|
||||
this->m_uiGCHandle = mono_gchandle_new( pObject, true );
|
||||
|
||||
this->m_pElementManager->AddToList( this );
|
||||
}
|
||||
|
||||
@ -52,6 +54,13 @@ CElement::~CElement( void )
|
||||
{
|
||||
this->m_pElementManager->RemoveFromList( this );
|
||||
|
||||
if( this->m_uiGCHandle )
|
||||
{
|
||||
mono_gchandle_free( this->m_uiGCHandle );
|
||||
|
||||
this->m_uiGCHandle = 0;
|
||||
}
|
||||
|
||||
this->m_pMonoObject = nullptr;
|
||||
this->m_pLuaUserdata = nullptr;
|
||||
this->m_pParent = nullptr;
|
||||
@ -67,3 +76,15 @@ const string CElement::GetTypeName( void )
|
||||
{
|
||||
return CElement::GetTypeName( this->m_iType );
|
||||
}
|
||||
|
||||
CElement* CElement::GetParent( void ) const
|
||||
{
|
||||
MonoObject* pMonoObject = CMonoFunctions::Element::GetParent( this->ToMonoObject() );
|
||||
|
||||
if( pMonoObject )
|
||||
{
|
||||
return this->m_pElementManager->GetFromList( pMonoObject );
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ class CElement;
|
||||
|
||||
#include "CResource.h"
|
||||
#include "CElementManager.h"
|
||||
#include "CMonoFunctions.h"
|
||||
|
||||
enum class eElementType
|
||||
{
|
||||
@ -110,6 +111,8 @@ private:
|
||||
|
||||
eElementType m_iType;
|
||||
|
||||
uint32_t m_uiGCHandle;
|
||||
|
||||
public:
|
||||
CElement ( CElementManager* pManager, MonoObject* pObject, PVOID pUserdata, const CResource* pParent = nullptr );
|
||||
virtual ~CElement ( void );
|
||||
@ -119,6 +122,8 @@ public:
|
||||
void SetTypeName ( const string& strTypeName );
|
||||
const string GetTypeName ( void );
|
||||
|
||||
CElement* GetParent ( void ) const;
|
||||
|
||||
inline MonoObject* ToMonoObject ( void ) const { return this->m_pMonoObject; }
|
||||
inline PVOID ToLuaUserData ( void ) const { return this->m_pLuaUserdata; }
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user