1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 08:47:17 +01:00

Implemented functions to create sphere entities and added constructor to create an entity reference from a base reference.

This commit is contained in:
Sandu Liviu Catalin 2015-11-01 01:32:50 +02:00
parent b0c174e75e
commit 0d5dd53984
2 changed files with 206 additions and 1 deletions

View File

@ -1,5 +1,6 @@
#include "Entity/Sphere.hpp" #include "Entity/Sphere.hpp"
#include "Base/Color3.hpp" #include "Base/Color3.hpp"
#include "Core.hpp"
#include "Register.hpp" #include "Register.hpp"
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -14,6 +15,13 @@ SQUint32 CSphere::s_ColorR;
SQUint32 CSphere::s_ColorG; SQUint32 CSphere::s_ColorG;
SQUint32 CSphere::s_ColorB; SQUint32 CSphere::s_ColorB;
// ------------------------------------------------------------------------------------------------
CSphere::CSphere(const Reference< CSphere > & o) noexcept
: Reference(o)
{
/* ... */
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
bool CSphere::IsStreamedFor(const Reference< CPlayer > & player) const noexcept bool CSphere::IsStreamedFor(const Reference< CPlayer > & player) const noexcept
{ {
@ -208,6 +216,150 @@ SQInt32 CSphere::GetOwnerID() const noexcept
return SQMOD_UNKNOWN; return SQMOD_UNKNOWN;
} }
// ------------------------------------------------------------------------------------------------
Reference< CSphere > CreateBaseSphere_PEF(SQInt32 player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b,
SQFloat radius) noexcept
{
return _Core->NewSphere(player, world, x, y, z, r, g, b, radius,
SQMOD_CREATE_DEFAULT, NullData());
}
Reference< CSphere > CreateBaseSphere_PEF(SQInt32 player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b,
SQFloat radius,
SQInt32 header, SqObj & payload) noexcept
{
return _Core->NewSphere(player, world, x, y, z, r, g, b, radius,
header, payload);
}
// ------------------------------------------------------------------------------------------------
Reference< CSphere > CreateBaseSphere_PCF(SQInt32 player, SQInt32 world,
const Vector3 & pos, const Color3 & color, SQFloat radius) noexcept
{
return _Core->NewSphere(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, radius,
SQMOD_CREATE_DEFAULT, NullData());
}
Reference< CSphere > CreateBaseSphere_PCF(SQInt32 player, SQInt32 world,
const Vector3 & pos, const Color3 & color, SQFloat radius,
SQInt32 header, SqObj & payload) noexcept
{
return _Core->NewSphere(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, radius,
header, payload);
}
// ------------------------------------------------------------------------------------------------
Reference< CSphere > CreateBaseSphere_EF(const Reference< CPlayer > & player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b,
SQFloat radius) noexcept
{
return _Core->NewSphere(player, world, x, y, z, r, g, b, radius,
SQMOD_CREATE_DEFAULT, NullData());
}
Reference< CSphere > CreateBaseSphere_EF(const Reference< CPlayer > & player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b,
SQFloat radius,
SQInt32 header, SqObj & payload) noexcept
{
return _Core->NewSphere(player, world, x, y, z, r, g, b, radius,
header, payload);
}
// ------------------------------------------------------------------------------------------------
Reference< CSphere > CreateBaseSphere_CF(const Reference< CPlayer > & player, SQInt32 world,
const Vector3 & pos, const Color3 & color, SQFloat radius) noexcept
{
return _Core->NewSphere(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, radius,
SQMOD_CREATE_DEFAULT, NullData());
}
Reference< CSphere > CreateBaseSphere_CF(const Reference< CPlayer > & player, SQInt32 world,
const Vector3 & pos, const Color3 & color, SQFloat radius,
SQInt32 header, SqObj & payload) noexcept
{
return _Core->NewSphere(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, radius,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CSphere CreateSphere_PEF(SQInt32 player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b,
SQFloat radius) noexcept
{
return _Core->NewSphere(player, world, x, y, z, r, g, b, radius,
SQMOD_CREATE_DEFAULT, NullData());
}
CSphere CreateSphere_PEF(SQInt32 player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b,
SQFloat radius,
SQInt32 header, SqObj & payload) noexcept
{
return _Core->NewSphere(player, world, x, y, z, r, g, b, radius,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CSphere CreateSphere_PCF(SQInt32 player, SQInt32 world,
const Vector3 & pos, const Color3 & color, SQFloat radius) noexcept
{
return _Core->NewSphere(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, radius,
SQMOD_CREATE_DEFAULT, NullData());
}
CSphere CreateSphere_PCF(SQInt32 player, SQInt32 world,
const Vector3 & pos, const Color3 & color, SQFloat radius,
SQInt32 header, SqObj & payload) noexcept
{
return _Core->NewSphere(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, radius,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CSphere CreateSphere_EF(const Reference< CPlayer > & player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b,
SQFloat radius) noexcept
{
return _Core->NewSphere(player, world, x, y, z, r, g, b, radius,
SQMOD_CREATE_DEFAULT, NullData());
}
CSphere CreateSphere_EF(const Reference< CPlayer > & player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b,
SQFloat radius,
SQInt32 header, SqObj & payload) noexcept
{
return _Core->NewSphere(player, world, x, y, z, r, g, b, radius,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CSphere CreateSphere_CF(const Reference< CPlayer > & player, SQInt32 world,
const Vector3 & pos, const Color3 & color, SQFloat radius) noexcept
{
return _Core->NewSphere(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, radius,
SQMOD_CREATE_DEFAULT, NullData());
}
CSphere CreateSphere_CF(const Reference< CPlayer > & player, SQInt32 world,
const Vector3 & pos, const Color3 & color, SQFloat radius,
SQInt32 header, SqObj & payload) noexcept
{
return _Core->NewSphere(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, radius,
header, payload);
}
// ================================================================================================ // ================================================================================================
bool Register_CSphere(HSQUIRRELVM vm) bool Register_CSphere(HSQUIRRELVM vm)
{ {
@ -218,10 +370,12 @@ bool Register_CSphere(HSQUIRRELVM vm)
// Registration failed // Registration failed
return false; return false;
} }
// Typedef the base reference type for simplicity
typedef Reference< CSphere > RefType;
// Output debugging information // Output debugging information
LogDbg("Beginning registration of <CSphere> type"); LogDbg("Beginning registration of <CSphere> type");
// Attempt to register the actual reference that implements all of the entity functionality // Attempt to register the actual reference that implements all of the entity functionality
Sqrat::RootTable(vm).Bind(_SC("CSphere"), Sqrat::DerivedClass< CSphere, Reference< CSphere > >(vm, _SC("CSphere")) Sqrat::RootTable(vm).Bind(_SC("CSphere"), Sqrat::DerivedClass< CSphere, RefType >(vm, _SC("CSphere"))
/* Constructors */ /* Constructors */
.Ctor() .Ctor()
.Ctor< SQInt32 >() .Ctor< SQInt32 >()
@ -239,6 +393,52 @@ bool Register_CSphere(HSQUIRRELVM vm)
); );
// Output debugging information // Output debugging information
LogDbg("Registration of <CSphere> type was successful"); LogDbg("Registration of <CSphere> type was successful");
// Output debugging information
LogDbg("Beginning registration of <Sphere functions> type");
// Register global functions related to this entity type
Sqrat::RootTable(vm)
/* Create BaseSphere [P]rimitive [E]xtended [F]Full */
.Overload< RefType (*)(SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, SQFloat) >
(_SC("CreateBaseSphere_PEF"), &CreateBaseSphere_PEF)
.Overload< RefType (*)(SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, SQFloat, SQInt32, SqObj &) >
(_SC("CreateBaseSphere_PEF"), &CreateBaseSphere_PEF)
/* Create BaseSphere [P]rimitive [C]ompact [F]ull */
.Overload< RefType (*)(SQInt32, SQInt32, const Vector3 &, const Color3 &, SQFloat) >
(_SC("CreateBaseSphere_PCF"), &CreateBaseSphere_PCF)
.Overload< RefType (*)(SQInt32, SQInt32, const Vector3 &, const Color3 &, SQFloat, SQInt32, SqObj &) >
(_SC("CreateBaseSphere_PCF"), &CreateBaseSphere_PCF)
/* Create BaseSphere [E]xtended [F]Full */
.Overload< RefType (*)(const Reference< CPlayer > &, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, SQFloat) >
(_SC("CreateBaseSphere_EF"), &CreateBaseSphere_EF)
.Overload< RefType (*)(const Reference< CPlayer > &, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, SQFloat, SQInt32, SqObj &) >
(_SC("CreateBaseSphere_EF"), &CreateBaseSphere_EF)
/* Create BaseSphere [C]ompact [F]ull */
.Overload< RefType (*)(const Reference< CPlayer > &, SQInt32, const Vector3 &, const Color3 &, SQFloat) >
(_SC("CreateBaseSphere_CF"), &CreateBaseSphere_CF)
.Overload< RefType (*)(const Reference< CPlayer > &, SQInt32, const Vector3 &, const Color3 &, SQFloat, SQInt32, SqObj &) >
(_SC("CreateBaseSphere_CF"), &CreateBaseSphere_CF)
/* Create CSphere [P]rimitive [E]xtended [F]Full */
.Overload< CSphere (*)(SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, SQFloat) >
(_SC("CreateSphere_PEF"), &CreateSphere_PEF)
.Overload< CSphere (*)(SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, SQFloat, SQInt32, SqObj &) >
(_SC("CreateSphere_PEF"), &CreateSphere_PEF)
/* Create CSphere [P]rimitive [C]ompact [F]ull */
.Overload< CSphere (*)(SQInt32, SQInt32, const Vector3 &, const Color3 &, SQFloat) >
(_SC("CreateSphere_PCF"), &CreateSphere_PCF)
.Overload< CSphere (*)(SQInt32, SQInt32, const Vector3 &, const Color3 &, SQFloat, SQInt32, SqObj &) >
(_SC("CreateSphere_PCF"), &CreateSphere_PCF)
/* Create CSphere [E]xtended [F]Full */
.Overload< CSphere (*)(const Reference< CPlayer > &, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, SQFloat) >
(_SC("CreateSphere_EF"), &CreateSphere_EF)
.Overload< CSphere (*)(const Reference< CPlayer > &, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, SQFloat, SQInt32, SqObj &) >
(_SC("CreateSphere_EF"), &CreateSphere_EF)
/* Create CSphere [C]ompact [F]ull */
.Overload< CSphere (*)(const Reference< CPlayer > &, SQInt32, const Vector3 &, const Color3 &, SQFloat) >
(_SC("CreateSphere_CF"), &CreateSphere_CF)
.Overload< CSphere (*)(const Reference< CPlayer > &, SQInt32, const Vector3 &, const Color3 &, SQFloat, SQInt32, SqObj &) >
(_SC("CreateSphere_CF"), &CreateSphere_CF);
// Output debugging information
LogDbg("Registration of <Sphere functions> type was successful");
// Registration succeeded // Registration succeeded
return true; return true;
} }

View File

@ -26,6 +26,11 @@ public:
*/ */
using RefType::Reference; using RefType::Reference;
/* --------------------------------------------------------------------------------------------
* Construct a reference from a base reference.
*/
CSphere(const Reference< CSphere > & o) noexcept;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* See if the referenced sphere instance is streamed for the specified player. * See if the referenced sphere instance is streamed for the specified player.
*/ */