Изменён метод работы с библиотеками. Исправлены ошибки

This commit is contained in:
Kernell 2015-11-28 04:41:37 +03:00
parent 9b0242c67b
commit 31a0c20137
18 changed files with 4118 additions and 4443 deletions

View File

@ -683,11 +683,9 @@ bool CMonoFunctions::Server::OutputChatBox( MonoString* msText, DWORD pElement,
{ {
const char* szText = mono_string_to_utf8( msText ); const char* szText = mono_string_to_utf8( msText );
CMonoObject pColor( mpColor ); unsigned char ucRed = CMonoObject::GetPropertyValue< unsigned char >( mpColor, "R" );
unsigned char ucGreen = CMonoObject::GetPropertyValue< unsigned char >( mpColor, "G" );
unsigned char ucRed = pColor.GetPropertyValue< unsigned char >( "R" ); unsigned char ucBlue = CMonoObject::GetPropertyValue< unsigned char >( mpColor, "B" );
unsigned char ucGreen = pColor.GetPropertyValue< unsigned char >( "G" );
unsigned char ucBlue = pColor.GetPropertyValue< unsigned char >( "B" );
return CLuaFunctionDefinitions::OutputChatBox( RESOURCE->GetLua(), szText, (void*)pElement, ucRed, ucGreen, ucBlue, bColorCoded ); return CLuaFunctionDefinitions::OutputChatBox( RESOURCE->GetLua(), szText, (void*)pElement, ucRed, ucGreen, ucBlue, bColorCoded );
} }
@ -748,12 +746,7 @@ MonoObject* CMonoFunctions::Server::GetVersion( void )
&szSortable &szSortable
}; };
CMonoObject* pObject = RESOURCE->NewObject( "MultiTheftAuto", "ServerVersion", args, 8 ); return RESOURCE->NewObject( "MultiTheftAuto", "ServerVersion", args, 8 );
if( pObject )
{
return pObject->GetObject();
}
} }
} }

View File

@ -27,9 +27,7 @@ bool CMonoFunctions::Audio::PlayMission( DWORD pUserData, MonoObject* pPosition,
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); return CLuaFunctionDefinitions::PlayMissionAudio( RESOURCE->GetLua(), (void*)pUserData, Vector3( pPosition ), usSlot );
return CLuaFunctionDefinitions::PlayMissionAudio( RESOURCE->GetLua(), (void*)pUserData, vecPosition, usSlot );
} }
return false; return false;

View File

@ -17,9 +17,9 @@ DWORD CMonoFunctions::Blip::Create( MonoObject* pPosition, unsigned char ucIcon,
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); Vector3 vecPosition( pPosition );
SColor pColor = CMonoObject( color ).GetColor(); SColor pColor = CMonoObject::GetColor( color );
return (DWORD)CLuaFunctionDefinitions::CreateBlip( RESOURCE->GetLua(), vecPosition, ucIcon, ucSize, pColor, sOrdering, usVisibleDistance, (void*)pVisibleTo ); return (DWORD)CLuaFunctionDefinitions::CreateBlip( RESOURCE->GetLua(), vecPosition, ucIcon, ucSize, pColor, sOrdering, usVisibleDistance, (void*)pVisibleTo );
} }
@ -31,7 +31,7 @@ DWORD CMonoFunctions::Blip::CreateAttachedTo( DWORD pTarget, unsigned char ucIco
{ {
if( RESOURCE ) if( RESOURCE )
{ {
SColor pColor = CMonoObject( color ).GetColor(); SColor pColor = CMonoObject::GetColor( color );
return (DWORD)CLuaFunctionDefinitions::CreateBlipAttachedTo( RESOURCE->GetLua(), (void*)pTarget, ucIcon, ucSize, pColor, sOrdering, usVisibleDistance, (void*)pVisibleTo ); return (DWORD)CLuaFunctionDefinitions::CreateBlipAttachedTo( RESOURCE->GetLua(), (void*)pTarget, ucIcon, ucSize, pColor, sOrdering, usVisibleDistance, (void*)pVisibleTo );
} }
@ -79,12 +79,7 @@ MonoObject* CMonoFunctions::Blip::GetColor( DWORD pUserData )
if( CLuaFunctionDefinitions::GetBlipColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) ) if( CLuaFunctionDefinitions::GetBlipColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( outColor ); return RESOURCE->NewObject( outColor );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -147,9 +142,7 @@ bool CMonoFunctions::Blip::SetColor( DWORD pUserData, MonoObject* color )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
SColor pColor = CMonoObject( color ).GetColor(); return CLuaFunctionDefinitions::SetBlipColor( RESOURCE->GetLua(), (void*)pUserData, CMonoObject::GetColor( color ) );
return CLuaFunctionDefinitions::SetBlipColor( RESOURCE->GetLua(), (void*)pUserData, pColor );
} }
return false; return false;

View File

@ -41,13 +41,7 @@ DWORD CMonoFunctions::Element::Clone( DWORD pUserData, MonoObject* vecPosition,
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( vecPosition ); return (DWORD)CLuaFunctionDefinitions::CloneElement( RESOURCE->GetLua(), (void*)pUserData, Vector3( vecPosition ), bCloneElement );
float fX = pPosition.GetPropertyValue< float >( "X" );
float fY = pPosition.GetPropertyValue< float >( "Y" );
float fZ = pPosition.GetPropertyValue< float >( "Z" );
return (DWORD)CLuaFunctionDefinitions::CloneElement( RESOURCE->GetLua(), (void*)pUserData, Vector3( fX, fY, fZ ), bCloneElement );
} }
return false; return false;
@ -163,12 +157,7 @@ MonoObject* CMonoFunctions::Element::GetPosition( DWORD pUserData )
if( CLuaFunctionDefinitions::GetElementPosition( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) ) if( CLuaFunctionDefinitions::GetElementPosition( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( vecPosition ); return RESOURCE->NewObject( vecPosition );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -183,12 +172,7 @@ MonoObject* CMonoFunctions::Element::GetRotation( DWORD pUserData )
if( CLuaFunctionDefinitions::GetElementRotation( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) ) if( CLuaFunctionDefinitions::GetElementRotation( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( vecPosition ); return RESOURCE->NewObject( vecPosition );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -203,12 +187,7 @@ MonoObject* CMonoFunctions::Element::GetVelocity( DWORD pUserData )
if( CLuaFunctionDefinitions::GetElementVelocity( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) ) if( CLuaFunctionDefinitions::GetElementVelocity( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( vecPosition ); return RESOURCE->NewObject( vecPosition );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -403,12 +382,7 @@ MonoObject* CMonoFunctions::Element::GetAttachedOffsetPosition( DWORD pUserData
if( CLuaFunctionDefinitions::GetElementAttachedOffsets( RESOURCE->GetLua(), (void*)pUserData, vecPosition, vecRotation ) ) if( CLuaFunctionDefinitions::GetElementAttachedOffsets( RESOURCE->GetLua(), (void*)pUserData, vecPosition, vecRotation ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( vecPosition ); return RESOURCE->NewObject( vecPosition );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -423,12 +397,7 @@ MonoObject* CMonoFunctions::Element::GetAttachedOffsetRotation( DWORD pUserData
if( CLuaFunctionDefinitions::GetElementAttachedOffsets( RESOURCE->GetLua(), (void*)pUserData, vecPosition, vecRotation ) ) if( CLuaFunctionDefinitions::GetElementAttachedOffsets( RESOURCE->GetLua(), (void*)pUserData, vecPosition, vecRotation ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( vecRotation ); return RESOURCE->NewObject( vecRotation );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -560,13 +529,7 @@ bool CMonoFunctions::Element::SetPosition( DWORD pUserData, MonoObject* pPositio
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( pPosition ); return CLuaFunctionDefinitions::SetElementPosition( RESOURCE->GetLua(), (void*)pUserData, Vector3( pPosition ), bWarp );
float fX = pPosition.GetPropertyValue< float >( "X" );
float fY = pPosition.GetPropertyValue< float >( "Y" );
float fZ = pPosition.GetPropertyValue< float >( "Z" );
return CLuaFunctionDefinitions::SetElementPosition( RESOURCE->GetLua(), (void*)pUserData, Vector3( fX, fY, fZ ), bWarp );
} }
return false; return false;
@ -576,15 +539,9 @@ bool CMonoFunctions::Element::SetRotation( DWORD pUserData, MonoObject* pRotatio
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( pRotation );
float fX = pPosition.GetPropertyValue<float>( "X" );
float fY = pPosition.GetPropertyValue<float>( "Y" );
float fZ = pPosition.GetPropertyValue<float>( "Z" );
const char* szRotationOrder = mono_string_to_utf8( msRotationOrder ); const char* szRotationOrder = mono_string_to_utf8( msRotationOrder );
return CLuaFunctionDefinitions::SetElementRotation( RESOURCE->GetLua(), (void*)pUserData, Vector3( fX, fY, fZ ), szRotationOrder, bNewWay ); return CLuaFunctionDefinitions::SetElementRotation( RESOURCE->GetLua(), (void*)pUserData, Vector3( pRotation ), szRotationOrder, bNewWay );
} }
return false; return false;
@ -594,13 +551,7 @@ bool CMonoFunctions::Element::SetVelocity( DWORD pUserData, MonoObject* pVelocit
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( pVelocity ); return CLuaFunctionDefinitions::SetElementVelocity( RESOURCE->GetLua(), (void*)pUserData, Vector3( pVelocity ) );
float fX = pPosition.GetPropertyValue<float>( "X" );
float fY = pPosition.GetPropertyValue<float>( "Y" );
float fZ = pPosition.GetPropertyValue<float>( "Z" );
return CLuaFunctionDefinitions::SetElementVelocity( RESOURCE->GetLua(), (void*)pUserData, Vector3( fX, fY, fZ ) );
} }
return false; return false;
@ -641,18 +592,8 @@ bool CMonoFunctions::Element::Attach( DWORD pUserData, DWORD pTarget, MonoObject
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 Vector3
vecPosition, vecRotation; vecPosition( pMonoPosition ),
vecRotation( pMonoRotation );
CMonoObject
pPosition( pMonoPosition ), pRotation( pMonoRotation );
vecPosition.fX = pPosition.GetPropertyValue<float>( "X" );
vecPosition.fY = pPosition.GetPropertyValue<float>( "Y" );
vecPosition.fZ = pPosition.GetPropertyValue<float>( "Z" );
vecRotation.fX = pRotation.GetPropertyValue<float>( "X" );
vecRotation.fY = pRotation.GetPropertyValue<float>( "Y" );
vecRotation.fZ = pRotation.GetPropertyValue<float>( "Z" );
return CLuaFunctionDefinitions::AttachElements( RESOURCE->GetLua(), (void*)pUserData, (void*)pTarget, vecPosition, vecRotation ); return CLuaFunctionDefinitions::AttachElements( RESOURCE->GetLua(), (void*)pUserData, (void*)pTarget, vecPosition, vecRotation );
} }
@ -715,18 +656,8 @@ bool CMonoFunctions::Element::SetAttachedOffsets( DWORD pUserData, MonoObject* p
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 Vector3
vecPosition, vecRotation; vecPosition( pMonoPosition ),
vecRotation( pMonoRotation );
CMonoObject
pPosition( pMonoPosition ), pRotation( pMonoRotation );
vecPosition.fX = pPosition.GetPropertyValue<float>( "X" );
vecPosition.fY = pPosition.GetPropertyValue<float>( "Y" );
vecPosition.fZ = pPosition.GetPropertyValue<float>( "Z" );
vecRotation.fX = pRotation.GetPropertyValue<float>( "X" );
vecRotation.fY = pRotation.GetPropertyValue<float>( "Y" );
vecRotation.fZ = pRotation.GetPropertyValue<float>( "Z" );
return CLuaFunctionDefinitions::SetElementAttachedOffsets( RESOURCE->GetLua(), (void*)pUserData, vecPosition, vecRotation ); return CLuaFunctionDefinitions::SetElementAttachedOffsets( RESOURCE->GetLua(), (void*)pUserData, vecPosition, vecRotation );
} }

View File

@ -17,9 +17,7 @@ bool CMonoFunctions::Explosion::Create( MonoObject* pPosition, unsigned char ucT
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); return (DWORD)CLuaFunctionDefinitions::CreateExplosion( RESOURCE->GetLua(), Vector3( pPosition ), ucType, (void*)pCreator );
return (DWORD)CLuaFunctionDefinitions::CreateExplosion( RESOURCE->GetLua(), vecPosition, ucType, (void*)pCreator );
} }
return NULL; return NULL;

View File

@ -17,26 +17,9 @@ DWORD CMonoFunctions::Marker::Create( MonoObject* pPosition, MonoString* msType,
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( pPosition );
float fX = pPosition.GetPropertyValue< float >( "X" );
float fY = pPosition.GetPropertyValue< float >( "Y" );
float fZ = pPosition.GetPropertyValue< float >( "Z" );
Vector3 vecPosition( fX, fY, fZ );
const char* szType = mono_string_to_utf8( msType ); const char* szType = mono_string_to_utf8( msType );
CMonoObject pMonoColor( pColor ); return (DWORD)CLuaFunctionDefinitions::CreateMarker( RESOURCE->GetLua(), Vector3( pPosition ), szType, fSize, CMonoObject::GetColor( pColor ), (void*)pVisibleTo );
SColor pColor;
pColor.R = pMonoColor.GetPropertyValue< unsigned char >( "R" );
pColor.G = pMonoColor.GetPropertyValue< unsigned char >( "G" );
pColor.B = pMonoColor.GetPropertyValue< unsigned char >( "B" );
pColor.A = pMonoColor.GetPropertyValue< unsigned char >( "A" );
return (DWORD)CLuaFunctionDefinitions::CreateMarker( RESOURCE->GetLua(), vecPosition, szType, fSize, pColor, (void*)pVisibleTo );
} }
return NULL; return NULL;
@ -97,12 +80,7 @@ MonoObject* CMonoFunctions::Marker::GetColor( DWORD pUserData )
if( CLuaFunctionDefinitions::GetMarkerColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) ) if( CLuaFunctionDefinitions::GetMarkerColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( outColor ); return RESOURCE->NewObject( outColor );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -117,12 +95,7 @@ MonoObject* CMonoFunctions::Marker::GetTarget( DWORD pUserData )
if( CLuaFunctionDefinitions::GetMarkerTarget( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) ) if( CLuaFunctionDefinitions::GetMarkerTarget( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( vecPosition ); return RESOURCE->NewObject( vecPosition );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -168,20 +141,11 @@ bool CMonoFunctions::Marker::SetSize( DWORD pUserData, float fSize )
return false; return false;
} }
bool CMonoFunctions::Marker::SetColor( DWORD pUserData, MonoObject* color ) bool CMonoFunctions::Marker::SetColor( DWORD pUserData, MonoObject* pColor )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
SColor pColor; return CLuaFunctionDefinitions::SetMarkerColor( RESOURCE->GetLua(), (void*)pUserData, CMonoObject::GetColor( pColor ) );
CMonoObject pMonoColor( color );
pColor.R = pMonoColor.GetPropertyValue< unsigned char >( "R" );
pColor.G = pMonoColor.GetPropertyValue< unsigned char >( "G" );
pColor.B = pMonoColor.GetPropertyValue< unsigned char >( "B" );
pColor.A = pMonoColor.GetPropertyValue< unsigned char >( "A" );
return CLuaFunctionDefinitions::SetMarkerColor( RESOURCE->GetLua(), (void*)pUserData, pColor );
} }
return false; return false;
@ -191,15 +155,7 @@ bool CMonoFunctions::Marker::SetTarget( DWORD pUserData, MonoObject* pTarget )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3* vecPosition = new Vector3; return CLuaFunctionDefinitions::SetMarkerTarget( RESOURCE->GetLua(), (void*)pUserData, Vector3( pTarget ) );
CMonoObject pTarget( pTarget );
vecPosition->fX = pTarget.GetPropertyValue< float >( "X" );
vecPosition->fY = pTarget.GetPropertyValue< float >( "Y" );
vecPosition->fZ = pTarget.GetPropertyValue< float >( "Z" );
return CLuaFunctionDefinitions::SetMarkerTarget( RESOURCE->GetLua(), (void*)pUserData, vecPosition );
} }
return false; return false;

View File

@ -17,21 +17,8 @@ DWORD CMonoFunctions::Object::Create( unsigned short usModelID, MonoObject* pPos
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( pPosition ); Vector3 vecPosition( pPosition );
Vector3 vecRotation( pRotation );
float fX = pPosition.GetPropertyValue< float >( "X" );
float fY = pPosition.GetPropertyValue< float >( "Y" );
float fZ = pPosition.GetPropertyValue< float >( "Z" );
Vector3 vecPosition( fX, fY, fZ );
CMonoObject pRotation( pRotation );
float fRX = pRotation.GetPropertyValue< float >( "X" );
float fRY = pRotation.GetPropertyValue< float >( "Y" );
float fRZ = pRotation.GetPropertyValue< float >( "Z" );
Vector3 vecRotation( fRX, fRY, fRZ );
return (DWORD)CLuaFunctionDefinitions::CreateObject( RESOURCE->GetLua(), usModelID, vecPosition, vecRotation, bIsLowLod ); return (DWORD)CLuaFunctionDefinitions::CreateObject( RESOURCE->GetLua(), usModelID, vecPosition, vecRotation, bIsLowLod );
} }
@ -49,12 +36,7 @@ MonoObject* CMonoFunctions::Object::GetScale( DWORD pUserData )
if( CLuaFunctionDefinitions::GetObjectScale( RESOURCE->GetLua(), (void*)pUserData, vecScale ) ) if( CLuaFunctionDefinitions::GetObjectScale( RESOURCE->GetLua(), (void*)pUserData, vecScale ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( vecScale ); return RESOURCE->NewObject( vecScale );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -67,15 +49,7 @@ bool CMonoFunctions::Object::SetScale( DWORD pUserData, MonoObject* pScale )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecScale; return CLuaFunctionDefinitions::SetObjectScale( RESOURCE->GetLua(), (void*)pUserData, Vector3( pScale ) );
CMonoObject pScale( pScale );
vecScale.fX = pScale.GetPropertyValue< float >( "X" );
vecScale.fY = pScale.GetPropertyValue< float >( "Y" );
vecScale.fZ = pScale.GetPropertyValue< float >( "Z" );
return CLuaFunctionDefinitions::SetObjectScale( RESOURCE->GetLua(), (void*)pUserData, vecScale );
} }
return false; return false;
@ -85,19 +59,9 @@ bool CMonoFunctions::Object::Move( DWORD pUserData, unsigned long ulTime, MonoOb
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecPosition, vecRotation; Vector3
vecPosition( pPosition ),
CMonoObject pPosition( pPosition ); vecRotation( pRotation );
vecPosition.fX = pPosition.GetPropertyValue< float >( "X" );
vecPosition.fY = pPosition.GetPropertyValue< float >( "Y" );
vecPosition.fZ = pPosition.GetPropertyValue< float >( "Z" );
CMonoObject pRotation( pRotation );
vecRotation.fX = pRotation.GetPropertyValue< float >( "X" );
vecRotation.fY = pRotation.GetPropertyValue< float >( "Y" );
vecRotation.fZ = pRotation.GetPropertyValue< float >( "Z" );
const char* szEasingType = mono_string_to_utf8( msEasingType ); const char* szEasingType = mono_string_to_utf8( msEasingType );

View File

@ -20,13 +20,7 @@ DWORD CMonoFunctions::Ped::Create( int iModelid, MonoObject* pMonoPosition, floa
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( pMonoPosition ); Vector3 vecPosition( pMonoPosition );
float fX = pPosition.GetPropertyValue< float >( "X" );
float fY = pPosition.GetPropertyValue< float >( "Y" );
float fZ = pPosition.GetPropertyValue< float >( "Z" );
Vector3 vecPosition( fX, fY, fZ );
return (DWORD)CLuaFunctionDefinitions::CreatePed( RESOURCE->GetLua(), iModelid, vecPosition, fRot, bSynced ); return (DWORD)CLuaFunctionDefinitions::CreatePed( RESOURCE->GetLua(), iModelid, vecPosition, fRot, bSynced );
} }

View File

@ -17,13 +17,7 @@ DWORD CMonoFunctions::Pickup::Create( MonoObject* pPosition, unsigned char ucTyp
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( pPosition ); Vector3 vecPosition( pPosition );
float fX = pPosition.GetPropertyValue< float >( "X" );
float fY = pPosition.GetPropertyValue< float >( "Y" );
float fZ = pPosition.GetPropertyValue< float >( "Z" );
Vector3 vecPosition( fX, fY, fZ );
return (DWORD)CLuaFunctionDefinitions::CreatePickup( RESOURCE->GetLua(), vecPosition, ucType, dFive, ulRespawnInterval, dSix ); return (DWORD)CLuaFunctionDefinitions::CreatePickup( RESOURCE->GetLua(), vecPosition, ucType, dFive, ulRespawnInterval, dSix );
} }

View File

@ -224,12 +224,7 @@ MonoObject* CMonoFunctions::Player::GetNametagColor( DWORD pUserData )
&ucR, &ucG, &ucB &ucR, &ucG, &ucB
}; };
CMonoObject* pObject = RESOURCE->NewObject( "MultiTheftAuto", "Color", args, 3 ); return RESOURCE->NewObject( "MultiTheftAuto", "Color", args, 3 );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -358,12 +353,7 @@ MonoObject* CMonoFunctions::Player::GetACInfo( DWORD pUserData )
&msD3D9SHA256 &msD3D9SHA256
}; };
CMonoObject* pObject = RESOURCE->NewObject( "MultiTheftAuto", "PlayerACInfo", args, 4 ); return RESOURCE->NewObject( "MultiTheftAuto", "PlayerACInfo", args, 4 );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
return NULL; return NULL;
@ -417,13 +407,7 @@ bool CMonoFunctions::Player::Spawn( DWORD pUserData, MonoObject* pPosition, int
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( pPosition ); Vector3 vecPosition( pPosition );
float fX = pPosition.GetPropertyValue< float >( "X" );
float fY = pPosition.GetPropertyValue< float >( "Y" );
float fZ = pPosition.GetPropertyValue< float >( "Z" );
Vector3 vecPosition( fX, fY, fZ );
return CLuaFunctionDefinitions::SpawnPlayer( RESOURCE->GetLua(), (void*)pUserData, vecPosition, iRotation, iSkinID, iInterior, iDimension, (void*)pTeam ); return CLuaFunctionDefinitions::SpawnPlayer( RESOURCE->GetLua(), (void*)pUserData, vecPosition, iRotation, iSkinID, iInterior, iDimension, (void*)pTeam );
} }
@ -801,12 +785,7 @@ MonoObject* CMonoFunctions::Player::GetCameraMatrix( DWORD pPlayer )
&fFOV &fFOV
}; };
CMonoObject* pObject = RESOURCE->NewObject( "MultiTheftAuto", "CameraMatrix", args, 8 ); return RESOURCE->NewObject( "MultiTheftAuto", "CameraMatrix", args, 8 );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -844,22 +823,20 @@ bool CMonoFunctions::Player::SetCameraMatrix( DWORD pPlayer, MonoObject* pCamera
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pCameraMatrix( pCameraMatrix ); float fX = CMonoObject::GetPropertyValue< float >( pCameraMatrix, "X" );
float fY = CMonoObject::GetPropertyValue< float >( pCameraMatrix, "Y" );
float fX = pCameraMatrix.GetPropertyValue< float >( "X" ); float fZ = CMonoObject::GetPropertyValue< float >( pCameraMatrix, "Z" );
float fY = pCameraMatrix.GetPropertyValue< float >( "Y" );
float fZ = pCameraMatrix.GetPropertyValue< float >( "Z" );
Vector3 vecPosition( fX, fY, fZ ); Vector3 vecPosition( fX, fY, fZ );
float fLookAtX = pCameraMatrix.GetPropertyValue< float >( "LookAtX" ); float fLookAtX = CMonoObject::GetPropertyValue< float >( pCameraMatrix, "LookAtX" );
float fLookAtY = pCameraMatrix.GetPropertyValue< float >( "LookAtY" ); float fLookAtY = CMonoObject::GetPropertyValue< float >( pCameraMatrix, "LookAtY" );
float fLookAtZ = pCameraMatrix.GetPropertyValue< float >( "LookAtZ" ); float fLookAtZ = CMonoObject::GetPropertyValue< float >( pCameraMatrix, "LookAtZ" );
Vector3* vecLookAt = new Vector3( fLookAtX, fLookAtY, fLookAtZ ); Vector3 vecLookAt( fLookAtX, fLookAtY, fLookAtZ );
float fRoll = pCameraMatrix.GetPropertyValue< float >( "Roll" ); float fRoll = CMonoObject::GetPropertyValue< float >( pCameraMatrix, "Roll" );
float fFOV = pCameraMatrix.GetPropertyValue< float >( "FOV" ); float fFOV = CMonoObject::GetPropertyValue< float >( pCameraMatrix, "FOV" );
return CLuaFunctionDefinitions::SetCameraMatrix( RESOURCE->GetLua(), (void*)pPlayer, vecPosition, vecLookAt, fRoll, fFOV ); return CLuaFunctionDefinitions::SetCameraMatrix( RESOURCE->GetLua(), (void*)pPlayer, vecPosition, vecLookAt, fRoll, fFOV );
} }
@ -891,11 +868,9 @@ bool CMonoFunctions::Player::FadeCamera( DWORD pPlayer, bool bFadeIn, float fFad
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pColor( pColor ); unsigned char ucReed = CMonoObject::GetPropertyValue< unsigned char >( pColor, "R" );
unsigned char ucGreen = CMonoObject::GetPropertyValue< unsigned char >( pColor, "G" );
unsigned char ucReed = pColor.GetPropertyValue< unsigned char >( "R" ); unsigned char ucBlue = CMonoObject::GetPropertyValue< unsigned char >( pColor, "B" );
unsigned char ucGreen = pColor.GetPropertyValue< unsigned char >( "G" );
unsigned char ucBlue = pColor.GetPropertyValue< unsigned char >( "B" );
return CLuaFunctionDefinitions::FadeCamera( RESOURCE->GetLua(), (void*)pPlayer, bFadeIn, fFadeTime, ucReed, ucGreen, ucBlue ); return CLuaFunctionDefinitions::FadeCamera( RESOURCE->GetLua(), (void*)pPlayer, bFadeIn, fFadeTime, ucReed, ucGreen, ucBlue );
} }

View File

@ -17,26 +17,9 @@ DWORD CMonoFunctions::RadarArea::Create( MonoObject* pPosition, MonoObject* pSiz
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector2 vecPosition, vecSize; Vector2 vecPosition( pPosition );
Vector2 vecSize( pSize );
CMonoObject pPosition( pPosition ); SColor pColor = CMonoObject::GetColor( color );
vecPosition.fX = pPosition.GetPropertyValue< float >( "X" );
vecPosition.fY = pPosition.GetPropertyValue< float >( "Y" );
CMonoObject pSize( pSize );
vecSize.fX = pSize.GetPropertyValue< float >( "X" );
vecSize.fY = pSize.GetPropertyValue< float >( "Y" );
CMonoObject pMonoColor( color );
SColor pColor;
pColor.R = pMonoColor.GetPropertyValue< unsigned char >( "R" );
pColor.G = pMonoColor.GetPropertyValue< unsigned char >( "G" );
pColor.B = pMonoColor.GetPropertyValue< unsigned char >( "B" );
pColor.A = pMonoColor.GetPropertyValue< unsigned char >( "A" );
return (DWORD)CLuaFunctionDefinitions::CreateRadarArea( RESOURCE->GetLua(), vecPosition, vecSize, pColor, (void*)pVisibleTo ); return (DWORD)CLuaFunctionDefinitions::CreateRadarArea( RESOURCE->GetLua(), vecPosition, vecSize, pColor, (void*)pVisibleTo );
} }
@ -54,12 +37,7 @@ MonoObject* CMonoFunctions::RadarArea::GetSize( DWORD pUserData )
if( CLuaFunctionDefinitions::GetRadarAreaSize( RESOURCE->GetLua(), (void*)pUserData, vecSize ) ) if( CLuaFunctionDefinitions::GetRadarAreaSize( RESOURCE->GetLua(), (void*)pUserData, vecSize ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( vecSize ); return RESOURCE->NewObject( vecSize );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -74,12 +52,7 @@ MonoObject* CMonoFunctions::RadarArea::GetColor( DWORD pUserData )
if( CLuaFunctionDefinitions::GetRadarAreaColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) ) if( CLuaFunctionDefinitions::GetRadarAreaColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( outColor ); return RESOURCE->NewObject( outColor );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -102,10 +75,8 @@ bool CMonoFunctions::RadarArea::IsInside( DWORD pUserData, MonoObject* pPosition
{ {
bool bInside; bool bInside;
CMonoObject pPosition( pPosition ); float fX = CMonoObject::GetPropertyValue< float >( pPosition, "X" );
float fY = CMonoObject::GetPropertyValue< float >( pPosition, "Y" );
float fX = pPosition.GetPropertyValue< float >( "X" );
float fY = pPosition.GetPropertyValue< float >( "Y" );
Vector2 vecPosition( fX, fY ); Vector2 vecPosition( fX, fY );
@ -124,10 +95,8 @@ bool CMonoFunctions::RadarArea::SetSize( DWORD pUserData, MonoObject* pSize )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pSize( pSize ); float fX = CMonoObject::GetPropertyValue< float >( pSize, "X" );
float fY = CMonoObject::GetPropertyValue< float >( pSize, "Y" );
float fX = pSize.GetPropertyValue< float >( "X" );
float fY = pSize.GetPropertyValue< float >( "Y" );
Vector2 vecPosition( fX, fY ); Vector2 vecPosition( fX, fY );
@ -141,14 +110,7 @@ bool CMonoFunctions::RadarArea::SetColor( DWORD pUserData, MonoObject* color )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
SColor pColor; SColor pColor = CMonoObject::GetColor( color );
CMonoObject pObject( color );
pColor.R = pObject.GetPropertyValue< unsigned char >( "R" );
pColor.G = pObject.GetPropertyValue< unsigned char >( "G" );
pColor.B = pObject.GetPropertyValue< unsigned char >( "B" );
pColor.A = pObject.GetPropertyValue< unsigned char >( "A" );
return CLuaFunctionDefinitions::SetRadarAreaColor( RESOURCE->GetLua(), (void*)pUserData, pColor ); return CLuaFunctionDefinitions::SetRadarAreaColor( RESOURCE->GetLua(), (void*)pUserData, pColor );
} }

View File

@ -17,7 +17,7 @@ DWORD CMonoFunctions::Shape::CreateCircle( MonoObject* pPosition, float fRadius
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector2 vecPosition = CMonoObject( pPosition ).GetVector2(); Vector2 vecPosition( pPosition );
return (DWORD)CLuaFunctionDefinitions::CreateColCircle( RESOURCE->GetLua(), vecPosition, fRadius ); return (DWORD)CLuaFunctionDefinitions::CreateColCircle( RESOURCE->GetLua(), vecPosition, fRadius );
} }
@ -29,8 +29,8 @@ DWORD CMonoFunctions::Shape::CreateCuboid( MonoObject* pPosition, MonoObject* pS
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); Vector3 vecPosition( pPosition );
Vector3 vecSize = CMonoObject( pSize ).GetVector3(); Vector3 vecSize( pSize );
return (DWORD)CLuaFunctionDefinitions::CreateColCuboid( RESOURCE->GetLua(), vecPosition, vecSize ); return (DWORD)CLuaFunctionDefinitions::CreateColCuboid( RESOURCE->GetLua(), vecPosition, vecSize );
} }
@ -42,7 +42,7 @@ DWORD CMonoFunctions::Shape::CreateSphere( MonoObject* pPosition, float fRadius
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); Vector3 vecPosition( pPosition );
return (DWORD)CLuaFunctionDefinitions::CreateColSphere( RESOURCE->GetLua(), vecPosition, fRadius ); return (DWORD)CLuaFunctionDefinitions::CreateColSphere( RESOURCE->GetLua(), vecPosition, fRadius );
} }
@ -54,8 +54,8 @@ DWORD CMonoFunctions::Shape::CreateRectangle( MonoObject* pPosition, MonoObject*
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector2 vecPosition = CMonoObject( pPosition ).GetVector2(); Vector2 vecPosition( pPosition );
Vector2 vecSize = CMonoObject( pSize ).GetVector2(); Vector2 vecSize( pSize );
return (DWORD)CLuaFunctionDefinitions::CreateColRectangle( RESOURCE->GetLua(), vecPosition, vecSize ); return (DWORD)CLuaFunctionDefinitions::CreateColRectangle( RESOURCE->GetLua(), vecPosition, vecSize );
} }
@ -75,9 +75,7 @@ DWORD CMonoFunctions::Shape::CreatePolygon( MonoArray* pPointList )
if( pObject ) if( pObject )
{ {
Vector2 vecPosition = CMonoObject( pObject ).GetVector2(); vecPointList.push_back( Vector2( pObject ) );
vecPointList.push_back( vecPosition );
} }
} }
@ -91,7 +89,7 @@ DWORD CMonoFunctions::Shape::CreateTube( MonoObject* pPosition, float fRadius, f
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); Vector3 vecPosition( pPosition );
return (DWORD)CLuaFunctionDefinitions::CreateColTube( RESOURCE->GetLua(), vecPosition, fRadius, fHeight ); return (DWORD)CLuaFunctionDefinitions::CreateColTube( RESOURCE->GetLua(), vecPosition, fRadius, fHeight );
} }

View File

@ -18,7 +18,7 @@ DWORD CMonoFunctions::Team::Create( MonoString* msTeamName, MonoObject* mColor )
if( RESOURCE ) if( RESOURCE )
{ {
const char* szTeamName = mono_string_to_utf8( msTeamName ); const char* szTeamName = mono_string_to_utf8( msTeamName );
SColor pColor = CMonoObject( mColor ).GetColor(); SColor pColor = CMonoObject::GetColor( mColor );
return (DWORD)CLuaFunctionDefinitions::CreateTeam( RESOURCE->GetLua(), szTeamName, pColor.R, pColor.G, pColor.B ); return (DWORD)CLuaFunctionDefinitions::CreateTeam( RESOURCE->GetLua(), szTeamName, pColor.R, pColor.G, pColor.B );
} }
@ -61,12 +61,7 @@ MonoObject* CMonoFunctions::Team::GetColor( DWORD pUserData )
if( CLuaFunctionDefinitions::GetTeamColor( RESOURCE->GetLua(), (void*)pUserData, pColor.R, pColor.G, pColor.B ) ) if( CLuaFunctionDefinitions::GetTeamColor( RESOURCE->GetLua(), (void*)pUserData, pColor.R, pColor.G, pColor.B ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( pColor ); return RESOURCE->NewObject( pColor );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -121,7 +116,7 @@ bool CMonoFunctions::Team::SetColor( DWORD pUserData, MonoObject* mColor )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
SColor pColor = CMonoObject( mColor ).GetColor(); SColor pColor = CMonoObject::GetColor( mColor );
return CLuaFunctionDefinitions::SetTeamColor( RESOURCE->GetLua(), (void*)pUserData, pColor.R, pColor.G, pColor.B ); return CLuaFunctionDefinitions::SetTeamColor( RESOURCE->GetLua(), (void*)pUserData, pColor.R, pColor.G, pColor.B );
} }

View File

@ -17,17 +17,13 @@ DWORD CMonoFunctions::Vehicle::Create( int model, MonoObject* position, MonoObje
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( position ); float fX = CMonoObject::GetPropertyValue< float >( position, "X" );
float fY = CMonoObject::GetPropertyValue< float >( position, "Y" );
float fZ = CMonoObject::GetPropertyValue< float >( position, "Z" );
float fX = pPosition.GetPropertyValue< float >( "X" ); float fRX = CMonoObject::GetPropertyValue< float >( rotation, "X" );
float fY = pPosition.GetPropertyValue< float >( "Y" ); float fRY = CMonoObject::GetPropertyValue< float >( rotation, "Y" );
float fZ = pPosition.GetPropertyValue< float >( "Z" ); float fRZ = CMonoObject::GetPropertyValue< float >( rotation, "Z" );
CMonoObject pRotation( rotation );
float fRX = pRotation.GetPropertyValue< float >( "X" );
float fRY = pRotation.GetPropertyValue< float >( "Y" );
float fRZ = pRotation.GetPropertyValue< float >( "Z" );
string sNumberplate = ""; string sNumberplate = "";
@ -103,12 +99,7 @@ MonoObject* CMonoFunctions::Vehicle::GetColor( DWORD pUserData )
&pColor4 &pColor4
}; };
CMonoObject* pObject = RESOURCE->NewObject( "MultiTheftAuto", "VehicleColor", args, 4 ); return RESOURCE->NewObject( "MultiTheftAuto", "VehicleColor", args, 4 );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -247,12 +238,7 @@ MonoObject* CMonoFunctions::Vehicle::GetTurnVelocity( DWORD pUserData )
if( CLuaFunctionDefinitions::GetVehicleTurnVelocity( RESOURCE->GetLua(), (void*)pUserData, vecVelocity ) ) if( CLuaFunctionDefinitions::GetVehicleTurnVelocity( RESOURCE->GetLua(), (void*)pUserData, vecVelocity ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( vecVelocity ); return RESOURCE->NewObject( vecVelocity );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -267,12 +253,7 @@ MonoObject* CMonoFunctions::Vehicle::GetTurretPosition( DWORD pUserData )
if( CLuaFunctionDefinitions::GetVehicleTurretPosition( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) ) if( CLuaFunctionDefinitions::GetVehicleTurretPosition( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( vecPosition ); return RESOURCE->NewObject( vecPosition );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -388,12 +369,7 @@ MonoObject* CMonoFunctions::Vehicle::GetWheelStates( DWORD pUserData )
&ucFrontLeft, &ucRearLeft, &ucFrontRight, &ucRearRight &ucFrontLeft, &ucRearLeft, &ucFrontRight, &ucRearRight
}; };
CMonoObject* pObject = RESOURCE->NewObject( "MultiTheftAuto.Vehicle", "VehicleWheelsState", args, 4 ); return RESOURCE->NewObject( "MultiTheftAuto.Vehicle", "VehicleWheelsState", args, 4 );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -648,12 +624,7 @@ MonoObject* CMonoFunctions::Vehicle::GetHeadLightColor( DWORD pUserData )
if( CLuaFunctionDefinitions::GetVehicleHeadLightColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) ) if( CLuaFunctionDefinitions::GetVehicleHeadLightColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) )
{ {
CMonoObject* pMonoObject = RESOURCE->NewObject( outColor ); return RESOURCE->NewObject( outColor );
if( pMonoObject )
{
return pMonoObject->GetObject();
}
} }
} }
@ -716,11 +687,9 @@ bool CMonoFunctions::Vehicle::SetTurnVelocity( DWORD pUserData, MonoObject* pVel
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pVelocity( pVelocity ); float fX = CMonoObject::GetPropertyValue< float >( pVelocity, "X" );
float fY = CMonoObject::GetPropertyValue< float >( pVelocity, "Y" );
float fX = pVelocity.GetPropertyValue< float >( "X" ); float fZ = CMonoObject::GetPropertyValue< float >( pVelocity, "Z" );
float fY = pVelocity.GetPropertyValue< float >( "Y" );
float fZ = pVelocity.GetPropertyValue< float >( "Z" );
return CLuaFunctionDefinitions::SetVehicleTurnVelocity( RESOURCE->GetLua(), (void*)pUserData, fX, fY, fZ ); return CLuaFunctionDefinitions::SetVehicleTurnVelocity( RESOURCE->GetLua(), (void*)pUserData, fX, fY, fZ );
} }
@ -732,29 +701,21 @@ bool CMonoFunctions::Vehicle::SetColor( DWORD pUserData, MonoObject* pColor1, Mo
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pColor1( pColor1 ); unsigned char ucR1 = CMonoObject::GetPropertyValue< unsigned char >( pColor1, "R" );
unsigned char ucG1 = CMonoObject::GetPropertyValue< unsigned char >( pColor1, "G" );
unsigned char ucB1 = CMonoObject::GetPropertyValue< unsigned char >( pColor1, "B" );
unsigned char ucR1 = pColor1.GetPropertyValue< unsigned char >( "R" ); unsigned char ucR2 = CMonoObject::GetPropertyValue< unsigned char >( pColor2, "R" );
unsigned char ucG1 = pColor1.GetPropertyValue< unsigned char >( "G" ); unsigned char ucG2 = CMonoObject::GetPropertyValue< unsigned char >( pColor2, "G" );
unsigned char ucB1 = pColor1.GetPropertyValue< unsigned char >( "B" ); unsigned char ucB2 = CMonoObject::GetPropertyValue< unsigned char >( pColor2, "B" );
CMonoObject pColor2( pColor2 ); unsigned char ucR3 = CMonoObject::GetPropertyValue< unsigned char >( pColor3, "R" );
unsigned char ucG3 = CMonoObject::GetPropertyValue< unsigned char >( pColor3, "G" );
unsigned char ucB3 = CMonoObject::GetPropertyValue< unsigned char >( pColor3, "B" );
unsigned char ucR2 = pColor2.GetPropertyValue< unsigned char >( "R" ); unsigned char ucR4 = CMonoObject::GetPropertyValue< unsigned char >( pColor4, "R" );
unsigned char ucG2 = pColor2.GetPropertyValue< unsigned char >( "G" ); unsigned char ucG4 = CMonoObject::GetPropertyValue< unsigned char >( pColor4, "G" );
unsigned char ucB2 = pColor2.GetPropertyValue< unsigned char >( "B" ); unsigned char ucB4 = CMonoObject::GetPropertyValue< unsigned char >( pColor4, "B" );
CMonoObject pColor3( pColor3 );
unsigned char ucR3 = pColor3.GetPropertyValue< unsigned char >( "R" );
unsigned char ucG3 = pColor3.GetPropertyValue< unsigned char >( "G" );
unsigned char ucB3 = pColor3.GetPropertyValue< unsigned char >( "B" );
CMonoObject pColor4( pColor4 );
unsigned char ucR4 = pColor4.GetPropertyValue< unsigned char >( "R" );
unsigned char ucG4 = pColor4.GetPropertyValue< unsigned char >( "G" );
unsigned char ucB4 = pColor4.GetPropertyValue< unsigned char >( "B" );
return CLuaFunctionDefinitions::SetVehicleColor( RESOURCE->GetLua(), (void*)pUserData, ucR1, ucG1, ucB1, ucR2, ucG2, ucB2, ucR3, ucG3, ucB3, ucR4, ucG4, ucB4 ); return CLuaFunctionDefinitions::SetVehicleColor( RESOURCE->GetLua(), (void*)pUserData, ucR1, ucG1, ucB1, ucR2, ucG2, ucB2, ucR3, ucG3, ucB3, ucR4, ucG4, ucB4 );
} }
@ -896,17 +857,13 @@ bool CMonoFunctions::Vehicle::SetRespawnPosition( DWORD pUserData, MonoObject* p
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( pPosition ); float fX = CMonoObject::GetPropertyValue< float >( pPosition, "X" );
float fY = CMonoObject::GetPropertyValue< float >( pPosition, "Y" );
float fZ = CMonoObject::GetPropertyValue< float >( pPosition, "Z" );
float fX = pPosition.GetPropertyValue< float >( "X" ); float fRX = CMonoObject::GetPropertyValue< float >( pRotation, "X" );
float fY = pPosition.GetPropertyValue< float >( "X" ); float fRY = CMonoObject::GetPropertyValue< float >( pRotation, "Y" );
float fZ = pPosition.GetPropertyValue< float >( "X" ); float fRZ = CMonoObject::GetPropertyValue< float >( pRotation, "Z" );
CMonoObject pRotation( pRotation );
float fRX = pRotation.GetPropertyValue< float >( "X" );
float fRY = pRotation.GetPropertyValue< float >( "X" );
float fRZ = pRotation.GetPropertyValue< float >( "X" );
return CLuaFunctionDefinitions::SetVehicleRespawnPosition( RESOURCE->GetLua(), (void*)pUserData, fX, fY, fZ, fRX, fRY, fRZ ); return CLuaFunctionDefinitions::SetVehicleRespawnPosition( RESOURCE->GetLua(), (void*)pUserData, fX, fY, fZ, fRX, fRY, fRZ );
} }
@ -948,17 +905,13 @@ bool CMonoFunctions::Vehicle::Spawn( DWORD pUserData, MonoObject* pPosition, Mon
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( pPosition ); float fX = CMonoObject::GetPropertyValue< float >( pPosition, "X" );
float fY = CMonoObject::GetPropertyValue< float >( pPosition, "Y" );
float fZ = CMonoObject::GetPropertyValue< float >( pPosition, "Z" );
float fX = pPosition.GetPropertyValue< float >( "X" ); float fRX = CMonoObject::GetPropertyValue< float >( pRotation, "X" );
float fY = pPosition.GetPropertyValue< float >( "X" ); float fRY = CMonoObject::GetPropertyValue< float >( pRotation, "Y" );
float fZ = pPosition.GetPropertyValue< float >( "X" ); float fRZ = CMonoObject::GetPropertyValue< float >( pRotation, "Z" );
CMonoObject pRotation( pRotation );
float fRX = pRotation.GetPropertyValue< float >( "X" );
float fRY = pRotation.GetPropertyValue< float >( "X" );
float fRZ = pRotation.GetPropertyValue< float >( "X" );
return CLuaFunctionDefinitions::SpawnVehicle( RESOURCE->GetLua(), (void*)pUserData, fX, fY, fZ, fRX, fRY, fRZ ); return CLuaFunctionDefinitions::SpawnVehicle( RESOURCE->GetLua(), (void*)pUserData, fX, fY, fZ, fRX, fRY, fRZ );
} }
@ -1100,11 +1053,9 @@ bool CMonoFunctions::Vehicle::SetHeadLightColor( DWORD pUserData, MonoObject* pC
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pColor1( pColor ); unsigned char ucR1 = CMonoObject::GetPropertyValue< unsigned char >( pColor, "R" );
unsigned char ucG1 = CMonoObject::GetPropertyValue< unsigned char >( pColor, "G" );
unsigned char ucR1 = pColor1.GetPropertyValue< unsigned char >( "R" ); unsigned char ucB1 = CMonoObject::GetPropertyValue< unsigned char >( pColor, "B" );
unsigned char ucG1 = pColor1.GetPropertyValue< unsigned char >( "G" );
unsigned char ucB1 = pColor1.GetPropertyValue< unsigned char >( "B" );
return CLuaFunctionDefinitions::SetVehicleHeadLightColor( RESOURCE->GetLua(), (void*)pUserData, ucR1, ucG1, ucB1 ); return CLuaFunctionDefinitions::SetVehicleHeadLightColor( RESOURCE->GetLua(), (void*)pUserData, ucR1, ucG1, ucB1 );
} }
@ -1116,10 +1067,8 @@ bool CMonoFunctions::Vehicle::SetTurretPosition( DWORD pUserData, MonoObject* pP
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( pPosition ); float fX = CMonoObject::GetPropertyValue< float >( pPosition, "X" );
float fY = CMonoObject::GetPropertyValue< float >( pPosition, "Y" );
float fX = pPosition.GetPropertyValue< float >( "X" );
float fY = pPosition.GetPropertyValue< float >( "Y" );
return CLuaFunctionDefinitions::SetVehicleTurretPosition( RESOURCE->GetLua(), (void*)pUserData, fX, fY ); return CLuaFunctionDefinitions::SetVehicleTurretPosition( RESOURCE->GetLua(), (void*)pUserData, fX, fY );
} }
@ -1171,18 +1120,14 @@ bool CMonoFunctions::Vehicle::SetSirens( DWORD pUserData, unsigned char ucSirenI
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( pPosition ); float fX = CMonoObject::GetPropertyValue< float >( pPosition, "X" );
float fY = CMonoObject::GetPropertyValue< float >( pPosition, "Y" );
float fZ = CMonoObject::GetPropertyValue< float >( pPosition, "Z" );
float fX = pPosition.GetPropertyValue< float >( "X" ); float fRed = CMonoObject::GetPropertyValue< float >( pColor, "R" );
float fY = pPosition.GetPropertyValue< float >( "Y" ); float fGreen = CMonoObject::GetPropertyValue< float >( pColor, "G" );
float fZ = pPosition.GetPropertyValue< float >( "Z" ); float fBlue = CMonoObject::GetPropertyValue< float >( pColor, "B" );
float fAlpha = CMonoObject::GetPropertyValue< float >( pColor, "A" );
CMonoObject pColor( pColor );
float fRed = pColor.GetPropertyValue< float >( "R" );
float fGreen = pColor.GetPropertyValue< float >( "G" );
float fBlue = pColor.GetPropertyValue< float >( "B" );
float fAlpha = pColor.GetPropertyValue< float >( "A" );
return CLuaFunctionDefinitions::SetVehicleSirens( RESOURCE->GetLua(), (void*)pUserData, ucSirenID, fX, fY, fZ, fRed, fGreen, fBlue, fAlpha, fMinAlpha ); return CLuaFunctionDefinitions::SetVehicleSirens( RESOURCE->GetLua(), (void*)pUserData, ucSirenID, fX, fY, fZ, fRed, fGreen, fBlue, fAlpha, fMinAlpha );
} }

View File

@ -17,12 +17,12 @@ DWORD CMonoFunctions::Water::Create( MonoObject* pV1, MonoObject* pV2, MonoObjec
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3* vec1 = &CMonoObject( pV1 ).GetVector3(); Vector3 vec1( pV1 );
Vector3* vec2 = &CMonoObject( pV2 ).GetVector3(); Vector3 vec2( pV2 );
Vector3* vec3 = &CMonoObject( pV3 ).GetVector3(); Vector3 vec3( pV3 );
Vector3* vec4 = pV4 ? &CMonoObject( pV4 ).GetVector3() : NULL; Vector3 vec4 = pV4 ? Vector3( pV4 ) : NULL;
return (DWORD)CLuaFunctionDefinitions::CreateWater( RESOURCE->GetLua(), vec1, vec2, vec3, vec4, bShallow ); return (DWORD)CLuaFunctionDefinitions::CreateWater( RESOURCE->GetLua(), &vec1, &vec2, &vec3, &vec4, bShallow );
} }
return NULL; return NULL;
@ -76,9 +76,7 @@ MonoObject* CMonoFunctions::Water::GetVertexPosition( DWORD pUserData, int iVert
if( CLuaFunctionDefinitions::GetWaterVertexPosition( RESOURCE->GetLua(), (void*)pUserData, iVertexIndex, vecPosition ) ) if( CLuaFunctionDefinitions::GetWaterVertexPosition( RESOURCE->GetLua(), (void*)pUserData, iVertexIndex, vecPosition ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( vecPosition ); return RESOURCE->NewObject( vecPosition );
return pObject ? pObject->GetObject() : NULL;
} }
} }
@ -89,7 +87,7 @@ bool CMonoFunctions::Water::SetVertexPosition( DWORD pUserData, int iVertexIndex
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecPosition = CMonoObject( mPosition ).GetVector3(); Vector3 vecPosition( mPosition );
return CLuaFunctionDefinitions::SetWaterVertexPosition( RESOURCE->GetLua(), (void*)pUserData, iVertexIndex, vecPosition ); return CLuaFunctionDefinitions::SetWaterVertexPosition( RESOURCE->GetLua(), (void*)pUserData, iVertexIndex, vecPosition );
} }
@ -105,9 +103,7 @@ MonoObject* CMonoFunctions::Water::GetColor( void )
if( CLuaFunctionDefinitions::GetWaterColor( RESOURCE->GetLua(), pColor.R, pColor.G, pColor.B, pColor.A ) ) if( CLuaFunctionDefinitions::GetWaterColor( RESOURCE->GetLua(), pColor.R, pColor.G, pColor.B, pColor.A ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( pColor ); return RESOURCE->NewObject( pColor );
return pObject ? pObject->GetObject() : NULL;
} }
} }
@ -118,7 +114,7 @@ bool CMonoFunctions::Water::SetColor( MonoObject* mColor )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
SColor pColor = CMonoObject( mColor ).GetColor(); SColor pColor = CMonoObject::GetColor( mColor );
return CLuaFunctionDefinitions::SetWaterColor( RESOURCE->GetLua(), pColor.R, pColor.G, pColor.B, pColor.A ); return CLuaFunctionDefinitions::SetWaterColor( RESOURCE->GetLua(), pColor.R, pColor.G, pColor.B, pColor.A );
} }

View File

@ -59,7 +59,7 @@ MonoString* CMonoFunctions::World::GetZoneName( MonoObject* mPosition, bool bCit
{ {
string strOutName; string strOutName;
Vector3 vecPosition = CMonoObject( mPosition ).GetVector3(); Vector3 vecPosition( mPosition );
if( CLuaFunctionDefinitions::GetZoneName( RESOURCE->GetLua(), vecPosition, strOutName, bCitiesOnly ) ) if( CLuaFunctionDefinitions::GetZoneName( RESOURCE->GetLua(), vecPosition, strOutName, bCitiesOnly ) )
{ {
@ -275,15 +275,15 @@ MonoArray* CMonoFunctions::World::GetSunColor( void )
{ {
pCore.A = pCorona.A = 255; pCore.A = pCorona.A = 255;
CMonoObject* pCoreObject = RESOURCE->NewObject( pCore ); MonoObject* pCoreObject = RESOURCE->NewObject( pCore );
CMonoObject* pCoronaObject = RESOURCE->NewObject( pCorona ); MonoObject* pCoronaObject = RESOURCE->NewObject( pCorona );
if( pCoreObject && pCoronaObject ) if( pCoreObject && pCoronaObject )
{ {
MonoArray* pMonoArray = mono_array_new( RESOURCE->m_pMonoDomain, pCoreObject->GetClass()->GetClass(), 2 ); MonoArray* pMonoArray = mono_array_new( RESOURCE->m_pMonoDomain, CMonoObject::GetClass( pCoreObject ), 2 );
mono_array_set( pMonoArray, MonoObject*, 0, pCoreObject->GetObject() ); mono_array_set( pMonoArray, MonoObject*, 0, pCoreObject );
mono_array_set( pMonoArray, MonoObject*, 1, pCoronaObject->GetObject() ); mono_array_set( pMonoArray, MonoObject*, 1, pCoronaObject );
return pMonoArray; return pMonoArray;
} }
@ -301,12 +301,7 @@ MonoObject* CMonoFunctions::World::GetWindVelocity( void )
if( CLuaFunctionDefinitions::GetWindVelocity( RESOURCE->GetLua(), vecVelocity.fX, vecVelocity.fY, vecVelocity.fZ ) ) if( CLuaFunctionDefinitions::GetWindVelocity( RESOURCE->GetLua(), vecVelocity.fX, vecVelocity.fY, vecVelocity.fZ ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( vecVelocity ); return RESOURCE->NewObject( vecVelocity );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -398,15 +393,15 @@ MonoArray* CMonoFunctions::World::GetSkyGradient( void )
{ {
pCore.A = pCorona.A = 255; pCore.A = pCorona.A = 255;
CMonoObject* pCoreObject = RESOURCE->NewObject( pCore ); MonoObject* pCoreObject = RESOURCE->NewObject( pCore );
CMonoObject* pCoronaObject = RESOURCE->NewObject( pCorona ); MonoObject* pCoronaObject = RESOURCE->NewObject( pCorona );
if( pCoreObject && pCoronaObject ) if( pCoreObject && pCoronaObject )
{ {
MonoArray* pMonoArray = mono_array_new( RESOURCE->m_pMonoDomain, pCoreObject->GetClass()->GetClass(), 2 ); MonoArray* pMonoArray = mono_array_new( RESOURCE->m_pMonoDomain, CMonoObject::GetClass( pCoreObject ), 2 );
mono_array_set( pMonoArray, MonoObject*, 0, pCoreObject->GetObject() ); mono_array_set( pMonoArray, MonoObject*, 0, pCoreObject );
mono_array_set( pMonoArray, MonoObject*, 1, pCoronaObject->GetObject() ); mono_array_set( pMonoArray, MonoObject*, 1, pCoronaObject );
return pMonoArray; return pMonoArray;
} }
@ -429,12 +424,7 @@ MonoObject* CMonoFunctions::World::GetHeatHaze( void )
&heatHazeSettings &heatHazeSettings
}; };
CMonoObject* pObject = RESOURCE->NewObject( "MultiTheftAuto", "HeatHazeSettings", args, 1 ); return RESOURCE->NewObject( "MultiTheftAuto", "HeatHazeSettings", args, 1 );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -527,8 +517,8 @@ bool CMonoFunctions::World::SetSkyGradient( MonoObject* pTopColor, MonoObject* p
{ {
if( RESOURCE ) if( RESOURCE )
{ {
SColor pTop = CMonoObject( pTopColor ).GetColor(); SColor pTop = CMonoObject::GetColor( pTopColor );
SColor pBottom = CMonoObject( pBottomColor ).GetColor(); SColor pBottom = CMonoObject::GetColor( pBottomColor );
return CLuaFunctionDefinitions::SetSkyGradient( RESOURCE->GetLua(), pTop.R, pTop.G, pTop.B, pBottom.R, pBottom.G, pBottom.B ); return CLuaFunctionDefinitions::SetSkyGradient( RESOURCE->GetLua(), pTop.R, pTop.G, pTop.B, pBottom.R, pBottom.G, pBottom.B );
} }
@ -550,19 +540,17 @@ bool CMonoFunctions::World::SetHeatHaze( MonoObject* heatHazeSettings )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject* pObject = new CMonoObject( heatHazeSettings );
SHeatHazeSettings pHeatHazeSettings; SHeatHazeSettings pHeatHazeSettings;
pHeatHazeSettings.ucIntensity = pObject->GetPropertyValue< unsigned char >( "ucIntensity" ); pHeatHazeSettings.ucIntensity = CMonoObject::GetPropertyValue< unsigned char >( heatHazeSettings, "ucIntensity" );
pHeatHazeSettings.ucRandomShift = pObject->GetPropertyValue< unsigned char >( "ucRandomShift" ); pHeatHazeSettings.ucRandomShift = CMonoObject::GetPropertyValue< unsigned char >( heatHazeSettings, "ucRandomShift" );
pHeatHazeSettings.usSpeedMin = pObject->GetPropertyValue< unsigned short >( "usSpeedMin" ); pHeatHazeSettings.usSpeedMin = CMonoObject::GetPropertyValue< unsigned short >( heatHazeSettings, "usSpeedMin" );
pHeatHazeSettings.usSpeedMax = pObject->GetPropertyValue< unsigned short >( "usSpeedMax" ); pHeatHazeSettings.usSpeedMax = CMonoObject::GetPropertyValue< unsigned short >( heatHazeSettings, "usSpeedMax" );
pHeatHazeSettings.sScanSizeX = pObject->GetPropertyValue< short >( "sScanSizeX" ); pHeatHazeSettings.sScanSizeX = CMonoObject::GetPropertyValue< short >( heatHazeSettings, "sScanSizeX" );
pHeatHazeSettings.sScanSizeY = pObject->GetPropertyValue< short >( "sScanSizeY" ); pHeatHazeSettings.sScanSizeY = CMonoObject::GetPropertyValue< short >( heatHazeSettings, "sScanSizeY" );
pHeatHazeSettings.usRenderSizeX = pObject->GetPropertyValue< unsigned short >( "usRenderSizeX" ); pHeatHazeSettings.usRenderSizeX = CMonoObject::GetPropertyValue< unsigned short >( heatHazeSettings, "usRenderSizeX" );
pHeatHazeSettings.usRenderSizeY = pObject->GetPropertyValue< unsigned short >( "usRenderSizeY" ); pHeatHazeSettings.usRenderSizeY = CMonoObject::GetPropertyValue< unsigned short >( heatHazeSettings, "usRenderSizeY" );
pHeatHazeSettings.bInsideBuilding = pObject->GetPropertyValue< bool >( "bInsideBuilding" ); pHeatHazeSettings.bInsideBuilding = CMonoObject::GetPropertyValue< bool >( heatHazeSettings, "bInsideBuilding" );
return CLuaFunctionDefinitions::SetHeatHaze( RESOURCE->GetLua(), pHeatHazeSettings ); return CLuaFunctionDefinitions::SetHeatHaze( RESOURCE->GetLua(), pHeatHazeSettings );
} }
@ -718,8 +706,8 @@ bool CMonoFunctions::World::SetSunColor( MonoObject* pCoreColor, MonoObject* pCo
{ {
if( RESOURCE ) if( RESOURCE )
{ {
SColor pTop = CMonoObject( pCoreColor ).GetColor(); SColor pTop = CMonoObject::GetColor( pCoreColor );
SColor pBottom = CMonoObject( pCoronaColor ).GetColor(); SColor pBottom = CMonoObject::GetColor( pCoronaColor );
return CLuaFunctionDefinitions::SetSunColor( RESOURCE->GetLua(), pTop.R, pTop.G, pTop.B, pBottom.R, pBottom.G, pBottom.B ); return CLuaFunctionDefinitions::SetSunColor( RESOURCE->GetLua(), pTop.R, pTop.G, pTop.B, pBottom.R, pBottom.G, pBottom.B );
} }
@ -731,7 +719,7 @@ bool CMonoFunctions::World::SetWindVelocity( MonoObject* pVelocity )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecVelocity = CMonoObject( pVelocity ).GetVector3(); Vector3 vecVelocity( pVelocity );
return CLuaFunctionDefinitions::SetWindVelocity( RESOURCE->GetLua(), vecVelocity.fX, vecVelocity.fY, vecVelocity.fZ ); return CLuaFunctionDefinitions::SetWindVelocity( RESOURCE->GetLua(), vecVelocity.fX, vecVelocity.fY, vecVelocity.fZ );
} }
@ -853,7 +841,7 @@ bool CMonoFunctions::World::RemoveWorldModel( unsigned short usModel, float fRad
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); Vector3 vecPosition( pPosition );
return CLuaFunctionDefinitions::RemoveWorldModel( RESOURCE->GetLua(), usModel, fRadius, vecPosition, cInterior ); return CLuaFunctionDefinitions::RemoveWorldModel( RESOURCE->GetLua(), usModel, fRadius, vecPosition, cInterior );
} }
@ -865,7 +853,7 @@ bool CMonoFunctions::World::RestoreWorldModel( unsigned short usModel, float fRa
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); Vector3 vecPosition( pPosition );
return CLuaFunctionDefinitions::RestoreWorldModel( RESOURCE->GetLua(), usModel, fRadius, vecPosition, cInterior ); return CLuaFunctionDefinitions::RestoreWorldModel( RESOURCE->GetLua(), usModel, fRadius, vecPosition, cInterior );
} }

View File

@ -127,7 +127,7 @@ bool CResource::RegisterFunction( const char *szFunctionName, lua_CFunction Func
return true; return true;
} }
CMonoClass* CResource::GetClassFromName( const char* szNamespace, const char* szName ) MonoClass* CResource::GetClassFromName( const char* szNamespace, const char* szName )
{ {
MonoClass* pMonoClass = mono_class_from_name( this->m_pMonoImage, szNamespace, szName ); MonoClass* pMonoClass = mono_class_from_name( this->m_pMonoImage, szNamespace, szName );
@ -136,21 +136,16 @@ CMonoClass* CResource::GetClassFromName( const char* szNamespace, const char* sz
pMonoClass = mono_class_from_name( this->m_pMonoImageLib, szNamespace, szName ); pMonoClass = mono_class_from_name( this->m_pMonoImageLib, szNamespace, szName );
} }
if( pMonoClass ) return pMonoClass;
{
return new CMonoClass( pMonoClass );
} }
return NULL; MonoObject* CResource::NewObject( const char* szNamespace, const char* szName )
}
CMonoObject* CResource::NewObject( const char* szNamespace, const char* szName )
{ {
CMonoClass* pClass = this->GetClassFromName( szNamespace, szName ); MonoClass* pClass = this->GetClassFromName( szNamespace, szName );
if( pClass ) if( pClass )
{ {
CMonoObject* pObject = pClass->New( mono_domain_get() ); MonoObject* pObject = CMonoClass::New( pClass, mono_domain_get() );
if( pObject ) if( pObject )
{ {
@ -166,16 +161,41 @@ CMonoObject* CResource::NewObject( const char* szNamespace, const char* szName )
g_pModuleManager->ErrorPrintf( "%s:%d: class '%s::%s' not found\n", __FILE__, __LINE__, szNamespace, szName ); g_pModuleManager->ErrorPrintf( "%s:%d: class '%s::%s' not found\n", __FILE__, __LINE__, szNamespace, szName );
} }
return NULL; return nullptr;
} }
CMonoObject* CResource::NewObject( SColor& pColor ) MonoObject* CResource::NewObject( SColor& pColor )
{ {
CMonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Color" ); MonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Color" );
if( pClass ) if( pClass )
{ {
CMonoObject* pObject = pClass->New( mono_domain_get(), pColor ); MonoObject* pObject = CMonoClass::New( pClass, mono_domain_get(), pColor );
if( pObject )
{
return pObject;
}
else
{
g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of 'MultiTheftAuto::Color'\n", __FILE__, __LINE__ );
}
}
else
{
g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Color' not found\n", __FILE__, __LINE__ );
}
return nullptr;
}
MonoObject* CResource::NewObject( Vector2& vecVector )
{
MonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Vector2" );
if( pClass )
{
MonoObject* pObject = CMonoClass::New( pClass, mono_domain_get(), vecVector );
if( pObject ) if( pObject )
{ {
@ -191,41 +211,16 @@ CMonoObject* CResource::NewObject( SColor& pColor )
g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Vector2' not found\n", __FILE__, __LINE__ ); g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Vector2' not found\n", __FILE__, __LINE__ );
} }
return NULL; return nullptr;
} }
CMonoObject* CResource::NewObject( Vector2& vecVector ) MonoObject* CResource::NewObject( Vector3& vecVector )
{ {
CMonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Vector2" ); MonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Vector3" );
if( pClass ) if( pClass )
{ {
CMonoObject* pObject = pClass->New( mono_domain_get(), vecVector ); MonoObject* pObject = CMonoClass::New( pClass, mono_domain_get(), vecVector );
if( pObject )
{
return pObject;
}
else
{
g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of 'MultiTheftAuto::Vector2'\n", __FILE__, __LINE__ );
}
}
else
{
g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Vector2' not found\n", __FILE__, __LINE__ );
}
return NULL;
}
CMonoObject* CResource::NewObject( Vector3& vecVector )
{
CMonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Vector3" );
if( pClass )
{
CMonoObject* pObject = pClass->New( mono_domain_get(), vecVector );
if( pObject ) if( pObject )
{ {
@ -241,16 +236,16 @@ CMonoObject* CResource::NewObject( Vector3& vecVector )
g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Vector3' not found\n", __FILE__, __LINE__ ); g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Vector3' not found\n", __FILE__, __LINE__ );
} }
return NULL; return nullptr;
} }
CMonoObject* CResource::NewObject( const char* szNamespace, const char* szName, void** args, int argc ) MonoObject* CResource::NewObject( const char* szNamespace, const char* szName, void** args, int argc )
{ {
CMonoClass* pClass = this->GetClassFromName( szNamespace, szName ); MonoClass* pClass = this->GetClassFromName( szNamespace, szName );
if( pClass ) if( pClass )
{ {
CMonoObject* pObject = pClass->New( mono_domain_get(), args, argc ); MonoObject* pObject = CMonoClass::New( pClass, mono_domain_get(), args, argc );
if( pObject ) if( pObject )
{ {
@ -266,5 +261,5 @@ CMonoObject* CResource::NewObject( const char* szNamespace, const char* szName,
g_pModuleManager->ErrorPrintf( "%s:%d: class '%s::%s' not found\n", __FILE__, __LINE__, szNamespace, szName ); g_pModuleManager->ErrorPrintf( "%s:%d: class '%s::%s' not found\n", __FILE__, __LINE__, szNamespace, szName );
} }
return NULL; return nullptr;
} }

View File

@ -43,13 +43,13 @@ public:
void DoPulse ( void ); void DoPulse ( void );
bool RegisterFunction ( const char *szFunctionName, lua_CFunction Func ); bool RegisterFunction ( const char *szFunctionName, lua_CFunction Func );
CMonoClass* GetClassFromName( const char* szNamespace, const char* szName ); MonoClass* GetClassFromName( const char* szNamespace, const char* szName );
CMonoObject* NewObject( const char* szNamespace, const char* szName ); MonoObject* NewObject( const char* szNamespace, const char* szName );
CMonoObject* NewObject( SColor& pColor ); MonoObject* NewObject( SColor& pColor );
CMonoObject* NewObject( Vector2& vecVector ); MonoObject* NewObject( Vector2& vecVector );
CMonoObject* NewObject( Vector3& vecVector ); MonoObject* NewObject( Vector3& vecVector );
CMonoObject* NewObject( const char* szNamespace, const char* szName, void** args, int argc ); MonoObject* NewObject( const char* szNamespace, const char* szName, void** args, int argc );
MonoString* NewString( const char* szText ) MonoString* NewString( const char* szText )
{ {