Lua ColShape functions (CLuaFunctionDefinitions)

This commit is contained in:
Dmitry Korolev 2014-10-15 10:53:31 +04:00
parent 13b55ee064
commit 2bc3b40824
2 changed files with 137 additions and 8 deletions

View File

@ -4988,3 +4988,129 @@ bool CLuaFunctionDefinitions::UsePickup( lua_State* pLuaVM, void* pUserData, voi
return false;
}
// Shape create funcs
void* CLuaFunctionDefinitions::CreateColCircle( lua_State* pLuaVM, const Vector2& vecPosition, float fRadius )
{
CLuaArguments pLuaArguments;
pLuaArguments.PushNumber( vecPosition.fX );
pLuaArguments.PushNumber( vecPosition.fY );
pLuaArguments.PushNumber( fRadius );
if( pLuaArguments.Call( pLuaVM, "createColCircle", 1 ) )
{
CLuaArgument pLuaArgument( pLuaVM, -1 );
return pLuaArgument.GetLightUserData();
}
return NULL;
}
void* CLuaFunctionDefinitions::CreateColCuboid( lua_State* pLuaVM, const Vector3& vecPosition, const Vector3& vecSize )
{
CLuaArguments pLuaArguments;
pLuaArguments.PushNumber( vecPosition.fX );
pLuaArguments.PushNumber( vecPosition.fY );
pLuaArguments.PushNumber( vecPosition.fZ );
pLuaArguments.PushNumber( vecSize.fX );
pLuaArguments.PushNumber( vecSize.fY );
pLuaArguments.PushNumber( vecSize.fZ );
if( pLuaArguments.Call( pLuaVM, "createColCuboid", 1 ) )
{
CLuaArgument pLuaArgument( pLuaVM, -1 );
return pLuaArgument.GetLightUserData();
}
return NULL;
}
void* CLuaFunctionDefinitions::CreateColSphere( lua_State* pLuaVM, const Vector3& vecPosition, float fRadius )
{
CLuaArguments pLuaArguments;
pLuaArguments.PushNumber( vecPosition.fX );
pLuaArguments.PushNumber( vecPosition.fY );
pLuaArguments.PushNumber( vecPosition.fZ );
pLuaArguments.PushNumber( fRadius );
if( pLuaArguments.Call( pLuaVM, "createColSphere", 1 ) )
{
CLuaArgument pLuaArgument( pLuaVM, -1 );
return pLuaArgument.GetLightUserData();
}
return NULL;
}
void* CLuaFunctionDefinitions::CreateColRectangle( lua_State* pLuaVM, const Vector2& vecPosition, const Vector2& vecSize )
{
CLuaArguments pLuaArguments;
pLuaArguments.PushNumber( vecPosition.fX );
pLuaArguments.PushNumber( vecPosition.fY );
pLuaArguments.PushNumber( vecSize.fX );
pLuaArguments.PushNumber( vecSize.fY );
if( pLuaArguments.Call( pLuaVM, "createColRectangle", 1 ) )
{
CLuaArgument pLuaArgument( pLuaVM, -1 );
return pLuaArgument.GetLightUserData();
}
return NULL;
}
void* CLuaFunctionDefinitions::CreateColPolygon( lua_State* pLuaVM, const vector< Vector2 >& vecPointList )
{
if( vecPointList.size() < 4 )
{
return NULL;
}
CLuaArguments pLuaArguments;
for( unsigned int i = 0; i < vecPointList.size(); i++ )
{
pLuaArguments.PushNumber( vecPointList[ i ].fX );
pLuaArguments.PushNumber( vecPointList[ i ].fY );
}
if( pLuaArguments.Call( pLuaVM, "createColRectangle", 1 ) )
{
CLuaArgument pLuaArgument( pLuaVM, -1 );
return pLuaArgument.GetLightUserData();
}
return NULL;
}
void* CLuaFunctionDefinitions::CreateColTube( lua_State* pLuaVM, const Vector3& vecPosition, float fRadius, float fHeight )
{
CLuaArguments pLuaArguments;
pLuaArguments.PushNumber( vecPosition.fX );
pLuaArguments.PushNumber( vecPosition.fY );
pLuaArguments.PushNumber( vecPosition.fZ );
pLuaArguments.PushNumber( fRadius );
pLuaArguments.PushNumber( fHeight );
if( pLuaArguments.Call( pLuaVM, "createColTube", 1 ) )
{
CLuaArgument pLuaArgument( pLuaVM, -1 );
return pLuaArgument.GetLightUserData();
}
return NULL;
}

View File

@ -18,6 +18,9 @@ class CLuaFunctionDefinitions;
#include "../Common.h"
#include "../extra/CLuaArguments.h"
#include "../extra/Vector2.h"
#include "../extra/Vector3.h"
class CLuaFunctionDefinitions
{
public:
@ -386,6 +389,14 @@ public:
static bool SetPickupRespawnInterval ( lua_State* pLuaVM, void* pUserData, unsigned long ulInterval );
static bool UsePickup ( lua_State* pLuaVM, void* pUserData, void* pPlayer );
// Shape create funcs
static void* CreateColCircle ( lua_State* pLuaVM, const Vector2& vecPosition, float fRadius );
static void* CreateColCuboid ( lua_State* pLuaVM, const Vector3& vecPosition, const Vector3& vecSize );
static void* CreateColSphere ( lua_State* pLuaVM, const Vector3& vecPosition, float fRadius );
static void* CreateColRectangle ( lua_State* pLuaVM, const Vector2& vecPosition, const Vector2& vecSize );
static void* CreateColPolygon ( lua_State* pLuaVM, const vector< Vector2 >& vecPointList );
static void* CreateColTube ( lua_State* pLuaVM, const Vector3& vecPosition, float fRadius, float fHeight );
// Explosion funcs
// static int CreateExplosion ( lua_State* luaVM );
@ -416,14 +427,6 @@ public:
// static int ToggleControl ( lua_State* luaVM );
// static int ToggleAllControls ( lua_State* luaVM );
// Shape create funcs
// static int CreateColCircle ( lua_State* luaVM );
// static int CreateColCuboid ( lua_State* luaVM );
// static int CreateColSphere ( lua_State* luaVM );
// static int CreateColRectangle ( lua_State* luaVM );
// static int CreateColPolygon ( lua_State* luaVM );
// static int CreateColTube ( lua_State* luaVM );
// Team get funcs
// static int CreateTeam ( lua_State* luaVM );
// static int GetTeamFromName ( lua_State* luaVM );