1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-08-05 07:31:48 +02:00

Untested update to the new plugin API.

Various other changes to the plugin as well.
This commit is contained in:
Sandu Liviu Catalin
2016-05-22 06:20:38 +03:00
parent ddb52677bd
commit f2361a27c3
167 changed files with 15520 additions and 60635 deletions

View File

@@ -12,7 +12,7 @@ const Int32 CBlip::Max = SQMOD_BLIP_POOL;
// ------------------------------------------------------------------------------------------------
SQInteger CBlip::Typename(HSQUIRRELVM vm)
{
static SQChar name[] = _SC("SqBlip");
static const SQChar name[] = _SC("SqBlip");
sq_pushstring(vm, name, sizeof(name));
return 1;
}
@@ -35,11 +35,17 @@ CBlip::~CBlip()
Int32 CBlip::Cmp(const CBlip & o) const
{
if (m_ID == o.m_ID)
{
return 0;
}
else if (m_ID > o.m_ID)
{
return 1;
}
else
{
return -1;
}
}
// ------------------------------------------------------------------------------------------------
@@ -84,7 +90,7 @@ bool CBlip::Destroy(Int32 header, Object & payload)
// Validate the managed identifier
Validate();
// Perform the requested operation
return _Core->DelBlip(m_ID, header, payload);
return Core::Get().DelBlip(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
@@ -93,7 +99,7 @@ void CBlip::BindEvent(Int32 evid, Object & env, Function & func) const
// Validate the managed identifier
Validate();
// Obtain the function instance called for this event
Function & event = _Core->GetBlipEvent(m_ID, evid);
Function & event = Core::Get().GetBlipEvent(m_ID, evid);
// Is the specified callback function null?
if (func.IsNull())
{
@@ -112,7 +118,7 @@ Int32 CBlip::GetWorld() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Core->GetBlip(m_ID).mWorld;
return Core::Get().GetBlip(m_ID).mWorld;
}
// ------------------------------------------------------------------------------------------------
@@ -121,7 +127,7 @@ Int32 CBlip::GetScale() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Core->GetBlip(m_ID).mScale;
return Core::Get().GetBlip(m_ID).mScale;
}
// ------------------------------------------------------------------------------------------------
@@ -130,7 +136,7 @@ const Vector3 & CBlip::GetPosition() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Core->GetBlip(m_ID).mPosition;
return Core::Get().GetBlip(m_ID).mPosition;
}
// ------------------------------------------------------------------------------------------------
@@ -139,7 +145,7 @@ const Color4 & CBlip::GetColor() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Core->GetBlip(m_ID).mColor;
return Core::Get().GetBlip(m_ID).mColor;
}
// ------------------------------------------------------------------------------------------------
@@ -148,34 +154,34 @@ Int32 CBlip::GetSprID() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Core->GetBlip(m_ID).mSprID;
return Core::Get().GetBlip(m_ID).mSprID;
}
// ------------------------------------------------------------------------------------------------
Float32 CBlip::GetPosX() const
Float32 CBlip::GetPositionX() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Core->GetBlip(m_ID).mPosition.x;
return Core::Get().GetBlip(m_ID).mPosition.x;
}
// ------------------------------------------------------------------------------------------------
Float32 CBlip::GetPosY() const
Float32 CBlip::GetPositionY() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Core->GetBlip(m_ID).mPosition.y;
return Core::Get().GetBlip(m_ID).mPosition.y;
}
// ------------------------------------------------------------------------------------------------
Float32 CBlip::GetPosZ() const
Float32 CBlip::GetPositionZ() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Core->GetBlip(m_ID).mPosition.z;
return Core::Get().GetBlip(m_ID).mPosition.z;
}
// ------------------------------------------------------------------------------------------------
@@ -184,7 +190,7 @@ Int32 CBlip::GetColorR() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Core->GetBlip(m_ID).mColor.r;
return Core::Get().GetBlip(m_ID).mColor.r;
}
// ------------------------------------------------------------------------------------------------
@@ -193,7 +199,7 @@ Int32 CBlip::GetColorG() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Core->GetBlip(m_ID).mColor.g;
return Core::Get().GetBlip(m_ID).mColor.g;
}
// ------------------------------------------------------------------------------------------------
@@ -202,7 +208,7 @@ Int32 CBlip::GetColorB() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Core->GetBlip(m_ID).mColor.b;
return Core::Get().GetBlip(m_ID).mColor.b;
}
// ------------------------------------------------------------------------------------------------
@@ -211,14 +217,14 @@ Int32 CBlip::GetColorA() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Core->GetBlip(m_ID).mColor.a;
return Core::Get().GetBlip(m_ID).mColor.a;
}
// ------------------------------------------------------------------------------------------------
static Object & Blip_CreateEx(Int32 world, Float32 x, Float32 y, Float32 z, Int32 scale,
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Int32 sprid)
{
return _Core->NewBlip(-1, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
return Core::Get().NewBlip(-1, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
SQMOD_CREATE_DEFAULT, NullObject());
}
@@ -226,7 +232,7 @@ static Object & Blip_CreateEx(Int32 world, Float32 x, Float32 y, Float32 z, Int3
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Int32 sprid,
Int32 header, Object & payload)
{
return _Core->NewBlip(-1, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
return Core::Get().NewBlip(-1, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
header, payload);
}
@@ -234,7 +240,7 @@ static Object & Blip_CreateEx(Int32 world, Float32 x, Float32 y, Float32 z, Int3
static Object & Blip_CreateEx(Int32 index, Int32 world, Float32 x, Float32 y, Float32 z,
Int32 scale, Uint8 r, Uint8 g, Uint8 b, Uint8 a, Int32 sprid)
{
return _Core->NewBlip(index, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
return Core::Get().NewBlip(index, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
SQMOD_CREATE_DEFAULT, NullObject());
}
@@ -242,7 +248,7 @@ static Object & Blip_CreateEx(Int32 index, Int32 world, Float32 x, Float32 y, Fl
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Int32 sprid,
Int32 header, Object & payload)
{
return _Core->NewBlip(index, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
return Core::Get().NewBlip(index, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
header, payload);
}
@@ -250,14 +256,14 @@ static Object & Blip_CreateEx(Int32 index, Int32 world, Float32 x, Float32 y, Fl
static Object & Blip_Create(Int32 world, const Vector3 & pos, Int32 scale, const Color4 & color,
Int32 sprid)
{
return _Core->NewBlip(-1, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
return Core::Get().NewBlip(-1, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
SQMOD_CREATE_DEFAULT, NullObject());
}
static Object & Blip_Create(Int32 world, const Vector3 & pos, Int32 scale, const Color4 & color,
Int32 sprid, Int32 header, Object & payload)
{
return _Core->NewBlip(-1, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
return Core::Get().NewBlip(-1, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
header, payload);
}
@@ -265,14 +271,14 @@ static Object & Blip_Create(Int32 world, const Vector3 & pos, Int32 scale, const
static Object & Blip_Create(Int32 index, Int32 world, const Vector3 & pos, Int32 scale,
const Color4 & color, Int32 sprid)
{
return _Core->NewBlip(index, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
return Core::Get().NewBlip(index, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
SQMOD_CREATE_DEFAULT, NullObject());
}
static Object & Blip_Create(Int32 index, Int32 world, const Vector3 & pos, Int32 scale,
const Color4 & color, Int32 sprid, Int32 header, Object & payload)
{
return _Core->NewBlip(index, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
return Core::Get().NewBlip(index, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
header, payload);
}
@@ -283,8 +289,8 @@ static const Object & Blip_FindByID(Int32 id)
if (INVALID_ENTITYEX(id, SQMOD_BLIP_POOL))
STHROWF("The specified blip identifier is invalid: %d", id);
// Obtain the ends of the entity pool
Core::Blips::const_iterator itr = _Core->GetBlips().cbegin();
Core::Blips::const_iterator end = _Core->GetBlips().cend();
Core::Blips::const_iterator itr = Core::Get().GetBlips().cbegin();
Core::Blips::const_iterator end = Core::Get().GetBlips().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
@@ -306,8 +312,8 @@ static const Object & Blip_FindByTag(CSStr tag)
STHROWF("The specified blip tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Blips::const_iterator itr = _Core->GetBlips().cbegin();
Core::Blips::const_iterator end = _Core->GetBlips().cend();
Core::Blips::const_iterator itr = Core::Get().GetBlips().cbegin();
Core::Blips::const_iterator end = Core::Get().GetBlips().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
@@ -330,8 +336,8 @@ static const Object & Blip_FindBySprID(Int32 sprid)
STHROWF("The specified sprite identifier is invalid: %d", sprid);
}
// Obtain the ends of the entity pool
Core::Blips::const_iterator itr = _Core->GetBlips().cbegin();
Core::Blips::const_iterator end = _Core->GetBlips().cend();
Core::Blips::const_iterator itr = Core::Get().GetBlips().cbegin();
Core::Blips::const_iterator end = Core::Get().GetBlips().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
@@ -351,8 +357,8 @@ static Array Blip_FindActive()
// Remember the initial stack size
StackGuard sg;
// Obtain the ends of the entity pool
Core::Blips::const_iterator itr = _Core->GetBlips().cbegin();
Core::Blips::const_iterator end = _Core->GetBlips().cend();
Core::Blips::const_iterator itr = Core::Get().GetBlips().cbegin();
Core::Blips::const_iterator end = Core::Get().GetBlips().cend();
// Allocate an empty array on the stack
sq_newarray(DefaultVM::Get(), 0);
// Process each entity in the pool
@@ -403,13 +409,13 @@ void Register_CBlip(HSQUIRRELVM vm)
.Prop(_SC("Position"), &CBlip::GetPosition)
.Prop(_SC("Color"), &CBlip::GetColor)
.Prop(_SC("SprID"), &CBlip::GetSprID)
.Prop(_SC("X"), &CBlip::GetPosX)
.Prop(_SC("Y"), &CBlip::GetPosY)
.Prop(_SC("Z"), &CBlip::GetPosZ)
.Prop(_SC("R"), &CBlip::GetColorR)
.Prop(_SC("G"), &CBlip::GetColorG)
.Prop(_SC("B"), &CBlip::GetColorB)
.Prop(_SC("A"), &CBlip::GetColorA)
.Prop(_SC("PosX"), &CBlip::GetPositionX)
.Prop(_SC("PosY"), &CBlip::GetPositionY)
.Prop(_SC("PosZ"), &CBlip::GetPositionZ)
.Prop(_SC("Red"), &CBlip::GetColorR)
.Prop(_SC("Green"), &CBlip::GetColorG)
.Prop(_SC("Blue"), &CBlip::GetColorB)
.Prop(_SC("Alpha"), &CBlip::GetColorA)
// Static Functions
.StaticFunc(_SC("FindByID"), &Blip_FindByID)
.StaticFunc(_SC("FindByTag"), &Blip_FindByTag)

View File

@@ -185,17 +185,17 @@ public:
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the x axis of the managed blip entity.
*/
Float32 GetPosX() const;
Float32 GetPositionX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the y axis of the managed blip entity.
*/
Float32 GetPosY() const;
Float32 GetPositionY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the z axis of the managed blip entity.
*/
Float32 GetPosZ() const;
Float32 GetPositionZ() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the red color of the managed blip entity.

View File

@@ -14,10 +14,10 @@ Color4 CCheckpoint::s_Color4;
Vector3 CCheckpoint::s_Vector3;
// ------------------------------------------------------------------------------------------------
Uint32 CCheckpoint::s_ColorR;
Uint32 CCheckpoint::s_ColorG;
Uint32 CCheckpoint::s_ColorB;
Uint32 CCheckpoint::s_ColorA;
Int32 CCheckpoint::s_ColorR;
Int32 CCheckpoint::s_ColorG;
Int32 CCheckpoint::s_ColorB;
Int32 CCheckpoint::s_ColorA;
// ------------------------------------------------------------------------------------------------
const Int32 CCheckpoint::Max = SQMOD_CHECKPOINT_POOL;
@@ -25,7 +25,7 @@ const Int32 CCheckpoint::Max = SQMOD_CHECKPOINT_POOL;
// ------------------------------------------------------------------------------------------------
SQInteger CCheckpoint::Typename(HSQUIRRELVM vm)
{
static SQChar name[] = _SC("SqCheckpoint");
static const SQChar name[] = _SC("SqCheckpoint");
sq_pushstring(vm, name, sizeof(name));
return 1;
}
@@ -48,11 +48,17 @@ CCheckpoint::~CCheckpoint()
Int32 CCheckpoint::Cmp(const CCheckpoint & o) const
{
if (m_ID == o.m_ID)
{
return 0;
}
else if (m_ID > o.m_ID)
{
return 1;
}
else
{
return -1;
}
}
// ------------------------------------------------------------------------------------------------
@@ -97,7 +103,7 @@ bool CCheckpoint::Destroy(Int32 header, Object & payload)
// Validate the managed identifier
Validate();
// Perform the requested operation
return _Core->DelCheckpoint(m_ID, header, payload);
return Core::Get().DelCheckpoint(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
@@ -106,7 +112,7 @@ void CCheckpoint::BindEvent(Int32 evid, Object & env, Function & func) const
// Validate the managed identifier
Validate();
// Obtain the function instance called for this event
Function & event = _Core->GetCheckpointEvent(m_ID, evid);
Function & event = Core::Get().GetCheckpointEvent(m_ID, evid);
// Is the specified callback function null?
if (func.IsNull())
{
@@ -130,7 +136,16 @@ bool CCheckpoint::IsStreamedFor(CPlayer & player) const
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->IsCheckpointStreamedForPlayer(m_ID, player.GetID());
return _Func->IsCheckPointStreamedForPlayer(m_ID, player.GetID());
}
// ------------------------------------------------------------------------------------------------
bool CCheckpoint::IsSphere() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->IsCheckPointSphere(m_ID);
}
// ------------------------------------------------------------------------------------------------
@@ -139,7 +154,7 @@ Int32 CCheckpoint::GetWorld() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetCheckpointWorld(m_ID);
return _Func->GetCheckPointWorld(m_ID);
}
// ------------------------------------------------------------------------------------------------
@@ -148,7 +163,7 @@ void CCheckpoint::SetWorld(Int32 world) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetCheckpointWorld(m_ID, world);
_Func->SetCheckPointWorld(m_ID, world);
}
// ------------------------------------------------------------------------------------------------
@@ -157,9 +172,9 @@ const Color4 & CCheckpoint::GetColor() const
// Validate the managed identifier
Validate();
// Clear previous color information, if any
s_Color4.Clear();
s_ColorR = s_ColorG = s_ColorB = s_ColorA = 0;
// Query the server for the color values
_Func->GetCheckpointColor(m_ID, &s_ColorR, &s_ColorG, &s_ColorB, &s_ColorA);
_Func->GetCheckPointColour(m_ID, &s_ColorR, &s_ColorG, &s_ColorB, &s_ColorA);
// Convert and assign the retrieved values
s_Color4.Set(s_ColorR, s_ColorG, s_ColorB, s_ColorA);
// Return the requested information
@@ -172,7 +187,16 @@ void CCheckpoint::SetColor(const Color4 & col) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetCheckpointColor(m_ID, col.r, col.g, col.b, col.a);
_Func->SetCheckPointColour(m_ID, col.r, col.g, col.b, col.a);
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetColorEx(Uint8 r, Uint8 g, Uint8 b) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetCheckPointColour(m_ID, r, g, b, 0xFF);
}
// ------------------------------------------------------------------------------------------------
@@ -181,7 +205,7 @@ void CCheckpoint::SetColorEx(Uint8 r, Uint8 g, Uint8 b, Uint8 a) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetCheckpointColor(m_ID, r, g, b, a);
_Func->SetCheckPointColour(m_ID, r, g, b, a);
}
// ------------------------------------------------------------------------------------------------
@@ -192,7 +216,7 @@ const Vector3 & CCheckpoint::GetPosition() const
// Clear previous position information, if any
s_Vector3.Clear();
// Query the server for the position values
_Func->GetCheckpointPos(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z);
_Func->GetCheckPointPosition(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z);
// Return the requested information
return s_Vector3;
}
@@ -203,7 +227,7 @@ void CCheckpoint::SetPosition(const Vector3 & pos) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetCheckpointPos(m_ID, pos.x, pos.y, pos.z);
_Func->SetCheckPointPosition(m_ID, pos.x, pos.y, pos.z);
}
// ------------------------------------------------------------------------------------------------
@@ -212,7 +236,7 @@ void CCheckpoint::SetPositionEx(Float32 x, Float32 y, Float32 z) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetCheckpointPos(m_ID, x, y, z);
_Func->SetCheckPointPosition(m_ID, x, y, z);
}
// ------------------------------------------------------------------------------------------------
@@ -221,7 +245,7 @@ Float32 CCheckpoint::GetRadius() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetCheckpointRadius(m_ID);
return _Func->GetCheckPointRadius(m_ID);
}
// ------------------------------------------------------------------------------------------------
@@ -230,7 +254,7 @@ void CCheckpoint::SetRadius(Float32 radius) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetCheckpointRadius(m_ID, radius);
_Func->SetCheckPointRadius(m_ID, radius);
}
// ------------------------------------------------------------------------------------------------
@@ -239,7 +263,7 @@ Object & CCheckpoint::GetOwner() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Core->GetPlayer(_Func->GetCheckpointOwner(m_ID)).mObj;
return Core::Get().GetPlayer(_Func->GetCheckPointOwner(m_ID)).mObj;
}
// ------------------------------------------------------------------------------------------------
@@ -248,205 +272,208 @@ Int32 CCheckpoint::GetOwnerID() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetCheckpointOwner(m_ID);
return _Func->GetCheckPointOwner(m_ID);
}
// ------------------------------------------------------------------------------------------------
Float32 CCheckpoint::GetPosX() const
Float32 CCheckpoint::GetPositionX() const
{
// Validate the managed identifier
Validate();
// Clear previous position information, if any
s_Vector3.x = 0;
// Query the server for the requested component value
_Func->GetCheckpointPos(m_ID, &s_Vector3.x, NULL, NULL);
_Func->GetCheckPointPosition(m_ID, &s_Vector3.x, nullptr, nullptr);
// Return the requested information
return s_Vector3.x;
}
// ------------------------------------------------------------------------------------------------
Float32 CCheckpoint::GetPosY() const
Float32 CCheckpoint::GetPositionY() const
{
// Validate the managed identifier
Validate();
// Clear previous position information, if any
s_Vector3.y = 0;
// Query the server for the requested component value
_Func->GetCheckpointPos(m_ID, NULL, &s_Vector3.y, NULL);
_Func->GetCheckPointPosition(m_ID, nullptr, &s_Vector3.y, nullptr);
// Return the requested information
return s_Vector3.y;
}
// ------------------------------------------------------------------------------------------------
Float32 CCheckpoint::GetPosZ() const
Float32 CCheckpoint::GetPositionZ() const
{
// Validate the managed identifier
Validate();
// Clear previous position information, if any
s_Vector3.z = 0;
// Query the server for the requested component value
_Func->GetCheckpointPos(m_ID, NULL, NULL, &s_Vector3.z);
_Func->GetCheckPointPosition(m_ID, nullptr, nullptr, &s_Vector3.z);
// Return the requested information
return s_Vector3.z;
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetPosX(Float32 x) const
void CCheckpoint::SetPositionX(Float32 x) const
{
// Validate the managed identifier
Validate();
// Retrieve the current values for unchanged components
_Func->GetCheckpointPos(m_ID, NULL, &s_Vector3.y, &s_Vector3.z);
_Func->GetCheckPointPosition(m_ID, nullptr, &s_Vector3.y, &s_Vector3.z);
// Perform the requested operation
_Func->SetCheckpointPos(m_ID, x, s_Vector3.y, s_Vector3.z);
_Func->SetCheckPointPosition(m_ID, x, s_Vector3.y, s_Vector3.z);
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetPosY(Float32 y) const
void CCheckpoint::SetPositionY(Float32 y) const
{
// Validate the managed identifier
Validate();
// Retrieve the current values for unchanged components
_Func->GetCheckpointPos(m_ID, &s_Vector3.x, NULL, &s_Vector3.z);
_Func->GetCheckPointPosition(m_ID, &s_Vector3.x, nullptr, &s_Vector3.z);
// Perform the requested operation
_Func->SetCheckpointPos(m_ID, s_Vector3.x, y, s_Vector3.z);
_Func->SetCheckPointPosition(m_ID, s_Vector3.x, y, s_Vector3.z);
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetPosZ(Float32 z) const
void CCheckpoint::SetPositionZ(Float32 z) const
{
// Validate the managed identifier
Validate();
// Retrieve the current values for unchanged components
_Func->GetCheckpointPos(m_ID, &s_Vector3.x, &s_Vector3.y, NULL);
_Func->GetCheckPointPosition(m_ID, &s_Vector3.x, &s_Vector3.y, nullptr);
// Perform the requested operation
_Func->SetCheckpointPos(m_ID, s_Vector3.z, s_Vector3.y, z);
_Func->SetCheckPointPosition(m_ID, s_Vector3.z, s_Vector3.y, z);
}
// ------------------------------------------------------------------------------------------------
Uint32 CCheckpoint::GetColR() const
Int32 CCheckpoint::GetColorR() const
{
// Validate the managed identifier
Validate();
// Clear previous color information, if any
s_ColorR = 0;
// Query the server for the requested component value
_Func->GetCheckpointColor(m_ID, &s_ColorR, NULL, NULL, NULL);
_Func->GetCheckPointColour(m_ID, &s_ColorR, NULL, NULL, NULL);
// Return the requested information
return s_ColorR;
}
// ------------------------------------------------------------------------------------------------
Uint32 CCheckpoint::GetColG() const
Int32 CCheckpoint::GetColorG() const
{
// Validate the managed identifier
Validate();
// Clear previous color information, if any
s_ColorG = 0;
// Query the server for the requested component value
_Func->GetCheckpointColor(m_ID, NULL, &s_ColorG, NULL, NULL);
_Func->GetCheckPointColour(m_ID, NULL, &s_ColorG, NULL, NULL);
// Return the requested information
return s_ColorG;
}
// ------------------------------------------------------------------------------------------------
Uint32 CCheckpoint::GetColB() const
Int32 CCheckpoint::GetColorB() const
{
// Validate the managed identifier
Validate();
// Clear previous color information, if any
s_ColorB = 0;
// Query the server for the requested component value
_Func->GetCheckpointColor(m_ID, NULL, NULL, &s_ColorB, NULL);
_Func->GetCheckPointColour(m_ID, NULL, NULL, &s_ColorB, NULL);
// Return the requested information
return s_ColorB;
}
// ------------------------------------------------------------------------------------------------
Uint32 CCheckpoint::GetColA() const
Int32 CCheckpoint::GetColorA() const
{
// Validate the managed identifier
Validate();
// Clear previous color information, if any
s_ColorA = 0;
// Query the server for the requested component value
_Func->GetCheckpointColor(m_ID, NULL, NULL, NULL, &s_ColorA);
_Func->GetCheckPointColour(m_ID, NULL, NULL, NULL, &s_ColorA);
// Return the requested information
return s_ColorA;
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetColR(Uint32 r) const
void CCheckpoint::SetColorR(Int32 r) const
{
// Validate the managed identifier
Validate();
// Retrieve the current values for unchanged components
_Func->GetCheckpointColor(m_ID, NULL, &s_ColorG, &s_ColorB, &s_ColorA);
_Func->GetCheckPointColour(m_ID, NULL, &s_ColorG, &s_ColorB, &s_ColorA);
// Perform the requested operation
_Func->SetCheckpointColor(m_ID, r, s_ColorG, s_ColorB, s_ColorA);
_Func->SetCheckPointColour(m_ID, r, s_ColorG, s_ColorB, s_ColorA);
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetColG(Uint32 g) const
void CCheckpoint::SetColorG(Int32 g) const
{
// Validate the managed identifier
Validate();
// Retrieve the current values for unchanged components
_Func->GetCheckpointColor(m_ID, &s_ColorR, NULL, &s_ColorB, &s_ColorA);
_Func->GetCheckPointColour(m_ID, &s_ColorR, NULL, &s_ColorB, &s_ColorA);
// Perform the requested operation
_Func->SetCheckpointColor(m_ID, s_ColorR, g, s_ColorB, s_ColorA);
_Func->SetCheckPointColour(m_ID, s_ColorR, g, s_ColorB, s_ColorA);
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetColB(Uint32 b) const
void CCheckpoint::SetColorB(Int32 b) const
{
// Validate the managed identifier
Validate();
// Retrieve the current values for unchanged components
_Func->GetCheckpointColor(m_ID, &s_ColorB, &s_ColorG, NULL, &s_ColorA);
_Func->GetCheckPointColour(m_ID, &s_ColorB, &s_ColorG, NULL, &s_ColorA);
// Perform the requested operation
_Func->SetCheckpointColor(m_ID, s_ColorB, s_ColorG, b, s_ColorA);
_Func->SetCheckPointColour(m_ID, s_ColorB, s_ColorG, b, s_ColorA);
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetColA(Uint32 a) const
void CCheckpoint::SetColorA(Int32 a) const
{
// Validate the managed identifier
Validate();
// Retrieve the current values for unchanged components
_Func->GetCheckpointColor(m_ID, &s_ColorA, &s_ColorG, &s_ColorB, NULL);
_Func->GetCheckPointColour(m_ID, &s_ColorA, &s_ColorG, &s_ColorB, NULL);
// Perform the requested operation
_Func->SetCheckpointColor(m_ID, s_ColorA, s_ColorG, s_ColorB, a);
_Func->SetCheckPointColour(m_ID, s_ColorA, s_ColorG, s_ColorB, a);
}
// ------------------------------------------------------------------------------------------------
static Object & Checkpoint_CreateEx(CPlayer & player, Int32 world, Float32 x, Float32 y, Float32 z,
static Object & Checkpoint_CreateEx(CPlayer & player, Int32 world, bool sphere,
Float32 x, Float32 y, Float32 z,
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Float32 radius)
{
return _Core->NewCheckpoint(player.GetID(), world, x, y, z, r, g, b, a, radius,
return Core::Get().NewCheckpoint(player.GetID(), world, sphere, x, y, z, r, g, b, a, radius,
SQMOD_CREATE_DEFAULT, NullObject());
}
static Object & Checkpoint_CreateEx(CPlayer & player, Int32 world, Float32 x, Float32 y, Float32 z,
static Object & Checkpoint_CreateEx(CPlayer & player, Int32 world, bool sphere,
Float32 x, Float32 y, Float32 z,
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Float32 radius,
Int32 header, Object & payload)
{
return _Core->NewCheckpoint(player.GetID(), world, x, y, z, r, g, b, a, radius, header, payload);
return Core::Get().NewCheckpoint(player.GetID(), world, sphere, x, y, z, r, g, b, a,
radius, header, payload);
}
// ------------------------------------------------------------------------------------------------
static Object & Checkpoint_Create(CPlayer & player, Int32 world, const Vector3 & pos,
static Object & Checkpoint_Create(CPlayer & player, Int32 world, bool sphere, const Vector3 & pos,
const Color4 & color, Float32 radius)
{
return _Core->NewCheckpoint(player.GetID(), world, pos.x, pos.y, pos.z,
return Core::Get().NewCheckpoint(player.GetID(), world, sphere, pos.x, pos.y, pos.z,
color.r, color.g, color.b, color.a, radius,
SQMOD_CREATE_DEFAULT, NullObject());
}
static Object & Checkpoint_Create(CPlayer & player, Int32 world, const Vector3 & pos,
static Object & Checkpoint_Create(CPlayer & player, Int32 world, bool sphere, const Vector3 & pos,
const Color4 & color, Float32 radius, Int32 header, Object & payload)
{
return _Core->NewCheckpoint(player.GetID(), world, pos.x, pos.y, pos.z,
return Core::Get().NewCheckpoint(player.GetID(), world, sphere, pos.x, pos.y, pos.z,
color.r, color.g, color.b, color.a, radius, header, payload);
}
@@ -459,8 +486,8 @@ static const Object & Checkpoint_FindByID(Int32 id)
STHROWF("The specified checkpoint identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Checkpoints::const_iterator itr = _Core->GetCheckpoints().cbegin();
Core::Checkpoints::const_iterator end = _Core->GetCheckpoints().cend();
Core::Checkpoints::const_iterator itr = Core::Get().GetCheckpoints().cbegin();
Core::Checkpoints::const_iterator end = Core::Get().GetCheckpoints().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
@@ -483,8 +510,8 @@ static const Object & Checkpoint_FindByTag(CSStr tag)
STHROWF("The specified checkpoint tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Checkpoints::const_iterator itr = _Core->GetCheckpoints().cbegin();
Core::Checkpoints::const_iterator end = _Core->GetCheckpoints().cend();
Core::Checkpoints::const_iterator itr = Core::Get().GetCheckpoints().cbegin();
Core::Checkpoints::const_iterator end = Core::Get().GetCheckpoints().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
@@ -504,8 +531,8 @@ static Array Checkpoint_FindActive()
// Remember the initial stack size
StackGuard sg;
// Obtain the ends of the entity pool
Core::Checkpoints::const_iterator itr = _Core->GetCheckpoints().cbegin();
Core::Checkpoints::const_iterator end = _Core->GetCheckpoints().cend();
Core::Checkpoints::const_iterator itr = Core::Get().GetCheckpoints().cbegin();
Core::Checkpoints::const_iterator end = Core::Get().GetCheckpoints().cend();
// Allocate an empty array on the stack
sq_newarray(DefaultVM::Get(), 0);
// Process each entity in the pool
@@ -550,6 +577,7 @@ void Register_CCheckpoint(HSQUIRRELVM vm)
.Overload< bool (CCheckpoint::*)(Int32) >(_SC("Destroy"), &CCheckpoint::Destroy)
.Overload< bool (CCheckpoint::*)(Int32, Object &) >(_SC("Destroy"), &CCheckpoint::Destroy)
// Properties
.Prop(_SC("Sphere"), &CCheckpoint::IsSphere)
.Prop(_SC("World"), &CCheckpoint::GetWorld, &CCheckpoint::SetWorld)
.Prop(_SC("Color"), &CCheckpoint::GetColor, &CCheckpoint::SetColor)
.Prop(_SC("Pos"), &CCheckpoint::GetPosition, &CCheckpoint::SetPosition)
@@ -557,30 +585,34 @@ void Register_CCheckpoint(HSQUIRRELVM vm)
.Prop(_SC("Radius"), &CCheckpoint::GetRadius, &CCheckpoint::SetRadius)
.Prop(_SC("Owner"), &CCheckpoint::GetOwner)
.Prop(_SC("OwnerID"), &CCheckpoint::GetOwnerID)
.Prop(_SC("X"), &CCheckpoint::GetPosX, &CCheckpoint::SetPosX)
.Prop(_SC("Y"), &CCheckpoint::GetPosY, &CCheckpoint::SetPosY)
.Prop(_SC("Z"), &CCheckpoint::GetPosZ, &CCheckpoint::SetPosZ)
.Prop(_SC("R"), &CCheckpoint::GetColR, &CCheckpoint::SetColR)
.Prop(_SC("G"), &CCheckpoint::GetColG, &CCheckpoint::SetColG)
.Prop(_SC("B"), &CCheckpoint::GetColB, &CCheckpoint::SetColB)
.Prop(_SC("A"), &CCheckpoint::GetColA, &CCheckpoint::SetColA)
.Prop(_SC("PosX"), &CCheckpoint::GetPositionX, &CCheckpoint::SetPositionX)
.Prop(_SC("PosY"), &CCheckpoint::GetPositionY, &CCheckpoint::SetPositionY)
.Prop(_SC("PosZ"), &CCheckpoint::GetPositionZ, &CCheckpoint::SetPositionZ)
.Prop(_SC("Red"), &CCheckpoint::GetColorR, &CCheckpoint::SetColorR)
.Prop(_SC("Green"), &CCheckpoint::GetColorG, &CCheckpoint::SetColorG)
.Prop(_SC("Blue"), &CCheckpoint::GetColorB, &CCheckpoint::SetColorB)
.Prop(_SC("Alpha"), &CCheckpoint::GetColorA, &CCheckpoint::SetColorA)
// Member Methods
.Func(_SC("StreamedFor"), &CCheckpoint::IsStreamedFor)
.Func(_SC("SetColor"), &CCheckpoint::SetColorEx)
.Func(_SC("SetPos"), &CCheckpoint::SetPositionEx)
.Func(_SC("SetPosition"), &CCheckpoint::SetPositionEx)
// Member Overloads
.Overload< void (CCheckpoint::*)(Uint8, Uint8, Uint8) const >
(_SC("SetColor"), &CCheckpoint::SetColorEx)
.Overload< void (CCheckpoint::*)(Uint8, Uint8, Uint8, Uint8) const >
(_SC("SetColor"), &CCheckpoint::SetColorEx)
// Static Functions
.StaticFunc(_SC("FindByID"), &Checkpoint_FindByID)
.StaticFunc(_SC("FindByTag"), &Checkpoint_FindByTag)
.StaticFunc(_SC("FindActive"), &Checkpoint_FindActive)
// Static Overloads
.StaticOverload< Object & (*)(CPlayer &, Int32, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32) >
.StaticOverload< Object & (*)(CPlayer &, Int32, bool, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32) >
(_SC("CreateEx"), &Checkpoint_CreateEx)
.StaticOverload< Object & (*)(CPlayer &, Int32, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32, Int32, Object &) >
.StaticOverload< Object & (*)(CPlayer &, Int32, bool, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32, Int32, Object &) >
(_SC("CreateEx"), &Checkpoint_CreateEx)
.StaticOverload< Object & (*)(CPlayer &, Int32, const Vector3 &, const Color4 &, Float32) >
.StaticOverload< Object & (*)(CPlayer &, Int32, bool, const Vector3 &, const Color4 &, Float32) >
(_SC("Create"), &Checkpoint_Create)
.StaticOverload< Object & (*)(CPlayer &, Int32, const Vector3 &, const Color4 &, Float32, Int32, Object &) >
.StaticOverload< Object & (*)(CPlayer &, Int32, bool, const Vector3 &, const Color4 &, Float32, Int32, Object &) >
(_SC("Create"), &Checkpoint_Create)
);
}

View File

@@ -22,7 +22,7 @@ private:
static Vector3 s_Vector3;
// --------------------------------------------------------------------------------------------
static Uint32 s_ColorR, s_ColorG, s_ColorB, s_ColorA;
static Int32 s_ColorR, s_ColorG, s_ColorB, s_ColorA;
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
@@ -169,6 +169,11 @@ public:
*/
bool IsStreamedFor(CPlayer & player) const;
/* --------------------------------------------------------------------------------------------
* See if the managed checkpoint entity of sphere type.
*/
bool IsSphere() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the world in which the managed checkpoint entity exists.
*/
@@ -189,6 +194,11 @@ public:
*/
void SetColor(const Color4 & col) const;
/* --------------------------------------------------------------------------------------------
* Modify the color of the managed checkpoint entity.
*/
void SetColorEx(Uint8 r, Uint8 g, Uint8 b) const;
/* --------------------------------------------------------------------------------------------
* Modify the color of the managed checkpoint entity.
*/
@@ -232,72 +242,72 @@ public:
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the x axis of the managed checkpoint entity.
*/
Float32 GetPosX() const;
Float32 GetPositionX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the y axis of the managed checkpoint entity.
*/
Float32 GetPosY() const;
Float32 GetPositionY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the z axis of the managed checkpoint entity.
*/
Float32 GetPosZ() const;
Float32 GetPositionZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the x axis of the managed checkpoint entity.
*/
void SetPosX(Float32 x) const;
void SetPositionX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the y axis of the managed checkpoint entity.
*/
void SetPosY(Float32 y) const;
void SetPositionY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the z axis of the managed checkpoint entity.
*/
void SetPosZ(Float32 z) const;
void SetPositionZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the red color of the managed checkpoint entity.
*/
Uint32 GetColR() const;
Int32 GetColorR() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the green color of the managed checkpoint entity.
*/
Uint32 GetColG() const;
Int32 GetColorG() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the blue color of the managed checkpoint entity.
*/
Uint32 GetColB() const;
Int32 GetColorB() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the alpha transparency of the managed checkpoint entity.
*/
Uint32 GetColA() const;
Int32 GetColorA() const;
/* --------------------------------------------------------------------------------------------
* Modify the red color of the managed checkpoint entity.
*/
void SetColR(Uint32 r) const;
void SetColorR(Int32 r) const;
/* --------------------------------------------------------------------------------------------
* Modify the green color of the managed checkpoint entity.
*/
void SetColG(Uint32 g) const;
void SetColorG(Int32 g) const;
/* --------------------------------------------------------------------------------------------
* Modify the blue color of the managed checkpoint entity.
*/
void SetColB(Uint32 b) const;
void SetColorB(Int32 b) const;
/* --------------------------------------------------------------------------------------------
* Modify the alpha transparency of the managed checkpoint entity.
*/
void SetColA(Uint32 a) const;
void SetColorA(Int32 a) const;
};
} // Namespace:: SqMod

View File

@@ -1,561 +0,0 @@
// ------------------------------------------------------------------------------------------------
#include "Entity/Forcefield.hpp"
#include "Entity/Player.hpp"
#include "Base/Color3.hpp"
#include "Base/Vector3.hpp"
#include "Base/Stack.hpp"
#include "Core.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
Color3 CForcefield::s_Color3;
Vector3 CForcefield::s_Vector3;
// ------------------------------------------------------------------------------------------------
Uint32 CForcefield::s_ColorR;
Uint32 CForcefield::s_ColorG;
Uint32 CForcefield::s_ColorB;
// ------------------------------------------------------------------------------------------------
const Int32 CForcefield::Max = SQMOD_FORCEFIELD_POOL;
// ------------------------------------------------------------------------------------------------
SQInteger CForcefield::Typename(HSQUIRRELVM vm)
{
static SQChar name[] = _SC("SqForcefield");
sq_pushstring(vm, name, sizeof(name));
return 1;
}
// ------------------------------------------------------------------------------------------------
CForcefield::CForcefield(Int32 id)
: m_ID(VALID_ENTITYGETEX(id, SQMOD_FORCEFIELD_POOL))
, m_Tag(ToStrF("%d", id))
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
CForcefield::~CForcefield()
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
Int32 CForcefield::Cmp(const CForcefield & o) const
{
if (m_ID == o.m_ID)
return 0;
else if (m_ID > o.m_ID)
return 1;
else
return -1;
}
// ------------------------------------------------------------------------------------------------
const String & CForcefield::ToString() const
{
return m_Tag;
}
// ------------------------------------------------------------------------------------------------
const String & CForcefield::GetTag() const
{
return m_Tag;
}
// ------------------------------------------------------------------------------------------------
void CForcefield::SetTag(CSStr tag)
{
m_Tag.assign(tag);
}
// ------------------------------------------------------------------------------------------------
Object & CForcefield::GetData()
{
// Validate the managed identifier
Validate();
// Return the requested information
return m_Data;
}
// ------------------------------------------------------------------------------------------------
void CForcefield::SetData(Object & data)
{
// Validate the managed identifier
Validate();
// Apply the specified value
m_Data = data;
}
// ------------------------------------------------------------------------------------------------
bool CForcefield::Destroy(Int32 header, Object & payload)
{
// Validate the managed identifier
Validate();
// Perform the requested operation
return _Core->DelForcefield(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
void CForcefield::BindEvent(Int32 evid, Object & env, Function & func) const
{
// Validate the managed identifier
Validate();
// Obtain the function instance called for this event
Function & event = _Core->GetForcefieldEvent(m_ID, evid);
// Is the specified callback function null?
if (func.IsNull())
{
event.Release(); // Then release the current callback
}
// Assign the specified environment and function
else
{
event = Function(env.GetVM(), env, func.GetFunc());
}
}
// ------------------------------------------------------------------------------------------------
bool CForcefield::IsStreamedFor(CPlayer & player) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->IsSphereStreamedForPlayer(m_ID, player.GetID());
}
// ------------------------------------------------------------------------------------------------
Int32 CForcefield::GetWorld() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetSphereWorld(m_ID);
}
// ------------------------------------------------------------------------------------------------
void CForcefield::SetWorld(Int32 world) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetSphereWorld(m_ID, world);
}
// ------------------------------------------------------------------------------------------------
const Color3 & CForcefield::GetColor() const
{
// Validate the managed identifier
Validate();
// Clear previous color information, if any
s_Color3.Clear();
// Query the server for the color values
_Func->GetSphereColor(m_ID, &s_ColorR, &s_ColorG, &s_ColorB);
// Convert and assign the retrieved values
s_Color3.Set(s_ColorR, s_ColorG, s_ColorB);
// Return the requested information
return s_Color3;
}
// ------------------------------------------------------------------------------------------------
void CForcefield::SetColor(const Color3 & col) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetSphereColor(m_ID, col.r, col.g, col.b);
}
// ------------------------------------------------------------------------------------------------
void CForcefield::SetColorEx(Uint8 r, Uint8 g, Uint8 b) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetSphereColor(m_ID, r, g, b);
}
// ------------------------------------------------------------------------------------------------
const Vector3 & CForcefield::GetPosition() const
{
// Validate the managed identifier
Validate();
// Clear previous position information, if any
s_Vector3.Clear();
// Query the server for the position values
_Func->GetSpherePos(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z);
// Return the requested information
return s_Vector3;
}
// ------------------------------------------------------------------------------------------------
void CForcefield::SetPosition(const Vector3 & pos) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetSpherePos(m_ID, pos.x, pos.y, pos.z);
}
// ------------------------------------------------------------------------------------------------
void CForcefield::SetPositionEx(Float32 x, Float32 y, Float32 z) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetSpherePos(m_ID, x, y, z);
}
// ------------------------------------------------------------------------------------------------
Float32 CForcefield::GetRadius() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetSphereRadius(m_ID);
}
// ------------------------------------------------------------------------------------------------
void CForcefield::SetRadius(Float32 radius) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetSphereRadius(m_ID, radius);
}
// ------------------------------------------------------------------------------------------------
Object & CForcefield::GetOwner() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Core->GetPlayer(_Func->GetSphereOwner(m_ID)).mObj;
}
// ------------------------------------------------------------------------------------------------
Int32 CForcefield::GetOwnerID() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetSphereOwner(m_ID);
}
// ------------------------------------------------------------------------------------------------
Float32 CForcefield::GetPosX() const
{
// Validate the managed identifier
Validate();
// Clear previous position information, if any
s_Vector3.x = 0;
// Query the server for the requested component value
_Func->GetSpherePos(m_ID, &s_Vector3.x, NULL, NULL);
// Return the requested information
return s_Vector3.x;
}
// ------------------------------------------------------------------------------------------------
Float32 CForcefield::GetPosY() const
{
// Validate the managed identifier
Validate();
// Clear previous position information, if any
s_Vector3.y = 0;
// Query the server for the requested component value
_Func->GetSpherePos(m_ID, NULL, &s_Vector3.y, NULL);
// Return the requested information
return s_Vector3.y;
}
// ------------------------------------------------------------------------------------------------
Float32 CForcefield::GetPosZ() const
{
// Validate the managed identifier
Validate();
// Clear previous position information, if any
s_Vector3.z = 0;
// Query the server for the requested component value
_Func->GetSpherePos(m_ID, NULL, NULL, &s_Vector3.z);
// Return the requested information
return s_Vector3.z;
}
// ------------------------------------------------------------------------------------------------
void CForcefield::SetPosX(Float32 x) const
{
// Validate the managed identifier
Validate();
// Retrieve the current values for unchanged components
_Func->GetSpherePos(m_ID, NULL, &s_Vector3.y, &s_Vector3.z);
// Perform the requested operation
_Func->SetSpherePos(m_ID, x, s_Vector3.y, s_Vector3.z);
}
// ------------------------------------------------------------------------------------------------
void CForcefield::SetPosY(Float32 y) const
{
// Validate the managed identifier
Validate();
// Retrieve the current values for unchanged components
_Func->GetSpherePos(m_ID, &s_Vector3.x, NULL, &s_Vector3.z);
// Perform the requested operation
_Func->SetSpherePos(m_ID, s_Vector3.x, y, s_Vector3.z);
}
// ------------------------------------------------------------------------------------------------
void CForcefield::SetPosZ(Float32 z) const
{
// Validate the managed identifier
Validate();
// Retrieve the current values for unchanged components
_Func->GetSpherePos(m_ID, &s_Vector3.x, &s_Vector3.y, NULL);
// Perform the requested operation
_Func->SetSpherePos(m_ID, s_Vector3.z, s_Vector3.y, z);
}
// ------------------------------------------------------------------------------------------------
Uint32 CForcefield::GetColR() const
{
// Validate the managed identifier
Validate();
// Clear previous color information, if any
s_ColorR = 0;
// Query the server for the requested component value
_Func->GetSphereColor(m_ID, &s_ColorR, NULL, NULL);
// Return the requested information
return s_ColorR;
}
// ------------------------------------------------------------------------------------------------
Uint32 CForcefield::GetColG() const
{
// Validate the managed identifier
Validate();
// Query the server for the requested component value
s_ColorG = 0;
// Query the server for the requested component value
_Func->GetSphereColor(m_ID, NULL, &s_ColorG, NULL);
// Return the requested information
return s_ColorG;
}
// ------------------------------------------------------------------------------------------------
Uint32 CForcefield::GetColB() const
{
// Validate the managed identifier
Validate();
// Query the server for the requested component value
s_ColorB = 0;
// Query the server for the requested component value
_Func->GetSphereColor(m_ID, NULL, NULL, &s_ColorB);
// Return the requested information
return s_ColorB;
}
// ------------------------------------------------------------------------------------------------
void CForcefield::SetColR(Uint32 r) const
{
// Validate the managed identifier
Validate();
// Retrieve the current values for unchanged components
_Func->GetSphereColor(m_ID, NULL, &s_ColorG, &s_ColorB);
// Perform the requested operation
_Func->SetSphereColor(m_ID, r, s_ColorG, s_ColorB);
}
// ------------------------------------------------------------------------------------------------
void CForcefield::SetColG(Uint32 g) const
{
// Validate the managed identifier
Validate();
// Retrieve the current values for unchanged components
_Func->GetSphereColor(m_ID, &s_ColorR, NULL, &s_ColorB);
// Perform the requested operation
_Func->SetSphereColor(m_ID, s_ColorR, g, s_ColorB);
}
// ------------------------------------------------------------------------------------------------
void CForcefield::SetColB(Uint32 b) const
{
// Validate the managed identifier
Validate();
// Retrieve the current values for unchanged components
_Func->GetSphereColor(m_ID, &s_ColorB, &s_ColorG, NULL);
// Perform the requested operation
_Func->SetSphereColor(m_ID, s_ColorB, s_ColorG, b);
}
// ------------------------------------------------------------------------------------------------
static Object & Forcefield_CreateEx(CPlayer & player, Int32 world, Float32 x, Float32 y, Float32 z,
Uint8 r, Uint8 g, Uint8 b, Float32 radius)
{
return _Core->NewForcefield(player.GetID(), world, x, y, z, r, g, b, radius,
SQMOD_CREATE_DEFAULT, NullObject());
}
static Object & Forcefield_CreateEx(CPlayer & player, Int32 world, Float32 x, Float32 y, Float32 z,
Uint8 r, Uint8 g, Uint8 b, Float32 radius,
Int32 header, Object & payload)
{
return _Core->NewForcefield(player.GetID(), world, x, y, z, r, g, b, radius, header, payload);
}
// ------------------------------------------------------------------------------------------------
static Object & Forcefield_Create(CPlayer & player, Int32 world, const Vector3 & pos,
const Color3 & color, Float32 radius)
{
return _Core->NewForcefield(player.GetID(), world, pos.x, pos.y, pos.z, color.r, color.g, color.b, radius,
SQMOD_CREATE_DEFAULT, NullObject());
}
static Object & Forcefield_Create(CPlayer & player, Int32 world, const Vector3 & pos,
const Color3 & color, Float32 radius, Int32 header, Object & payload)
{
return _Core->NewForcefield(player.GetID(), world, pos.x, pos.y, pos.z, color.r, color.g, color.b, radius,
header, payload);
}
// ------------------------------------------------------------------------------------------------
static const Object & Forcefield_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_FORCEFIELD_POOL))
{
STHROWF("The specified forcefield identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Forcefields::const_iterator itr = _Core->GetForcefields().cbegin();
Core::Forcefields::const_iterator end = _Core->GetForcefields().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does the identifier match the specified one?
if (itr->mID == id)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a forcefield matching the specified identifier
return NullObject();
}
// ------------------------------------------------------------------------------------------------
static const Object & Forcefield_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == '\0')
{
STHROWF("The specified forcefield tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Forcefields::const_iterator itr = _Core->GetForcefields().cbegin();
Core::Forcefields::const_iterator end = _Core->GetForcefields().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a forcefield matching the specified tag
return NullObject();
}
// ------------------------------------------------------------------------------------------------
static Array Forcefield_FindActive()
{
// Remember the initial stack size
StackGuard sg;
// Obtain the ends of the entity pool
Core::Forcefields::const_iterator itr = _Core->GetForcefields().cbegin();
Core::Forcefields::const_iterator end = _Core->GetForcefields().cend();
// Allocate an empty array on the stack
sq_newarray(DefaultVM::Get(), 0);
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Is this entity instance active?
if (VALID_ENTITY(itr->mID))
{
// Push the script object on the stack
sq_pushobject(DefaultVM::Get(), (HSQOBJECT &)((*itr).mObj));
// Append the object at the back of the array
if (SQ_FAILED(sq_arrayappend(DefaultVM::Get(), -1)))
{
STHROWF("Unable to append entity instance to the list");
}
}
}
// Return the array at the top of the stack
return Var< Array >(DefaultVM::Get(), -1).value;
}
// ================================================================================================
void Register_CForcefield(HSQUIRRELVM vm)
{
RootTable(vm).Bind(_SC("SqForcefield"),
Class< CForcefield, NoConstructor< CForcefield > >(vm, _SC("SqForcefield"))
// Metamethods
.Func(_SC("_cmp"), &CForcefield::Cmp)
.SquirrelFunc(_SC("_typename"), &CForcefield::Typename)
.Func(_SC("_tostring"), &CForcefield::ToString)
// Static Values
.SetStaticValue(_SC("MaxID"), CForcefield::Max)
// Core Properties
.Prop(_SC("ID"), &CForcefield::GetID)
.Prop(_SC("Tag"), &CForcefield::GetTag, &CForcefield::SetTag)
.Prop(_SC("Data"), &CForcefield::GetData, &CForcefield::SetData)
.Prop(_SC("Active"), &CForcefield::IsActive)
// Core Methods
.Func(_SC("Bind"), &CForcefield::BindEvent)
// Core Overloads
.Overload< bool (CForcefield::*)(void) >(_SC("Destroy"), &CForcefield::Destroy)
.Overload< bool (CForcefield::*)(Int32) >(_SC("Destroy"), &CForcefield::Destroy)
.Overload< bool (CForcefield::*)(Int32, Object &) >(_SC("Destroy"), &CForcefield::Destroy)
// Properties
.Prop(_SC("World"), &CForcefield::GetWorld, &CForcefield::SetWorld)
.Prop(_SC("Color"), &CForcefield::GetColor, &CForcefield::SetColor)
.Prop(_SC("Pos"), &CForcefield::GetPosition, &CForcefield::SetPosition)
.Prop(_SC("Position"), &CForcefield::GetPosition, &CForcefield::SetPosition)
.Prop(_SC("Radius"), &CForcefield::GetRadius, &CForcefield::SetRadius)
.Prop(_SC("Owner"), &CForcefield::GetOwner)
.Prop(_SC("OwnerID"), &CForcefield::GetOwnerID)
.Prop(_SC("X"), &CForcefield::GetPosX, &CForcefield::SetPosX)
.Prop(_SC("Y"), &CForcefield::GetPosY, &CForcefield::SetPosY)
.Prop(_SC("Z"), &CForcefield::GetPosZ, &CForcefield::SetPosZ)
.Prop(_SC("R"), &CForcefield::GetColR, &CForcefield::SetColR)
.Prop(_SC("G"), &CForcefield::GetColG, &CForcefield::SetColG)
.Prop(_SC("B"), &CForcefield::GetColB, &CForcefield::SetColB)
// Member Methods
.Func(_SC("StreamedFor"), &CForcefield::IsStreamedFor)
.Func(_SC("SetColor"), &CForcefield::SetColorEx)
.Func(_SC("SetPos"), &CForcefield::SetPositionEx)
.Func(_SC("SetPosition"), &CForcefield::SetPositionEx)
// Static Functions
.StaticFunc(_SC("FindByID"), &Forcefield_FindByID)
.StaticFunc(_SC("FindByTag"), &Forcefield_FindByTag)
.StaticFunc(_SC("FindActive"), &Forcefield_FindActive)
// Static Overloads
.StaticOverload< Object & (*)(CPlayer &, Int32, Float32, Float32, Float32, Uint8, Uint8, Uint8, Float32) >
(_SC("CreateEx"), &Forcefield_CreateEx)
.StaticOverload< Object & (*)(CPlayer &, Int32, Float32, Float32, Float32, Uint8, Uint8, Uint8, Float32, Int32, Object &) >
(_SC("CreateEx"), &Forcefield_CreateEx)
.StaticOverload< Object & (*)(CPlayer &, Int32, const Vector3 &, const Color3 &, Float32) >
(_SC("Create"), &Forcefield_Create)
.StaticOverload< Object & (*)(CPlayer &, Int32, const Vector3 &, const Color3 &, Float32, Int32, Object &) >
(_SC("Create"), &Forcefield_Create)
);
}
} // Namespace:: SqMod

View File

@@ -1,295 +0,0 @@
#ifndef _ENTITY_FORCEFIELD_HPP_
#define _ENTITY_FORCEFIELD_HPP_
// ------------------------------------------------------------------------------------------------
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Manages a single forcefield entity.
*/
class CForcefield
{
// --------------------------------------------------------------------------------------------
friend class Core;
private:
// --------------------------------------------------------------------------------------------
static Color3 s_Color3;
static Vector3 s_Vector3;
// --------------------------------------------------------------------------------------------
static Uint32 s_ColorR, s_ColorG, s_ColorB;
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
*/
Int32 m_ID;
/* --------------------------------------------------------------------------------------------
* User tag associated with this instance.
*/
String m_Tag;
/* --------------------------------------------------------------------------------------------
* User data associated with this instance.
*/
Object m_Data;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CForcefield(Int32 id);
public:
/* --------------------------------------------------------------------------------------------
* Maximum possible number that could represent an identifier for this entity type.
*/
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
CForcefield(const CForcefield &) = delete;
/* --------------------------------------------------------------------------------------------
* Move constructor. (disabled)
*/
CForcefield(CForcefield &&) = delete;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~CForcefield();
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
CForcefield & operator = (const CForcefield &) = delete;
/* --------------------------------------------------------------------------------------------
* Move assignment operator. (disabled)
*/
CForcefield & operator = (CForcefield &&) = delete;
/* --------------------------------------------------------------------------------------------
* See whether this instance manages a valid entity otherwise throw an exception.
*/
void Validate() const
{
if (INVALID_ENTITY(m_ID))
{
STHROWF("Invalid forcefield reference [%s]", m_Tag.c_str());
}
}
/* --------------------------------------------------------------------------------------------
* Used by the script engine to compare two instances of this type.
*/
Int32 Cmp(const CForcefield & o) const;
/* --------------------------------------------------------------------------------------------
* Used by the script engine to convert an instance of this type to a string.
*/
const String & ToString() const;
/* --------------------------------------------------------------------------------------------
* Used by the script engine to retrieve the name from instances of this type.
*/
static SQInteger Typename(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Retrieve the identifier of the entity managed by this instance.
*/
Int32 GetID() const
{
return m_ID;
}
/* --------------------------------------------------------------------------------------------
* Check whether this instance manages a valid entity.
*/
bool IsActive() const
{
return VALID_ENTITY(m_ID);
}
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user tag.
*/
const String & GetTag() const;
/* --------------------------------------------------------------------------------------------
* Modify the associated user tag.
*/
void SetTag(CSStr tag);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user data.
*/
Object & GetData();
/* --------------------------------------------------------------------------------------------
* Modify the associated user data.
*/
void SetData(Object & data);
/* --------------------------------------------------------------------------------------------
* Destroy the managed forcefield entity.
*/
bool Destroy()
{
return Destroy(0, NullObject());
}
/* --------------------------------------------------------------------------------------------
* Destroy the managed forcefield entity.
*/
bool Destroy(Int32 header)
{
return Destroy(header, NullObject());
}
/* --------------------------------------------------------------------------------------------
* Destroy the managed forcefield entity.
*/
bool Destroy(Int32 header, Object & payload);
/* --------------------------------------------------------------------------------------------
* Bind to an event supported by this entity type.
*/
void BindEvent(Int32 evid, Object & env, Function & func) const;
/* --------------------------------------------------------------------------------------------
* See if the managed forcefield entity is streamed for the specified player.
*/
bool IsStreamedFor(CPlayer & player) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the world in which the managed forcefield entity exists.
*/
Int32 GetWorld() const;
/* --------------------------------------------------------------------------------------------
* Modify the world in which the managed forcefield entity exists.
*/
void SetWorld(Int32 world) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the color of the managed forcefield entity.
*/
const Color3 & GetColor() const;
/* --------------------------------------------------------------------------------------------
* Modify the color of the managed forcefield entity.
*/
void SetColor(const Color3 & col) const;
/* --------------------------------------------------------------------------------------------
* Modify the color of the managed forcefield entity.
*/
void SetColorEx(Uint8 r, Uint8 g, Uint8 b) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position of the managed forcefield entity.
*/
const Vector3 & GetPosition() const;
/* --------------------------------------------------------------------------------------------
* Modify the position of the managed forcefield entity.
*/
void SetPosition(const Vector3 & pos) const;
/* --------------------------------------------------------------------------------------------
* Modify the position of the managed forcefield entity.
*/
void SetPositionEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the radius of the managed forcefield entity.
*/
Float32 GetRadius() const;
/* --------------------------------------------------------------------------------------------
* Modify the radius of the managed forcefield entity.
*/
void SetRadius(Float32 radius) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the owner of the managed forcefield entity.
*/
Object & GetOwner() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the owner identifier of the managed forcefield entity.
*/
Int32 GetOwnerID() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the x axis of the managed forcefield entity.
*/
Float32 GetPosX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the y axis of the managed forcefield entity.
*/
Float32 GetPosY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the z axis of the managed forcefield entity.
*/
Float32 GetPosZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the x axis of the managed forcefield entity.
*/
void SetPosX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the y axis of the managed forcefield entity.
*/
void SetPosY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the z axis of the managed forcefield entity.
*/
void SetPosZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the red color of the managed forcefield entity.
*/
Uint32 GetColR() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the green color of the managed forcefield entity.
*/
Uint32 GetColG() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the blue color of the managed forcefield entity.
*/
Uint32 GetColB() const;
/* --------------------------------------------------------------------------------------------
* Modify the red color of the managed forcefield entity.
*/
void SetColR(Uint32 r) const;
/* --------------------------------------------------------------------------------------------
* Modify the green color of the managed forcefield entity.
*/
void SetColG(Uint32 g) const;
/* --------------------------------------------------------------------------------------------
* Modify the blue color of the managed forcefield entity.
*/
void SetColB(Uint32 b) const;
};
} // Namespace:: SqMod
#endif // _ENTITY_FORCEFIELD_HPP_

View File

@@ -12,7 +12,7 @@ const Int32 CKeybind::Max = SQMOD_KEYBIND_POOL;
// ------------------------------------------------------------------------------------------------
SQInteger CKeybind::Typename(HSQUIRRELVM vm)
{
static SQChar name[] = _SC("SqKeybind");
static const SQChar name[] = _SC("SqKeybind");
sq_pushstring(vm, name, sizeof(name));
return 1;
}
@@ -35,11 +35,17 @@ CKeybind::~CKeybind()
Int32 CKeybind::Cmp(const CKeybind & o) const
{
if (m_ID == o.m_ID)
{
return 0;
}
else if (m_ID > o.m_ID)
{
return 1;
}
else
{
return -1;
}
}
// ------------------------------------------------------------------------------------------------
@@ -84,7 +90,7 @@ bool CKeybind::Destroy(Int32 header, Object & payload)
// Validate the managed identifier
Validate();
// Perform the requested operation
return _Core->DelKeybind(m_ID, header, payload);
return Core::Get().DelKeybind(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
@@ -93,7 +99,7 @@ void CKeybind::BindEvent(Int32 evid, Object & env, Function & func) const
// Validate the managed identifier
Validate();
// Obtain the function instance called for this event
Function & event = _Core->GetKeybindEvent(m_ID, evid);
Function & event = Core::Get().GetKeybindEvent(m_ID, evid);
// Is the specified callback function null?
if (func.IsNull())
{
@@ -112,7 +118,7 @@ Int32 CKeybind::GetFirst() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Core->GetKeybind(m_ID).mFirst;
return Core::Get().GetKeybind(m_ID).mFirst;
}
// ------------------------------------------------------------------------------------------------
@@ -121,7 +127,7 @@ Int32 CKeybind::GetSecond() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Core->GetKeybind(m_ID).mSecond;
return Core::Get().GetKeybind(m_ID).mSecond;
}
// ------------------------------------------------------------------------------------------------
@@ -130,7 +136,7 @@ Int32 CKeybind::GetThird() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Core->GetKeybind(m_ID).mThird;
return Core::Get().GetKeybind(m_ID).mThird;
}
// ------------------------------------------------------------------------------------------------
@@ -139,34 +145,34 @@ bool CKeybind::IsRelease() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Core->GetKeybind(m_ID).mRelease;
return Core::Get().GetKeybind(m_ID).mRelease;
}
// ------------------------------------------------------------------------------------------------
static Object & Keybind_CreateEx(Int32 slot, bool release, Int32 primary, Int32 secondary,
Int32 alternative)
{
return _Core->NewKeybind(slot, release, primary, secondary, alternative,
return Core::Get().NewKeybind(slot, release, primary, secondary, alternative,
SQMOD_CREATE_DEFAULT, NullObject());
}
static Object & Keybind_CreateEx(Int32 slot, bool release, Int32 primary, Int32 secondary,
Int32 alternative, Int32 header, Object & payload)
{
return _Core->NewKeybind(slot, release, primary, secondary, alternative, header, payload);
return Core::Get().NewKeybind(slot, release, primary, secondary, alternative, header, payload);
}
// ------------------------------------------------------------------------------------------------
static Object & Keybind_Create(bool release, Int32 primary, Int32 secondary, Int32 alternative)
{
return _Core->NewKeybind(-1, release, primary, secondary, alternative,
return Core::Get().NewKeybind(-1, release, primary, secondary, alternative,
SQMOD_CREATE_DEFAULT, NullObject());
}
static Object & Keybind_Create(bool release, Int32 primary, Int32 secondary, Int32 alternative,
Int32 header, Object & payload)
{
return _Core->NewKeybind(-1, release, primary, secondary, alternative, header, payload);
return Core::Get().NewKeybind(-1, release, primary, secondary, alternative, header, payload);
}
// ------------------------------------------------------------------------------------------------
@@ -178,8 +184,8 @@ static const Object & Keybind_FindByID(Int32 id)
STHROWF("The specified keybind identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Keybinds::const_iterator itr = _Core->GetKeybinds().cbegin();
Core::Keybinds::const_iterator end = _Core->GetKeybinds().cend();
Core::Keybinds::const_iterator itr = Core::Get().GetKeybinds().cbegin();
Core::Keybinds::const_iterator end = Core::Get().GetKeybinds().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
@@ -202,8 +208,8 @@ static const Object & Keybind_FindByTag(CSStr tag)
STHROWF("The specified keybind tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Keybinds::const_iterator itr = _Core->GetKeybinds().cbegin();
Core::Keybinds::const_iterator end = _Core->GetKeybinds().cend();
Core::Keybinds::const_iterator itr = Core::Get().GetKeybinds().cbegin();
Core::Keybinds::const_iterator end = Core::Get().GetKeybinds().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
@@ -223,8 +229,8 @@ static Array Keybind_FindActive()
// Remember the initial stack size
StackGuard sg;
// Obtain the ends of the entity pool
Core::Keybinds::const_iterator itr = _Core->GetKeybinds().cbegin();
Core::Keybinds::const_iterator end = _Core->GetKeybinds().cend();
Core::Keybinds::const_iterator itr = Core::Get().GetKeybinds().cbegin();
Core::Keybinds::const_iterator end = Core::Get().GetKeybinds().cend();
// Allocate an empty array on the stack
sq_newarray(DefaultVM::Get(), 0);
// Process each entity in the pool

View File

@@ -19,7 +19,7 @@ const Int32 CObject::Max = SQMOD_OBJECT_POOL;
// ------------------------------------------------------------------------------------------------
SQInteger CObject::Typename(HSQUIRRELVM vm)
{
static SQChar name[] = _SC("SqObject");
static const SQChar name[] = _SC("SqObject");
sq_pushstring(vm, name, sizeof(name));
return 1;
}
@@ -27,7 +27,13 @@ SQInteger CObject::Typename(HSQUIRRELVM vm)
// ------------------------------------------------------------------------------------------------
CObject::CObject(Int32 id)
: m_ID(VALID_ENTITYGETEX(id, SQMOD_OBJECT_POOL))
, m_Tag(ToStrF("%d", id))
, m_Tag(ToStrF("%d", id)), m_Data()
, mMoveToDuration(0)
, mMoveByDuration(0)
, mRotateToDuration(0)
, mRotateByDuration(0)
, mRotateToEulerDuration(0)
, mRotateByEulerDuration(0)
{
/* ... */
}
@@ -42,11 +48,17 @@ CObject::~CObject()
Int32 CObject::Cmp(const CObject & o) const
{
if (m_ID == o.m_ID)
{
return 0;
}
else if (m_ID > o.m_ID)
{
return 1;
}
else
{
return -1;
}
}
// ------------------------------------------------------------------------------------------------
@@ -91,7 +103,7 @@ bool CObject::Destroy(Int32 header, Object & payload)
// Validate the managed identifier
Validate();
// Perform the requested operation
return _Core->DelObject(m_ID, header, payload);
return Core::Get().DelObject(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
@@ -100,7 +112,7 @@ void CObject::BindEvent(Int32 evid, Object & env, Function & func) const
// Validate the managed identifier
Validate();
// Obtain the function instance called for this event
Function & event = _Core->GetObjectEvent(m_ID, evid);
Function & event = Core::Get().GetObjectEvent(m_ID, evid);
// Is the specified callback function null?
if (func.IsNull())
{
@@ -173,7 +185,7 @@ void CObject::SetAlpha(Int32 alpha) const
}
// ------------------------------------------------------------------------------------------------
void CObject::SetAlphaEx(Int32 alpha, Int32 time) const
void CObject::SetAlphaEx(Int32 alpha, Uint32 time) const
{
// Validate the managed identifier
Validate();
@@ -182,7 +194,7 @@ void CObject::SetAlphaEx(Int32 alpha, Int32 time) const
}
// ------------------------------------------------------------------------------------------------
void CObject::MoveTo(const Vector3 & pos, Int32 time) const
void CObject::MoveTo(const Vector3 & pos, Uint32 time) const
{
// Validate the managed identifier
Validate();
@@ -191,7 +203,7 @@ void CObject::MoveTo(const Vector3 & pos, Int32 time) const
}
// ------------------------------------------------------------------------------------------------
void CObject::MoveToEx(Float32 x, Float32 y, Float32 z, Int32 time) const
void CObject::MoveToEx(Float32 x, Float32 y, Float32 z, Uint32 time) const
{
// Validate the managed identifier
Validate();
@@ -200,7 +212,7 @@ void CObject::MoveToEx(Float32 x, Float32 y, Float32 z, Int32 time) const
}
// ------------------------------------------------------------------------------------------------
void CObject::MoveBy(const Vector3 & pos, Int32 time) const
void CObject::MoveBy(const Vector3 & pos, Uint32 time) const
{
// Validate the managed identifier
Validate();
@@ -209,7 +221,7 @@ void CObject::MoveBy(const Vector3 & pos, Int32 time) const
}
// ------------------------------------------------------------------------------------------------
void CObject::MoveByEx(Float32 x, Float32 y, Float32 z, Int32 time) const
void CObject::MoveByEx(Float32 x, Float32 y, Float32 z, Uint32 time) const
{
// Validate the managed identifier
Validate();
@@ -222,10 +234,10 @@ const Vector3 & CObject::GetPosition()
{
// Validate the managed identifier
Validate();
// Clear previous position information
// Clear previous information, if any
s_Vector3.Clear();
// Query the server for the position values
_Func->GetObjectPos(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z);
// Query the server for the values
_Func->GetObjectPosition(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z);
// Return the requested information
return s_Vector3;
}
@@ -236,7 +248,7 @@ void CObject::SetPosition(const Vector3 & pos) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetObjectPos(m_ID, pos.x, pos.y, pos.z);
_Func->SetObjectPosition(m_ID, pos.x, pos.y, pos.z);
}
// ------------------------------------------------------------------------------------------------
@@ -245,79 +257,79 @@ void CObject::SetPositionEx(Float32 x, Float32 y, Float32 z) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetObjectPos(m_ID, x, y, z);
_Func->SetObjectPosition(m_ID, x, y, z);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateTo(const Quaternion & rot, Int32 time) const
void CObject::RotateTo(const Quaternion & rot, Uint32 time) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotObjectTo(m_ID, rot.x, rot.y, rot.z, rot.w, time);
_Func->RotateObjectTo(m_ID, rot.x, rot.y, rot.z, rot.w, time);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateToEx(Float32 x, Float32 y, Float32 z, Float32 w, Int32 time) const
void CObject::RotateToEx(Float32 x, Float32 y, Float32 z, Float32 w, Uint32 time) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotObjectTo(m_ID, x, y, z, w, time);
_Func->RotateObjectTo(m_ID, x, y, z, w, time);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateToEuler(const Vector3 & rot, Int32 time) const
void CObject::RotateToEuler(const Vector3 & rot, Uint32 time) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotObjectToEuler(m_ID, rot.x, rot.y, rot.z, time);
_Func->RotateObjectToEuler(m_ID, rot.x, rot.y, rot.z, time);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateToEulerEx(Float32 x, Float32 y, Float32 z, Int32 time) const
void CObject::RotateToEulerEx(Float32 x, Float32 y, Float32 z, Uint32 time) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotObjectToEuler(m_ID, x, y, z, time);
_Func->RotateObjectToEuler(m_ID, x, y, z, time);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateBy(const Quaternion & rot, Int32 time) const
void CObject::RotateBy(const Quaternion & rot, Uint32 time) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotObjectBy(m_ID, rot.x, rot.y, rot.z, rot.w, time);
_Func->RotateObjectBy(m_ID, rot.x, rot.y, rot.z, rot.w, time);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateByEx(Float32 x, Float32 y, Float32 z, Float32 w, Int32 time) const
void CObject::RotateByEx(Float32 x, Float32 y, Float32 z, Float32 w, Uint32 time) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotObjectBy(m_ID, x, y, z, w, time);
_Func->RotateObjectBy(m_ID, x, y, z, w, time);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateByEuler(const Vector3 & rot, Int32 time) const
void CObject::RotateByEuler(const Vector3 & rot, Uint32 time) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotObjectByEuler(m_ID, rot.x, rot.y, rot.z, time);
_Func->RotateObjectByEuler(m_ID, rot.x, rot.y, rot.z, time);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateByEulerEx(Float32 x, Float32 y, Float32 z, Int32 time) const
void CObject::RotateByEulerEx(Float32 x, Float32 y, Float32 z, Uint32 time) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotObjectByEuler(m_ID, x, y, z, time);
_Func->RotateObjectByEuler(m_ID, x, y, z, time);
}
// ------------------------------------------------------------------------------------------------
@@ -325,10 +337,10 @@ const Quaternion & CObject::GetRotation()
{
// Validate the managed identifier
Validate();
// Clear previous rotation information
// Clear previous information, if any
s_Quaternion.Clear();
// Query the server for the rotation values
_Func->GetObjectRot(m_ID, &s_Quaternion.x, &s_Quaternion.y, &s_Quaternion.z, &s_Quaternion.w);
// Query the server for the values
_Func->GetObjectRotation(m_ID, &s_Quaternion.x, &s_Quaternion.y, &s_Quaternion.z, &s_Quaternion.w);
// Return the requested information
return s_Quaternion;
}
@@ -338,10 +350,10 @@ const Vector3 & CObject::GetRotationEuler()
{
// Validate the managed identifier
Validate();
// Clear previous rotation information
// Clear previous information, if any
s_Vector3.Clear();
// Query the server for the rotation values
_Func->GetObjectRotEuler(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z);
// Query the server for the values
_Func->GetObjectRotationEuler(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z);
// Return the requested information
return s_Vector3;
}
@@ -352,7 +364,7 @@ bool CObject::GetShotReport() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->IsObjectShotReport(m_ID);
return _Func->IsObjectShotReportEnabled(m_ID);
}
// ------------------------------------------------------------------------------------------------
@@ -361,214 +373,434 @@ void CObject::SetShotReport(bool toggle) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetObjectShotReport(m_ID, toggle);
_Func->SetObjectShotReportEnabled(m_ID, toggle);
}
// ------------------------------------------------------------------------------------------------
bool CObject::GetBumpReport() const
bool CObject::GetTouchedReport() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->IsObjectBumpReport(m_ID);
return _Func->IsObjectTouchedReportEnabled(m_ID);
}
// ------------------------------------------------------------------------------------------------
void CObject::SetBumpReport(bool toggle) const
void CObject::SetTouchedReport(bool toggle) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetObjectBumpReport(m_ID, toggle);
_Func->SetObjectTouchedReportEnabled(m_ID, toggle);
}
// ------------------------------------------------------------------------------------------------
Float32 CObject::GetPosX() const
Float32 CObject::GetPositionX() const
{
// Validate the managed identifier
Validate();
// Clear previous position information, if any
s_Vector3.x = 0;
// Clear previous information, if any
s_Vector3.x = 0.0f;
// Query the server for the requested component value
_Func->GetObjectPos(m_ID, &s_Vector3.x, NULL, NULL);
_Func->GetObjectPosition(m_ID, &s_Vector3.x, nullptr, nullptr);
// Return the requested information
return s_Vector3.x;
}
// ------------------------------------------------------------------------------------------------
Float32 CObject::GetPosY() const
Float32 CObject::GetPositionY() const
{
// Validate the managed identifier
Validate();
// Clear previous position information, if any
s_Vector3.y = 0;
// Clear previous information, if any
s_Vector3.y = 0.0f;
// Query the server for the requested component value
_Func->GetObjectPos(m_ID, NULL, &s_Vector3.y, NULL);
_Func->GetObjectPosition(m_ID, nullptr, &s_Vector3.y, nullptr);
// Return the requested information
return s_Vector3.y;
}
// ------------------------------------------------------------------------------------------------
Float32 CObject::GetPosZ() const
Float32 CObject::GetPositionZ() const
{
// Validate the managed identifier
Validate();
// Clear previous position information, if any
s_Vector3.z = 0;
// Clear previous information, if any
s_Vector3.z = 0.0f;
// Query the server for the requested component value
_Func->GetObjectPos(m_ID, NULL, NULL, &s_Vector3.z);
_Func->GetObjectPosition(m_ID, nullptr, nullptr, &s_Vector3.z);
// Return the requested information
return s_Vector3.z;
}
// ------------------------------------------------------------------------------------------------
void CObject::SetPosX(Float32 x) const
void CObject::SetPositionX(Float32 x) const
{
// Validate the managed identifier
Validate();
// Retrieve the current values for unchanged components
_Func->GetObjectPos(m_ID, NULL, &s_Vector3.y, &s_Vector3.z);
_Func->GetObjectPosition(m_ID, nullptr, &s_Vector3.y, &s_Vector3.z);
// Perform the requested operation
_Func->SetObjectPos(m_ID, x, s_Vector3.y, s_Vector3.z);
_Func->SetObjectPosition(m_ID, x, s_Vector3.y, s_Vector3.z);
}
// ------------------------------------------------------------------------------------------------
void CObject::SetPosY(Float32 y) const
void CObject::SetPositionY(Float32 y) const
{
// Validate the managed identifier
Validate();
// Retrieve the current values for unchanged components
_Func->GetObjectPos(m_ID, &s_Vector3.x, NULL, &s_Vector3.z);
_Func->GetObjectPosition(m_ID, &s_Vector3.x, nullptr, &s_Vector3.z);
// Perform the requested operation
_Func->SetObjectPos(m_ID, s_Vector3.x, y, s_Vector3.z);
_Func->SetObjectPosition(m_ID, s_Vector3.x, y, s_Vector3.z);
}
// ------------------------------------------------------------------------------------------------
void CObject::SetPosZ(Float32 z) const
void CObject::SetPositionZ(Float32 z) const
{
// Validate the managed identifier
Validate();
// Retrieve the current values for unchanged components
_Func->GetObjectPos(m_ID, &s_Vector3.x, &s_Vector3.y, NULL);
_Func->GetObjectPosition(m_ID, &s_Vector3.x, &s_Vector3.y, nullptr);
// Perform the requested operation
_Func->SetObjectPos(m_ID, s_Vector3.z, s_Vector3.y, z);
_Func->SetObjectPosition(m_ID, s_Vector3.z, s_Vector3.y, z);
}
// ------------------------------------------------------------------------------------------------
Float32 CObject::GetRotX() const
Float32 CObject::GetRotationX() const
{
// Validate the managed identifier
Validate();
// Clear previous rotation information, if any
s_Quaternion.x = 0;
// Clear previous information, if any
s_Quaternion.x = 0.0f;
// Query the server for the requested component value
_Func->GetObjectRot(m_ID, &s_Quaternion.x, NULL, NULL, NULL);
_Func->GetObjectRotation(m_ID, &s_Quaternion.x, nullptr, nullptr, nullptr);
// Return the requested information
return s_Quaternion.x;
}
// ------------------------------------------------------------------------------------------------
Float32 CObject::GetRotY() const
Float32 CObject::GetRotationY() const
{
// Validate the managed identifier
Validate();
// Clear previous rotation information, if any
s_Quaternion.y = 0;
// Clear previous information, if any
s_Quaternion.y = 0.0f;
// Query the server for the requested component value
_Func->GetObjectRot(m_ID, NULL, &s_Quaternion.y, NULL, NULL);
_Func->GetObjectRotation(m_ID, nullptr, &s_Quaternion.y, nullptr, nullptr);
// Return the requested information
return s_Quaternion.y;
}
// ------------------------------------------------------------------------------------------------
Float32 CObject::GetRotZ() const
Float32 CObject::GetRotationZ() const
{
// Validate the managed identifier
Validate();
// Clear previous rotation information, if any
s_Quaternion.z = 0;
// Clear previous information, if any
s_Quaternion.z = 0.0f;
// Query the server for the requested component value
_Func->GetObjectRot(m_ID, NULL, NULL, &s_Quaternion.z, NULL);
_Func->GetObjectRotation(m_ID, nullptr, nullptr, &s_Quaternion.z, nullptr);
// Return the requested information
return s_Quaternion.z;
}
// ------------------------------------------------------------------------------------------------
Float32 CObject::GetRotW() const
Float32 CObject::GetRotationW() const
{
// Validate the managed identifier
Validate();
// Clear previous rotation information, if any
s_Quaternion.w = 0;
// Clear previous information, if any
s_Quaternion.w = 0.0f;
// Query the server for the requested component value
_Func->GetObjectRot(m_ID, NULL, NULL, NULL, &s_Quaternion.w);
_Func->GetObjectRotation(m_ID, nullptr, nullptr, nullptr, &s_Quaternion.w);
// Return the requested information
return s_Quaternion.w;
}
// ------------------------------------------------------------------------------------------------
Float32 CObject::GetERotX() const
Float32 CObject::GetEulerRotationX() const
{
// Validate the managed identifier
Validate();
// Clear previous rotation information, if any
s_Vector3.x = 0;
// Clear previous information, if any
s_Vector3.x = 0.0f;
// Query the server for the requested component value
_Func->GetObjectRotEuler(m_ID, &s_Vector3.x, NULL, NULL);
_Func->GetObjectRotationEuler(m_ID, &s_Vector3.x, nullptr, nullptr);
// Return the requested information
return s_Vector3.x;
}
// ------------------------------------------------------------------------------------------------
Float32 CObject::GetERotY() const
Float32 CObject::GetEulerRotationY() const
{
// Validate the managed identifier
Validate();
// Clear previous rotation information, if any
s_Vector3.y = 0;
// Clear previous information, if any
s_Vector3.y = 0.0f;
// Query the server for the requested component value
_Func->GetObjectRotEuler(m_ID, NULL, &s_Vector3.y, NULL);
_Func->GetObjectRotationEuler(m_ID, nullptr, &s_Vector3.y, nullptr);
// Return the requested information
return s_Vector3.y;
}
// ------------------------------------------------------------------------------------------------
Float32 CObject::GetERotZ() const
Float32 CObject::GetEulerRotationZ() const
{
// Validate the managed identifier
Validate();
// Clear previous rotation information, if any
s_Vector3.z = 0;
// Clear previous information, if any
s_Vector3.z = 0.0f;
// Query the server for the requested component value
_Func->GetObjectRotEuler(m_ID, NULL, NULL, &s_Vector3.z);
_Func->GetObjectRotationEuler(m_ID, nullptr, nullptr, &s_Vector3.z);
// Return the requested information
return s_Vector3.z;
}
// ------------------------------------------------------------------------------------------------
void CObject::MoveToX(Float32 x) const
{
// Validate the managed identifier
Validate();
// Clear previous information, if any
s_Vector3.Clear();
// Retrieve the current values for unchanged components
_Func->GetObjectPosition(m_ID, nullptr, &s_Vector3.y, &s_Vector3.z);
// Perform the requested operation
_Func->MoveObjectTo(m_ID, x, s_Vector3.y, s_Vector3.z, mMoveToDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::MoveToY(Float32 y) const
{
// Validate the managed identifier
Validate();
// Clear previous information, if any
s_Vector3.Clear();
// Retrieve the current values for unchanged components
_Func->GetObjectPosition(m_ID, &s_Vector3.x, nullptr, &s_Vector3.z);
// Perform the requested operation
_Func->MoveObjectTo(m_ID, s_Vector3.x, y, s_Vector3.z, mMoveToDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::MoveToZ(Float32 z) const
{
// Validate the managed identifier
Validate();
// Clear previous information, if any
s_Vector3.Clear();
// Retrieve the current values for unchanged components
_Func->GetObjectPosition(m_ID, &s_Vector3.x, &s_Vector3.y, nullptr);
// Perform the requested operation
_Func->MoveObjectTo(m_ID, s_Vector3.z, s_Vector3.y, z, mMoveToDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::MoveByX(Float32 x) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->MoveObjectBy(m_ID, x, 0.0f, 0.0f, mMoveByDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::MoveByY(Float32 y) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->MoveObjectBy(m_ID, 0.0f, y, 0.0f, mMoveByDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::MoveByZ(Float32 z) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->MoveObjectBy(m_ID, 0.0f, 0.0f, z, mMoveByDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateToX(Float32 x) const
{
// Validate the managed identifier
Validate();
// Clear previous information, if any
s_Quaternion.Clear();
// Retrieve the current values for unchanged components
_Func->GetObjectRotation(m_ID, nullptr, &s_Quaternion.y, &s_Quaternion.z, &s_Quaternion.w);
// Perform the requested operation
_Func->RotateObjectTo(m_ID, x, s_Quaternion.y, s_Quaternion.z, s_Quaternion.w, mRotateToDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateToY(Float32 y) const
{
// Validate the managed identifier
Validate();
// Clear previous information, if any
s_Quaternion.Clear();
// Retrieve the current values for unchanged components
_Func->GetObjectRotation(m_ID, &s_Quaternion.x, nullptr, &s_Quaternion.z, &s_Quaternion.w);
// Perform the requested operation
_Func->RotateObjectTo(m_ID, s_Quaternion.x, y, s_Quaternion.z, s_Quaternion.w, mRotateToDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateToZ(Float32 z) const
{
// Validate the managed identifier
Validate();
// Clear previous information, if any
s_Quaternion.Clear();
// Retrieve the current values for unchanged components
_Func->GetObjectRotation(m_ID, &s_Quaternion.x, &s_Quaternion.y, nullptr, &s_Quaternion.w);
// Perform the requested operation
_Func->RotateObjectTo(m_ID, s_Quaternion.x, s_Quaternion.y, z, s_Quaternion.w, mRotateToDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateToW(Float32 w) const
{
// Validate the managed identifier
Validate();
// Clear previous information, if any
s_Quaternion.Clear();
// Retrieve the current values for unchanged components
_Func->GetObjectRotation(m_ID, &s_Quaternion.x, &s_Quaternion.y, &s_Quaternion.z, nullptr);
// Perform the requested operation
_Func->RotateObjectTo(m_ID, s_Quaternion.x, s_Quaternion.y, s_Quaternion.z, w, mRotateToDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateByX(Float32 x) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectBy(m_ID, x, 0.0f, 0.0f, 0.0f, mRotateByDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateByY(Float32 y) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectBy(m_ID, 0.0f, y, 0.0f, 0.0f, mRotateByDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateByZ(Float32 z) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectBy(m_ID, 0.0f, 0.0f, z, 0.0f, mRotateByDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateByW(Float32 w) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectBy(m_ID, 0.0f, 0.0f, 0.0f, w, mRotateByDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateToEulerX(Float32 x) const
{
// Validate the managed identifier
Validate();
// Clear previous information, if any
s_Vector3.Clear();
// Retrieve the current values for unchanged components
_Func->GetObjectRotationEuler(m_ID, nullptr, &s_Vector3.y, &s_Vector3.z);
// Perform the requested operation
_Func->RotateObjectToEuler(m_ID, x, s_Vector3.y, s_Vector3.z, mRotateToEulerDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateToEulerY(Float32 y) const
{
// Validate the managed identifier
Validate();
// Clear previous information, if any
s_Vector3.Clear();
// Retrieve the current values for unchanged components
_Func->GetObjectRotationEuler(m_ID, &s_Vector3.x, nullptr, &s_Vector3.z);
// Perform the requested operation
_Func->RotateObjectToEuler(m_ID, s_Vector3.x, y, s_Vector3.z, mRotateToEulerDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateToEulerZ(Float32 z) const
{
// Validate the managed identifier
Validate();
// Clear previous information, if any
s_Vector3.Clear();
// Retrieve the current values for unchanged components
_Func->GetObjectRotationEuler(m_ID, &s_Vector3.x, &s_Vector3.y, nullptr);
// Perform the requested operation
_Func->RotateObjectToEuler(m_ID, s_Vector3.z, s_Vector3.y, z, mRotateToEulerDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateByEulerX(Float32 x) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectByEuler(m_ID, x, 0.0f, 0.0f, mRotateByEulerDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateByEulerY(Float32 y) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectByEuler(m_ID, 0.0f, y, 0.0f, mRotateByEulerDuration);
}
// ------------------------------------------------------------------------------------------------
void CObject::RotateByEulerZ(Float32 z) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateObjectByEuler(m_ID, 0.0f, 0.0f, z, mRotateByEulerDuration);
}
// ------------------------------------------------------------------------------------------------
static Object & Object_CreateEx(Int32 model, Int32 world, Float32 x, Float32 y, Float32 z,
Int32 alpha)
{
return _Core->NewObject(model, world, x, y, z, alpha, SQMOD_CREATE_DEFAULT, NullObject());
return Core::Get().NewObject(model, world, x, y, z, alpha, SQMOD_CREATE_DEFAULT, NullObject());
}
static Object & Object_CreateEx(Int32 model, Int32 world, Float32 x, Float32 y, Float32 z,
Int32 alpha, Int32 header, Object & payload)
{
return _Core->NewObject(model, world, x, y, z, alpha, header, payload);
return Core::Get().NewObject(model, world, x, y, z, alpha, header, payload);
}
// ------------------------------------------------------------------------------------------------
static Object & Object_Create(Int32 model, Int32 world, const Vector3 & pos, Int32 alpha)
{
return _Core->NewObject(model, world, pos.x, pos.y, pos.z, alpha,
return Core::Get().NewObject(model, world, pos.x, pos.y, pos.z, alpha,
SQMOD_CREATE_DEFAULT, NullObject());
}
static Object & Object_Create(Int32 model, Int32 world, const Vector3 & pos, Int32 alpha,
Int32 header, Object & payload)
{
return _Core->NewObject(model, world, pos.x, pos.y, pos.z, alpha, header, payload);
return Core::Get().NewObject(model, world, pos.x, pos.y, pos.z, alpha, header, payload);
}
// ------------------------------------------------------------------------------------------------
@@ -580,8 +812,8 @@ static const Object & Object_FindByID(Int32 id)
STHROWF("The specified object identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Objects::const_iterator itr = _Core->GetObjects().cbegin();
Core::Objects::const_iterator end = _Core->GetObjects().cend();
Core::Objects::const_iterator itr = Core::Get().GetObjects().cbegin();
Core::Objects::const_iterator end = Core::Get().GetObjects().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
@@ -602,8 +834,8 @@ static const Object & Object_FindByTag(CSStr tag)
if (!tag || *tag == '\0')
STHROWF("The specified object tag is invalid: null/empty");
// Obtain the ends of the entity pool
Core::Objects::const_iterator itr = _Core->GetObjects().cbegin();
Core::Objects::const_iterator end = _Core->GetObjects().cend();
Core::Objects::const_iterator itr = Core::Get().GetObjects().cbegin();
Core::Objects::const_iterator end = Core::Get().GetObjects().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
@@ -623,8 +855,8 @@ static Array Object_FindActive()
// Remember the initial stack size
StackGuard sg;
// Obtain the ends of the entity pool
Core::Objects::const_iterator itr = _Core->GetObjects().cbegin();
Core::Objects::const_iterator end = _Core->GetObjects().cend();
Core::Objects::const_iterator itr = Core::Get().GetObjects().cbegin();
Core::Objects::const_iterator end = Core::Get().GetObjects().cend();
// Allocate an empty array on the stack
sq_newarray(DefaultVM::Get(), 0);
// Process each entity in the pool
@@ -657,6 +889,13 @@ void Register_CObject(HSQUIRRELVM vm)
.Func(_SC("_tostring"), &CObject::ToString)
// Static Values
.SetStaticValue(_SC("MaxID"), CObject::Max)
// Member Variables
.Var(_SC("MoveToDuration"), &CObject::mMoveToDuration)
.Var(_SC("MoveByDuration"), &CObject::mMoveByDuration)
.Var(_SC("RotateToDuration"), &CObject::mRotateToDuration)
.Var(_SC("RotateByDuration"), &CObject::mRotateByDuration)
.Var(_SC("RotateToEulerDuration"), &CObject::mRotateToEulerDuration)
.Var(_SC("RotateByEulerDuration"), &CObject::mRotateByEulerDuration)
// Core Properties
.Prop(_SC("ID"), &CObject::GetID)
.Prop(_SC("Tag"), &CObject::GetTag, &CObject::SetTag)
@@ -674,49 +913,71 @@ void Register_CObject(HSQUIRRELVM vm)
.Prop(_SC("Alpha"), &CObject::GetAlpha, &CObject::SetAlpha)
.Prop(_SC("Pos"), &CObject::GetPosition, &CObject::SetPosition)
.Prop(_SC("Position"), &CObject::GetPosition, &CObject::SetPosition)
.Prop(_SC("ERot"), &CObject::GetRotation)
.Prop(_SC("Rot"), &CObject::GetRotation)
.Prop(_SC("Rotation"), &CObject::GetRotation)
.Prop(_SC("RotationEuler"), &CObject::GetRotationEuler)
.Prop(_SC("EulerRot"), &CObject::GetRotationEuler)
.Prop(_SC("EulerRotation"), &CObject::GetRotationEuler)
.Prop(_SC("ShotReport"), &CObject::GetShotReport, &CObject::SetShotReport)
.Prop(_SC("BumpReport"), &CObject::GetBumpReport, &CObject::SetBumpReport)
.Prop(_SC("X"), &CObject::GetPosX, &CObject::SetPosX)
.Prop(_SC("Y"), &CObject::GetPosY, &CObject::SetPosY)
.Prop(_SC("Z"), &CObject::GetPosZ, &CObject::SetPosZ)
.Prop(_SC("RX"), &CObject::GetRotX)
.Prop(_SC("RY"), &CObject::GetRotY)
.Prop(_SC("RZ"), &CObject::GetRotZ)
.Prop(_SC("RW"), &CObject::GetRotW)
.Prop(_SC("EX"), &CObject::GetERotX)
.Prop(_SC("EY"), &CObject::GetERotY)
.Prop(_SC("EZ"), &CObject::GetERotZ)
.Prop(_SC("BumpReport"), &CObject::GetTouchedReport, &CObject::SetTouchedReport)
.Prop(_SC("TouchedReport"), &CObject::GetTouchedReport, &CObject::SetTouchedReport)
.Prop(_SC("PosX"), &CObject::GetPositionX, &CObject::SetPositionX)
.Prop(_SC("PosY"), &CObject::GetPositionY, &CObject::SetPositionY)
.Prop(_SC("PosZ"), &CObject::GetPositionZ, &CObject::SetPositionZ)
.Prop(_SC("RotX"), &CObject::GetRotationX)
.Prop(_SC("RotY"), &CObject::GetRotationY)
.Prop(_SC("RotZ"), &CObject::GetRotationZ)
.Prop(_SC("RotW"), &CObject::GetRotationW)
.Prop(_SC("EulerRotX"), &CObject::GetEulerRotationX)
.Prop(_SC("EulerRotY"), &CObject::GetEulerRotationY)
.Prop(_SC("EulerRotZ"), &CObject::GetEulerRotationZ)
.Prop(_SC("MoveToX"), &CObject::GetPositionX, &CObject::MoveToX)
.Prop(_SC("MoveToY"), &CObject::GetPositionY, &CObject::MoveToY)
.Prop(_SC("MoveToZ"), &CObject::GetPositionZ, &CObject::MoveToZ)
.Prop(_SC("MoveByX"), &CObject::GetPositionX, &CObject::MoveByX)
.Prop(_SC("MoveByY"), &CObject::GetPositionY, &CObject::MoveByY)
.Prop(_SC("MoveByZ"), &CObject::GetPositionZ, &CObject::MoveByZ)
.Prop(_SC("RotateToX"), &CObject::GetRotationX, &CObject::RotateToX)
.Prop(_SC("RotateToY"), &CObject::GetRotationY, &CObject::RotateToY)
.Prop(_SC("RotateToZ"), &CObject::GetRotationZ, &CObject::RotateToZ)
.Prop(_SC("RotateToW"), &CObject::GetRotationW, &CObject::RotateToW)
.Prop(_SC("RotateByX"), &CObject::GetRotationX, &CObject::RotateByX)
.Prop(_SC("RotateByY"), &CObject::GetRotationY, &CObject::RotateByY)
.Prop(_SC("RotateByZ"), &CObject::GetRotationZ, &CObject::RotateByZ)
.Prop(_SC("RotateByW"), &CObject::GetRotationW, &CObject::RotateByW)
.Prop(_SC("RotateToEulerX"), &CObject::GetEulerRotationX, &CObject::RotateToEulerX)
.Prop(_SC("RotateToEulerY"), &CObject::GetEulerRotationY, &CObject::RotateToEulerY)
.Prop(_SC("RotateToEulerZ"), &CObject::GetEulerRotationZ, &CObject::RotateToEulerZ)
.Prop(_SC("RotateByEulerX"), &CObject::GetEulerRotationX, &CObject::RotateByEulerX)
.Prop(_SC("RotateByEulerY"), &CObject::GetEulerRotationY, &CObject::RotateByEulerY)
.Prop(_SC("RotateByEulerZ"), &CObject::GetEulerRotationZ, &CObject::RotateByEulerZ)
// Member Methods
.Func(_SC("StreamedFor"), &CObject::IsStreamedFor)
.Func(_SC("SetAlpha"), &CObject::SetAlphaEx)
.Func(_SC("SetPosition"), &CObject::SetPositionEx)
// Member Overloads
.Overload< void (CObject::*)(const Vector3 &, Int32) const >
.Overload< void (CObject::*)(const Vector3 &, Uint32) const >
(_SC("MoveTo"), &CObject::MoveTo)
.Overload< void (CObject::*)(Float32, Float32, Float32, Int32) const >
.Overload< void (CObject::*)(Float32, Float32, Float32, Uint32) const >
(_SC("MoveTo"), &CObject::MoveToEx)
.Overload< void (CObject::*)(const Vector3 &, Int32) const >
.Overload< void (CObject::*)(const Vector3 &, Uint32) const >
(_SC("MoveBy"), &CObject::MoveBy)
.Overload< void (CObject::*)(Float32, Float32, Float32, Int32) const >
.Overload< void (CObject::*)(Float32, Float32, Float32, Uint32) const >
(_SC("MoveBy"), &CObject::MoveByEx)
.Overload< void (CObject::*)(const Quaternion &, Int32) const >
.Overload< void (CObject::*)(const Quaternion &, Uint32) const >
(_SC("RotateTo"), &CObject::RotateTo)
.Overload< void (CObject::*)(Float32, Float32, Float32, Float32, Int32) const >
.Overload< void (CObject::*)(Float32, Float32, Float32, Float32, Uint32) const >
(_SC("RotateTo"), &CObject::RotateToEx)
.Overload< void (CObject::*)(const Vector3 &, Int32) const >
.Overload< void (CObject::*)(const Vector3 &, Uint32) const >
(_SC("RotateToEuler"), &CObject::RotateToEuler)
.Overload< void (CObject::*)(Float32, Float32, Float32, Int32) const >
.Overload< void (CObject::*)(Float32, Float32, Float32, Uint32) const >
(_SC("RotateToEuler"), &CObject::RotateToEulerEx)
.Overload< void (CObject::*)(const Quaternion &, Int32) const >
.Overload< void (CObject::*)(const Quaternion &, Uint32) const >
(_SC("RotateBy"), &CObject::RotateBy)
.Overload< void (CObject::*)(Float32, Float32, Float32, Float32, Int32) const >
.Overload< void (CObject::*)(Float32, Float32, Float32, Float32, Uint32) const >
(_SC("RotateBy"), &CObject::RotateByEx)
.Overload< void (CObject::*)(const Vector3 &, Int32) const >
.Overload< void (CObject::*)(const Vector3 &, Uint32) const >
(_SC("RotateByEuler"), &CObject::RotateByEuler)
.Overload< void (CObject::*)(Float32, Float32, Float32, Int32) const >
.Overload< void (CObject::*)(Float32, Float32, Float32, Uint32) const >
(_SC("RotateByEuler"), &CObject::RotateByEulerEx)
// Static Functions
.StaticFunc(_SC("FindByID"), &Object_FindByID)

View File

@@ -43,6 +43,24 @@ private:
public:
/* --------------------------------------------------------------------------------------------
* The default duration to use when moving the object.
*/
Uint32 mMoveToDuration;
Uint32 mMoveByDuration;
/* --------------------------------------------------------------------------------------------
* The default duration to use when rotating the object to Quaternion.
*/
Uint32 mRotateToDuration;
Uint32 mRotateByDuration;
/* --------------------------------------------------------------------------------------------
* The default duration to use when rotating the object to Euler.
*/
Uint32 mRotateToEulerDuration;
Uint32 mRotateByEulerDuration;
/* --------------------------------------------------------------------------------------------
* Maximum possible number that could represent an identifier for this entity type.
*/
@@ -194,27 +212,27 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the alpha of the managed object entity over the specified time.
*/
void SetAlphaEx(Int32 alpha, Int32 time) const;
void SetAlphaEx(Int32 alpha, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Move the managed object entity to the specified position over the specified time.
*/
void MoveTo(const Vector3 & pos, Int32 time) const;
void MoveTo(const Vector3 & pos, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Move the managed object entity to the specified position over the specified time.
*/
void MoveToEx(Float32 x, Float32 y, Float32 z, Int32 time) const;
void MoveToEx(Float32 x, Float32 y, Float32 z, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Move the managed object entity by the specified position over the specified time.
*/
void MoveBy(const Vector3 & pos, Int32 time) const;
void MoveBy(const Vector3 & pos, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Move the managed object entity by the specified position over the specified time.
*/
void MoveByEx(Float32 x, Float32 y, Float32 z, Int32 time) const;
void MoveByEx(Float32 x, Float32 y, Float32 z, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position of the managed object entity.
@@ -234,42 +252,42 @@ public:
/* --------------------------------------------------------------------------------------------
* Rotate the managed object entity to the specified rotation over the specified time.
*/
void RotateTo(const Quaternion & rot, Int32 time) const;
void RotateTo(const Quaternion & rot, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the managed object entity to the specified rotation over the specified time.
*/
void RotateToEx(Float32 x, Float32 y, Float32 z, Float32 w, Int32 time) const;
void RotateToEx(Float32 x, Float32 y, Float32 z, Float32 w, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the managed object entity to the specified euler rotation over the specified time.
* Rotate the managed object entity to the specified Euler rotation over the specified time.
*/
void RotateToEuler(const Vector3 & rot, Int32 time) const;
void RotateToEuler(const Vector3 & rot, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the managed object entity to the specified euler rotation over the specified time.
* Rotate the managed object entity to the specified Euler rotation over the specified time.
*/
void RotateToEulerEx(Float32 x, Float32 y, Float32 z, Int32 time) const;
void RotateToEulerEx(Float32 x, Float32 y, Float32 z, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the managed object entity by the specified rotation over the specified time.
*/
void RotateBy(const Quaternion & rot, Int32 time) const;
void RotateBy(const Quaternion & rot, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the managed object entity by the specified rotation over the specified time.
*/
void RotateByEx(Float32 x, Float32 y, Float32 z, Float32 w, Int32 time) const;
void RotateByEx(Float32 x, Float32 y, Float32 z, Float32 w, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the managed object entity by the specified euler rotation over the specified time.
* Rotate the managed object entity by the specified Euler rotation over the specified time.
*/
void RotateByEuler(const Vector3 & rot, Int32 time) const;
void RotateByEuler(const Vector3 & rot, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the managed object entity by the specified euler rotation over the specified time.
* Rotate the managed object entity by the specified Euler rotation over the specified time.
*/
void RotateByEulerEx(Float32 x, Float32 y, Float32 z, Int32 time) const;
void RotateByEulerEx(Float32 x, Float32 y, Float32 z, Uint32 time) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation of the managed object entity.
@@ -277,7 +295,7 @@ public:
const Quaternion & GetRotation();
/* --------------------------------------------------------------------------------------------
* Retrieve the euler rotation of the managed object entity.
* Retrieve the Euler rotation of the managed object entity.
*/
const Vector3 & GetRotationEuler();
@@ -294,77 +312,177 @@ public:
/* --------------------------------------------------------------------------------------------
* See whether the managed object entity reports player bumps.
*/
bool GetBumpReport() const;
bool GetTouchedReport() const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed object entity reports player bumps.
*/
void SetBumpReport(bool toggle) const;
void SetTouchedReport(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the x axis of the managed object entity.
*/
Float32 GetPosX() const;
Float32 GetPositionX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the y axis of the managed object entity.
*/
Float32 GetPosY() const;
Float32 GetPositionY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the z axis of the managed object entity.
*/
Float32 GetPosZ() const;
Float32 GetPositionZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the x axis of the managed object entity.
*/
void SetPosX(Float32 x) const;
void SetPositionX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the y axis of the managed object entity.
*/
void SetPosY(Float32 y) const;
void SetPositionY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the z axis of the managed object entity.
*/
void SetPosZ(Float32 z) const;
void SetPositionZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation on the x axis of the managed object entity.
*/
Float32 GetRotX() const;
Float32 GetRotationX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation on the y axis of the managed object entity.
*/
Float32 GetRotY() const;
Float32 GetRotationY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation on the z axis of the managed object entity.
*/
Float32 GetRotZ() const;
Float32 GetRotationZ() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation amount of the managed object entity.
*/
Float32 GetRotW() const;
Float32 GetRotationW() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the euler rotation on the x axis of the managed object entity.
* Retrieve the Euler rotation on the x axis of the managed object entity.
*/
Float32 GetERotX() const;
Float32 GetEulerRotationX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the euler rotation on the y axis of the managed object entity.
* Retrieve the Euler rotation on the y axis of the managed object entity.
*/
Float32 GetERotY() const;
Float32 GetEulerRotationY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the euler rotation on the z axis of the managed object entity.
* Retrieve the Euler rotation on the z axis of the managed object entity.
*/
Float32 GetERotZ() const;
Float32 GetEulerRotationZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the x axis of the managed object entity.
*/
void MoveToX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the y axis of the managed object entity.
*/
void MoveToY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the z axis of the managed object entity.
*/
void MoveToZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the x axis of the managed object entity.
*/
void MoveByX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the y axis of the managed object entity.
*/
void MoveByY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the z axis of the managed object entity.
*/
void MoveByZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the x axis of the managed object entity.
*/
void RotateToX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the y axis of the managed object entity.
*/
void RotateToY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the z axis of the managed object entity.
*/
void RotateToZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the w axis of the managed object entity.
*/
void RotateToW(Float32 w) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the x axis of the managed object entity.
*/
void RotateByX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the y axis of the managed object entity.
*/
void RotateByY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the z axis of the managed object entity.
*/
void RotateByZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the w axis of the managed object entity.
*/
void RotateByW(Float32 w) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the x axis of the managed object entity.
*/
void RotateToEulerX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the y axis of the managed object entity.
*/
void RotateToEulerY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the z axis of the managed object entity.
*/
void RotateToEulerZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the x axis of the managed object entity.
*/
void RotateByEulerX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the y axis of the managed object entity.
*/
void RotateByEulerY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the z axis of the managed object entity.
*/
void RotateByEulerZ(Float32 z) const;
};
} // Namespace:: SqMod

View File

@@ -17,7 +17,7 @@ const Int32 CPickup::Max = SQMOD_PICKUP_POOL;
// ------------------------------------------------------------------------------------------------
SQInteger CPickup::Typename(HSQUIRRELVM vm)
{
static SQChar name[] = _SC("SqPickup");
static const SQChar name[] = _SC("SqPickup");
sq_pushstring(vm, name, sizeof(name));
return 1;
}
@@ -40,11 +40,17 @@ CPickup::~CPickup()
Int32 CPickup::Cmp(const CPickup & o) const
{
if (m_ID == o.m_ID)
{
return 0;
}
else if (m_ID > o.m_ID)
{
return 1;
}
else
{
return -1;
}
}
// ------------------------------------------------------------------------------------------------
@@ -89,7 +95,7 @@ bool CPickup::Destroy(Int32 header, Object & payload)
// Validate the managed identifier
Validate();
// Perform the requested operation
return _Core->DelPickup(m_ID, header, payload);
return Core::Get().DelPickup(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
@@ -98,7 +104,7 @@ void CPickup::BindEvent(Int32 evid, Object & env, Function & func) const
// Validate the managed identifier
Validate();
// Obtain the function instance called for this event
Function & event = _Core->GetPickupEvent(m_ID, evid);
Function & event = Core::Get().GetPickupEvent(m_ID, evid);
// Is the specified callback function null?
if (func.IsNull())
{
@@ -125,15 +131,6 @@ bool CPickup::IsStreamedFor(CPlayer & player) const
return _Func->IsPickupStreamedForPlayer(m_ID, player.GetID());
}
// ------------------------------------------------------------------------------------------------
Int32 CPickup::GetModel() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->PickupGetModel(m_ID);
}
// ------------------------------------------------------------------------------------------------
Int32 CPickup::GetWorld() const
{
@@ -158,7 +155,7 @@ Int32 CPickup::GetAlpha() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetVehicleModel(m_ID);
return _Func->GetPickupAlpha(m_ID);
}
// ------------------------------------------------------------------------------------------------
@@ -167,7 +164,7 @@ void CPickup::SetAlpha(Int32 alpha) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->PickupSetAlpha(m_ID, alpha);
_Func->SetPickupAlpha(m_ID, alpha);
}
// ------------------------------------------------------------------------------------------------
@@ -176,7 +173,7 @@ bool CPickup::GetAutomatic() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->PickupIsAutomatic(m_ID);
return _Func->IsPickupAutomatic(m_ID);
}
// ------------------------------------------------------------------------------------------------
@@ -185,7 +182,7 @@ void CPickup::SetAutomatic(bool toggle) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->PickupSetAutomatic(m_ID, toggle);
_Func->SetPickupIsAutomatic(m_ID, toggle);
}
// ------------------------------------------------------------------------------------------------
@@ -212,7 +209,7 @@ void CPickup::Refresh() const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->PickupRefresh(m_ID);
_Func->RefreshPickup(m_ID);
}
// ------------------------------------------------------------------------------------------------
@@ -223,7 +220,7 @@ const Vector3 & CPickup::GetPosition()
// Clear previous position information, if any
s_Vector3.Clear();
// Query the server for the position values
_Func->PickupGetPos(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z);
_Func->GetPickupPosition(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z);
// Return the requested information
return s_Vector3;
}
@@ -234,7 +231,7 @@ void CPickup::SetPosition(const Vector3 & pos) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->PickupSetPos(m_ID, pos.x, pos.y, pos.z);
_Func->SetPickupPosition(m_ID, pos.x, pos.y, pos.z);
}
// ------------------------------------------------------------------------------------------------
@@ -243,7 +240,16 @@ void CPickup::SetPositionEx(Float32 x, Float32 y, Float32 z) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->PickupSetPos(m_ID, x, y, z);
_Func->SetPickupPosition(m_ID, x, y, z);
}
// ------------------------------------------------------------------------------------------------
Int32 CPickup::GetModel() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetPickupModel(m_ID);
}
// ------------------------------------------------------------------------------------------------
@@ -252,86 +258,86 @@ Int32 CPickup::GetQuantity() const
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->PickupGetQuantity(m_ID);
return _Func->GetPickupQuantity(m_ID);
}
// ------------------------------------------------------------------------------------------------
Float32 CPickup::GetPosX() const
Float32 CPickup::GetPositionX() const
{
// Validate the managed identifier
Validate();
// Clear previous position information, if any
s_Vector3.x = 0;
// Query the server for the requested component value
_Func->PickupGetPos(m_ID, &s_Vector3.x, NULL, NULL);
_Func->GetPickupPosition(m_ID, &s_Vector3.x, NULL, NULL);
// Return the requested information
return s_Vector3.x;
}
// ------------------------------------------------------------------------------------------------
Float32 CPickup::GetPosY() const
Float32 CPickup::GetPositionY() const
{
// Validate the managed identifier
Validate();
// Clear previous position information, if any
s_Vector3.y = 0;
// Query the server for the requested component value
_Func->PickupGetPos(m_ID, NULL, &s_Vector3.y, NULL);
_Func->GetPickupPosition(m_ID, NULL, &s_Vector3.y, NULL);
// Return the requested information
return s_Vector3.y;
}
// ------------------------------------------------------------------------------------------------
Float32 CPickup::GetPosZ() const
Float32 CPickup::GetPositionZ() const
{
// Validate the managed identifier
Validate();
// Clear previous position information, if any
s_Vector3.z = 0;
// Query the server for the requested component value
_Func->PickupGetPos(m_ID, NULL, NULL, &s_Vector3.z);
_Func->GetPickupPosition(m_ID, NULL, NULL, &s_Vector3.z);
// Return the requested information
return s_Vector3.z;
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetPosX(Float32 x) const
void CPickup::SetPositionX(Float32 x) const
{
// Validate the managed identifier
Validate();
// Retrieve the current values for unchanged components
_Func->PickupGetPos(m_ID, NULL, &s_Vector3.y, &s_Vector3.z);
_Func->GetPickupPosition(m_ID, NULL, &s_Vector3.y, &s_Vector3.z);
// Perform the requested operation
_Func->PickupSetPos(m_ID, x, s_Vector3.y, s_Vector3.z);
_Func->SetPickupPosition(m_ID, x, s_Vector3.y, s_Vector3.z);
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetPosY(Float32 y) const
void CPickup::SetPositionY(Float32 y) const
{
// Validate the managed identifier
Validate();
// Retrieve the current values for unchanged components
_Func->PickupGetPos(m_ID, &s_Vector3.x, NULL, &s_Vector3.z);
_Func->GetPickupPosition(m_ID, &s_Vector3.x, NULL, &s_Vector3.z);
// Perform the requested operation
_Func->PickupSetPos(m_ID, s_Vector3.x, y, s_Vector3.z);
_Func->SetPickupPosition(m_ID, s_Vector3.x, y, s_Vector3.z);
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetPosZ(Float32 z) const
void CPickup::SetPositionZ(Float32 z) const
{
// Validate the managed identifier
Validate();
// Retrieve the current values for unchanged components
_Func->PickupGetPos(m_ID, &s_Vector3.x, &s_Vector3.y, NULL);
_Func->GetPickupPosition(m_ID, &s_Vector3.x, &s_Vector3.y, NULL);
// Perform the requested operation
_Func->PickupSetPos(m_ID, s_Vector3.z, s_Vector3.y, z);
_Func->SetPickupPosition(m_ID, s_Vector3.z, s_Vector3.y, z);
}
// ------------------------------------------------------------------------------------------------
static Object & Pickup_CreateEx(Int32 model, Int32 world, Int32 quantity,
Float32 x, Float32 y, Float32 z, Int32 alpha, bool automatic)
{
return _Core->NewPickup(model, world, quantity, x, y, z, alpha, automatic,
return Core::Get().NewPickup(model, world, quantity, x, y, z, alpha, automatic,
SQMOD_CREATE_DEFAULT, NullObject());
}
@@ -339,21 +345,21 @@ static Object & Pickup_CreateEx(Int32 model, Int32 world, Int32 quantity,
Float32 x, Float32 y, Float32 z, Int32 alpha, bool automatic,
Int32 header, Object & payload)
{
return _Core->NewPickup(model, world, quantity, x, y, z, alpha, automatic, header, payload);
return Core::Get().NewPickup(model, world, quantity, x, y, z, alpha, automatic, header, payload);
}
// ------------------------------------------------------------------------------------------------
static Object & Pickup_Create(Int32 model, Int32 world, Int32 quantity, const Vector3 & pos,
Int32 alpha, bool automatic)
{
return _Core->NewPickup(model, world, quantity, pos.x, pos.y, pos.z, alpha, automatic,
return Core::Get().NewPickup(model, world, quantity, pos.x, pos.y, pos.z, alpha, automatic,
SQMOD_CREATE_DEFAULT, NullObject());
}
static Object & Pickup_Create(Int32 model, Int32 world, Int32 quantity, const Vector3 & pos,
Int32 alpha, bool automatic, Int32 header, Object & payload)
{
return _Core->NewPickup(model, world, quantity, pos.x, pos.y, pos.z, alpha, automatic,
return Core::Get().NewPickup(model, world, quantity, pos.x, pos.y, pos.z, alpha, automatic,
header, payload);
}
@@ -366,8 +372,8 @@ static const Object & Pickup_FindByID(Int32 id)
STHROWF("The specified pickup identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Pickups::const_iterator itr = _Core->GetPickups().cbegin();
Core::Pickups::const_iterator end = _Core->GetPickups().cend();
Core::Pickups::const_iterator itr = Core::Get().GetPickups().cbegin();
Core::Pickups::const_iterator end = Core::Get().GetPickups().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
@@ -390,8 +396,8 @@ static const Object & Pickup_FindByTag(CSStr tag)
STHROWF("The specified pickup tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Pickups::const_iterator itr = _Core->GetPickups().cbegin();
Core::Pickups::const_iterator end = _Core->GetPickups().cend();
Core::Pickups::const_iterator itr = Core::Get().GetPickups().cbegin();
Core::Pickups::const_iterator end = Core::Get().GetPickups().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
@@ -411,8 +417,8 @@ static Array Pickup_FindActive()
// Remember the initial stack size
StackGuard sg;
// Obtain the ends of the entity pool
Core::Pickups::const_iterator itr = _Core->GetPickups().cbegin();
Core::Pickups::const_iterator end = _Core->GetPickups().cend();
Core::Pickups::const_iterator itr = Core::Get().GetPickups().cbegin();
Core::Pickups::const_iterator end = Core::Get().GetPickups().cend();
// Allocate an empty array on the stack
sq_newarray(DefaultVM::Get(), 0);
// Process each entity in the pool
@@ -467,9 +473,9 @@ void Register_CPickup(HSQUIRRELVM vm)
.Prop(_SC("Pos"), &CPickup::GetPosition, &CPickup::SetPosition)
.Prop(_SC("Position"), &CPickup::GetPosition, &CPickup::SetPosition)
.Prop(_SC("Quantity"), &CPickup::GetQuantity)
.Prop(_SC("X"), &CPickup::GetPosX, &CPickup::SetPosX)
.Prop(_SC("Y"), &CPickup::GetPosY, &CPickup::SetPosY)
.Prop(_SC("Z"), &CPickup::GetPosZ, &CPickup::SetPosZ)
.Prop(_SC("PosX"), &CPickup::GetPositionX, &CPickup::SetPositionX)
.Prop(_SC("PosY"), &CPickup::GetPositionY, &CPickup::SetPositionY)
.Prop(_SC("PosZ"), &CPickup::GetPositionZ, &CPickup::SetPositionZ)
// Member Methods
.Func(_SC("StreamedFor"), &CPickup::IsStreamedFor)
.Func(_SC("Refresh"), &CPickup::Refresh)

View File

@@ -165,11 +165,6 @@ public:
*/
bool IsStreamedFor(CPlayer & player) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the model of the managed pickup entity.
*/
Int32 GetModel() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the world in which the managed pickup entity exists.
*/
@@ -230,6 +225,11 @@ public:
*/
void SetPositionEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the model of the managed pickup entity.
*/
Int32 GetModel() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the quantity of the managed pickup entity.
*/
@@ -238,32 +238,32 @@ public:
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the x axis of the managed pickup entity.
*/
Float32 GetPosX() const;
Float32 GetPositionX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the y axis of the managed pickup entity.
*/
Float32 GetPosY() const;
Float32 GetPositionY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the z axis of the managed pickup entity.
*/
Float32 GetPosZ() const;
Float32 GetPositionZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the x axis of the managed pickup entity.
*/
void SetPosX(Float32 x) const;
void SetPositionX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the y axis of the managed pickup entity.
*/
void SetPosY(Float32 y) const;
void SetPositionY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the z axis of the managed pickup entity.
*/
void SetPosZ(Float32 z) const;
void SetPositionZ(Float32 z) const;
};
} // Namespace:: SqMod

File diff suppressed because it is too large Load Diff

View File

@@ -3,10 +3,19 @@
// ------------------------------------------------------------------------------------------------
#include "Base/Shared.hpp"
#include "Base/Buffer.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Circular locks employed by the player manager.
*/
enum PlayerCircularLocks
{
PCL_EMIT_PLAYER_OPTION = (1 << 0)
};
/* ------------------------------------------------------------------------------------------------
* Manages a single player entity.
*/
@@ -39,6 +48,16 @@ private:
*/
Object m_Data;
/* --------------------------------------------------------------------------------------------
* Buffer used to generate client data.
*/
Buffer m_Buffer;
/* --------------------------------------------------------------------------------------------
* Prevent events from triggering themselves.
*/
Uint32 m_CircularLocks;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
@@ -46,11 +65,64 @@ private:
public:
// --------------------------------------------------------------------------------------------
typedef String MsgPrefix[SQMOD_PLAYER_MSG_PREFIXES];
/* --------------------------------------------------------------------------------------------
* Maximum possible number that could represent an identifier for this entity type.
*/
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* The initial size of the allocated memory buffer when starting a new stream.
*/
Uint32 mBufferInitSize;
/* --------------------------------------------------------------------------------------------
* Default color to use in client messages.
*/
Uint32 mMessageColor;
/* --------------------------------------------------------------------------------------------
* Default style to use in client announcements.
*/
Int32 mAnnounceStyle;
/* --------------------------------------------------------------------------------------------
* Default ammo to give to the managed player when not specifying any.
*/
Int32 mDefaultAmmo;
/* --------------------------------------------------------------------------------------------
* Set of strings to add before a client message automatically.
*/
String mMessagePrefix;
/* --------------------------------------------------------------------------------------------
* Set of strings to add before a client message automatically.
*/
String mMessagePostfix;
/* --------------------------------------------------------------------------------------------
* Set of strings to add before a client announcement automatically.
*/
String mAnnouncePrefix;
/* --------------------------------------------------------------------------------------------
* Set of strings to add before a client announcement automatically.
*/
String mAnnouncePostfix;
/* --------------------------------------------------------------------------------------------
* Set of strings to add before a client message automatically.
*/
MsgPrefix mMessagePrefixes;
/* --------------------------------------------------------------------------------------------
* Don't include the auto message prefix/postfix in already prefixed messages.
*/
bool mLimitPrefixPostfixMessage;
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
@@ -143,16 +215,16 @@ public:
*/
void BindEvent(Int32 evid, Object & env, Function & func) const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity is connected.
*/
bool IsConnected() const;
/* --------------------------------------------------------------------------------------------
* See if the managed player entity is streamed for the specified player.
*/
bool IsStreamedFor(CPlayer & player) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the class of the managed player entity.
*/
Int32 GetClass() const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity has administrator privileges.
*/
@@ -168,6 +240,16 @@ public:
*/
CSStr GetIP() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the unique user identifier of the managed player entity.
*/
CSStr GetUID() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the unique user identifier version 2 of the managed player entity.
*/
CSStr GetUID2() const;
/* --------------------------------------------------------------------------------------------
* Kick the managed player entity from the server.
*/
@@ -178,21 +260,41 @@ public:
*/
void Ban() const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity is connected.
*/
bool IsConnected() const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity is spawned.
*/
bool IsSpawned() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the key of the managed player entity.
*/
Uint32 GetKey() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the nick name of the managed player entity.
*/
CSStr GetName() const;
/* --------------------------------------------------------------------------------------------
* Modify the nick name of the managed player entity.
*/
void SetName(CSStr name) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the current state of the managed player entity.
*/
Int32 GetState() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the current option value of the managed player entity.
*/
Int32 GetOption(Int32 option_id) const;
/* --------------------------------------------------------------------------------------------
* Modify the current option value of the managed player entity.
*/
void SetOption(Int32 option_id, bool toggle);
/* --------------------------------------------------------------------------------------------
* Modify the current option value of the managed player entity.
*/
void SetOptionEx(Int32 option_id, bool toggle, Int32 header, Object & payload);
/* --------------------------------------------------------------------------------------------
* Retrieve the world in which the managed player entity exists.
*/
@@ -206,12 +308,12 @@ public:
/* --------------------------------------------------------------------------------------------
* Retrieve the secondary world of the managed player entity.
*/
Int32 GetSecWorld() const;
Int32 GetSecondaryWorld() const;
/* --------------------------------------------------------------------------------------------
* Modify the secondary world of the managed player entity.
*/
void SetSecWorld(Int32 world) const;
void SetSecondaryWorld(Int32 world) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the unique world of the managed player entity.
@@ -224,14 +326,9 @@ public:
bool IsWorldCompatible(Int32 world) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the nick name of the managed player entity.
* Retrieve the class of the managed player entity.
*/
CSStr GetName() const;
/* --------------------------------------------------------------------------------------------
* Modify the nick name of the managed player entity.
*/
void SetName(CSStr name) const;
Int32 GetClass() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the team of the managed player entity.
@@ -268,6 +365,11 @@ public:
*/
void SetColorEx(Uint8 r, Uint8 g, Uint8 b) const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity is spawned.
*/
bool IsSpawned() const;
/* --------------------------------------------------------------------------------------------
* Force the managed player entity to spawn in the game.
*/
@@ -278,6 +380,11 @@ public:
*/
void ForceSelect() const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity is typing.
*/
bool IsTyping() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the money amount of the managed player entity.
*/
@@ -303,6 +410,16 @@ public:
*/
void SetScore(Int32 score) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the wanted level of the managed player entity.
*/
Int32 GetWantedLevel() const;
/* --------------------------------------------------------------------------------------------
* Modify the wanted level of the managed player entity.
*/
void SetWantedLevel(Int32 level) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the connection latency of the managed player entity.
*/
@@ -313,21 +430,6 @@ public:
*/
Float32 GetFPS() const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity is typing.
*/
bool IsTyping() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the unique user identifier of the managed player entity.
*/
CSStr GetUID() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the unique user identifier version 2 of the managed player entity.
*/
CSStr GetUID2() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the current health of the managed player entity.
*/
@@ -418,6 +520,51 @@ public:
*/
void SetAlpha(Int32 alpha, Int32 fade) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the aim position of the managed player entity.
*/
const Vector3 & GetAimPosition() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the aim direction of the managed player entity.
*/
const Vector3 & GetAimDirection() const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity is burning.
*/
bool IsBurning() const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity is crouched.
*/
bool IsCrouched() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the current action of the managed player entity.
*/
Int32 GetAction() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the game keys of the managed player entity.
*/
Int32 GetGameKeys() const;
/* --------------------------------------------------------------------------------------------
* Embark the managed player entity into the specified vehicle entity.
*/
bool Embark(CVehicle & vehicle) const;
/* --------------------------------------------------------------------------------------------
* Embark the managed player entity into the specified vehicle entity.
*/
bool Embark(CVehicle & vehicle, Int32 slot, bool allocate, bool warp) const;
/* --------------------------------------------------------------------------------------------
* Disembark the managed player entity from the currently embarked vehicle entity.
*/
void Disembark() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the vehicle status of the managed player entity.
*/
@@ -426,7 +573,7 @@ public:
/* --------------------------------------------------------------------------------------------
* Retrieve the occupied vehicle slot by the managed player entity.
*/
Int32 GetOccupiedSlot() const;
Int32 GetVehicleSlot() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the vehicle in which the managed player entity is embarked.
@@ -438,106 +585,6 @@ public:
*/
Int32 GetVehicleID() const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity can be controlled.
*/
bool GetControllable() const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed player entity can be controlled.
*/
void SetControllable(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity can driveby.
*/
bool GetDriveby() const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed player entity can driveby.
*/
void SetDriveby(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity has white scanlines.
*/
bool GetWhiteScanlines() const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed player entity has white scanlines.
*/
void SetWhiteScanlines(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity has green scanlines.
*/
bool GetGreenScanlines() const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed player entity has green scanlines.
*/
void SetGreenScanlines(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity has widescreen.
*/
bool GetWidescreen() const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed player entity has widescreen.
*/
void SetWidescreen(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity displays markers.
*/
bool GetShowMarkers() const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed player entity displays markers.
*/
void SetShowMarkers(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity has attacking privileges.
*/
bool GetAttackPriv() const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed player entity has attacking privileges.
*/
void SetAttackPriv(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity has markers.
*/
bool GetHasMarker() const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed player entity has markers.
*/
void SetHasMarker(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity has chat tags.
*/
bool GetChatTags() const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed player entity has chat tags.
*/
void SetChatTags(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity is under drunk effects.
*/
bool GetDrunkEffects() const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed player entity is under drunk effects.
*/
void SetDrunkEffects(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the weapon identifier of the managed player entity.
*/
@@ -546,13 +593,48 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the weapon of the managed player entity.
*/
void SetWeapon(Int32 wep, Int32 ammo) const;
void SetWeapon(Int32 wep) const;
/* --------------------------------------------------------------------------------------------
* Modify the weapon of the managed player entity.
*/
void SetWeaponEx(Int32 wep, Int32 ammo) const;
/* --------------------------------------------------------------------------------------------
* Give a weapon of the managed player entity.
*/
void GiveWeapon(Int32 wep, Int32 ammo) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the active weapon ammo of the managed player entity.
*/
Int32 GetAmmo() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the weapon slot of the managed player entity.
*/
Int32 GetWeaponSlot() const;
/* --------------------------------------------------------------------------------------------
* Modify the weapon slot of the managed player entity.
*/
void SetWeaponSlot(Int32 slot) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the weapon identifier at the specified slot for the managed player entity.
*/
Int32 GetWeaponAtSlot(Int32 slot) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the ammo from the weapon at the specified slot for the managed player entity.
*/
Int32 GetAmmoAtSlot(Int32 slot) const;
/* --------------------------------------------------------------------------------------------
* Remove a certain weapon from the managed player entity.
*/
void RemoveWeapon(Int32 wep) const;
/* --------------------------------------------------------------------------------------------
* Strip the managed player entity of all weapons.
*/
@@ -583,16 +665,6 @@ public:
*/
void SetAnimation(Int32 group, Int32 anim) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the wanted level of the managed player entity.
*/
Int32 GetWantedLevel() const;
/* --------------------------------------------------------------------------------------------
* Modify the wanted level of the managed player entity.
*/
void SetWantedLevel(Int32 level) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the vehicle that the managed player entity is standing on.
*/
@@ -618,60 +690,10 @@ public:
*/
void SetSpectator(CPlayer & target) const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity is burning.
*/
bool IsBurning() const;
/* --------------------------------------------------------------------------------------------
* See whether the managed player entity is crouched.
*/
bool IsCrouched() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the current state of the managed player entity.
*/
Int32 GetState() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the current action of the managed player entity.
*/
Int32 GetAction() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the game keys of the managed player entity.
*/
Int32 GetGameKeys() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the aim position of the managed player entity.
*/
const Vector3 & GetAimPos() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the aim direction of the managed player entity.
*/
const Vector3 & GetAimDir() const;
/* --------------------------------------------------------------------------------------------
* Embark the managed player entity into the specified vehicle entity.
*/
void Embark(CVehicle & vehicle) const;
/* --------------------------------------------------------------------------------------------
* Embark the managed player entity into the specified vehicle entity.
*/
void Embark(CVehicle & vehicle, Int32 slot, bool allocate, bool warp) const;
/* --------------------------------------------------------------------------------------------
* Disembark the managed player entity from the currently embarked vehicle entity.
*/
void Disembark() const;
/* --------------------------------------------------------------------------------------------
* Redirect the managed player entity to the specified server.
*/
bool Redirect(CSStr ip, Uint32 port, CSStr nick, CSStr pass, CSStr user);
void Redirect(CSStr ip, Uint32 port, CSStr nick, CSStr server_pass, CSStr user_pass);
/* --------------------------------------------------------------------------------------------
* Retrieve the authority level of the managed player entity.
@@ -686,61 +708,162 @@ public:
/* --------------------------------------------------------------------------------------------
* Retrieve the message prefix at the specified index for the managed player entity.
*/
CSStr GetMessagePrefix(Uint32 index) const;
const String & GetMessagePrefix(Uint32 index) const;
/* --------------------------------------------------------------------------------------------
* Modify the message prefix at the specified index for the managed player entity.
*/
void SetMessagePrefix(Uint32 index, CSStr prefix) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the message color for the managed player entity.
*/
Uint32 GetMessageColor() const;
void SetMessagePrefix(Uint32 index, CSStr prefix);
/* --------------------------------------------------------------------------------------------
* Modify the message color for the managed player entity.
* Retrieve the last known weapon for the managed player entity.
*/
void SetMessageColor(Uint32 color) const;
Int32 GetLastWeapon() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the announcement style for the managed player entity.
* Retrieve the last known health for the managed player entity.
*/
Int32 GetAnnounceStyle() const;
Float32 GetLastHealth() const;
/* --------------------------------------------------------------------------------------------
* Modify the announcement style for the managed player entity.
* Retrieve the last known armour for the managed player entity.
*/
void SetAnnounceStyle(Int32 style) const;
Float32 GetLastArmour() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the last known heading for the managed player entity.
*/
Float32 GetLastHeading() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the last known position for the managed player entity.
*/
const Vector3 & GetLastPosition() const;
/* --------------------------------------------------------------------------------------------
* Start a new stream with the default size.
*/
void StartStream();
/* --------------------------------------------------------------------------------------------
* Start a new stream with a custom size.
*/
void StartStream(Uint32 size);
/* --------------------------------------------------------------------------------------------
* Retrieve the current cursor position of the stream buffer.
*/
Int32 GetBufferCursor() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the current cursor position of the stream buffer.
*/
void SetBufferCursor(Int32 pos);
/* --------------------------------------------------------------------------------------------
* Write a 8bit byte to the stream buffer.
*/
void StreamByte(SQInteger val);
/* --------------------------------------------------------------------------------------------
* Write a 16bit short to the stream buffer.
*/
void StreamShort(SQInteger val);
/* --------------------------------------------------------------------------------------------
* Write a 32bit integer to the stream buffer.
*/
void StreamInt(SQInteger val);
/* --------------------------------------------------------------------------------------------
* Write a 32bit float to the stream buffer.
*/
void StreamFloat(SQFloat val);
/* --------------------------------------------------------------------------------------------
* Write a string to the stream buffer.
*/
void StreamString(CSStr val);
/* --------------------------------------------------------------------------------------------
* Write a raw string to the stream buffer.
*/
void StreamRawString(CSStr val);
/* --------------------------------------------------------------------------------------------
* Send the data in the stream buffer to the client.
*/
void FlushStream(bool reset);
/* --------------------------------------------------------------------------------------------
* Retrieve the total capacity of the buffer stream in bytes.
*/
Uint32 GetBufferCapacity() const;
/* --------------------------------------------------------------------------------------------
* Send the specified buffer contents to the managed player entity.
*/
void SendBuffer(const BufferWrapper & buffer) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the x axis of the managed player entity.
*/
Float32 GetPosX() const;
Float32 GetPositionX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the y axis of the managed player entity.
*/
Float32 GetPosY() const;
Float32 GetPositionY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the z axis of the managed player entity.
*/
Float32 GetPosZ() const;
Float32 GetPositionZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the x axis of the managed player entity.
*/
void SetPosX(Float32 x) const;
void SetPositionX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the y axis of the managed player entity.
*/
void SetPosY(Float32 y) const;
void SetPositionY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the z axis of the managed player entity.
*/
void SetPosZ(Float32 z) const;
void SetPositionZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the red color of the managed player entity.
*/
Int32 GetColorR() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the green color of the managed player entity.
*/
Int32 GetColorG() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the blue color of the managed player entity.
*/
Int32 GetColorB() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the red color of the managed player entity.
*/
void SetColorR(Int32 r) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the green color of the managed player entity.
*/
void SetColorG(Int32 g) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the blue color of the managed player entity.
*/
void SetColorB(Int32 b) const;
/* --------------------------------------------------------------------------------------------
* Send a formatted colored message to the managed player entity.

View File

@@ -1,656 +0,0 @@
// ------------------------------------------------------------------------------------------------
#include "Entity/Sprite.hpp"
#include "Entity/Player.hpp"
#include "Base/Vector2i.hpp"
#include "Base/Stack.hpp"
#include "Core.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
const Int32 CSprite::Max = SQMOD_SPRITE_POOL;
// ------------------------------------------------------------------------------------------------
SQInteger CSprite::Typename(HSQUIRRELVM vm)
{
static SQChar name[] = _SC("SqSprite");
sq_pushstring(vm, name, sizeof(name));
return 1;
}
// ------------------------------------------------------------------------------------------------
CSprite::CSprite(Int32 id)
: m_ID(VALID_ENTITYGETEX(id, SQMOD_SPRITE_POOL))
, m_Tag(ToStrF("%d", id))
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
CSprite::~CSprite()
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
Int32 CSprite::Cmp(const CSprite & o) const
{
if (m_ID == o.m_ID)
return 0;
else if (m_ID > o.m_ID)
return 1;
else
return -1;
}
// ------------------------------------------------------------------------------------------------
const String & CSprite::ToString() const
{
return m_Tag;
}
// ------------------------------------------------------------------------------------------------
const String & CSprite::GetTag() const
{
return m_Tag;
}
// ------------------------------------------------------------------------------------------------
void CSprite::SetTag(CSStr tag)
{
m_Tag.assign(tag);
}
// ------------------------------------------------------------------------------------------------
Object & CSprite::GetData()
{
// Validate the managed identifier
Validate();
// Return the requested information
return m_Data;
}
// ------------------------------------------------------------------------------------------------
void CSprite::SetData(Object & data)
{
// Validate the managed identifier
Validate();
// Apply the specified value
m_Data = data;
}
// ------------------------------------------------------------------------------------------------
bool CSprite::Destroy(Int32 header, Object & payload)
{
// Validate the managed identifier
Validate();
// Perform the requested operation
return _Core->DelSprite(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
void CSprite::BindEvent(Int32 evid, Object & env, Function & func) const
{
// Validate the managed identifier
Validate();
// Obtain the function instance called for this event
Function & event = _Core->GetSpriteEvent(m_ID, evid);
// Is the specified callback function null?
if (func.IsNull())
{
event.Release(); // Then release the current callback
}
// Assign the specified environment and function
else
{
event = Function(env.GetVM(), env, func.GetFunc());
}
}
// ------------------------------------------------------------------------------------------------
void CSprite::ShowAll() const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->ShowSprite(m_ID, -1);
}
// ------------------------------------------------------------------------------------------------
void CSprite::ShowFor(CPlayer & player) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->ShowSprite(m_ID, player.GetID());
}
// ------------------------------------------------------------------------------------------------
void CSprite::ShowRange(Int32 first, Int32 last) const
{
// Validate the specified range
if (first > last)
{
STHROWF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
for (; first <= last; ++first)
{
// Is the currently processed player even connected?
if (_Func->IsPlayerConnected(first))
{
// Then show this textdraw on his client
_Func->ShowSprite(m_ID, first);
}
}
}
// ------------------------------------------------------------------------------------------------
void CSprite::HideAll() const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->HideSprite(m_ID, -1);
}
// ------------------------------------------------------------------------------------------------
void CSprite::HideFor(CPlayer & player) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->HideSprite(m_ID, player.GetID());
}
// ------------------------------------------------------------------------------------------------
void CSprite::HideRange(Int32 first, Int32 last) const
{
// Validate the specified range
if (first > last)
{
STHROWF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
for (; first <= last; ++first)
{
// Is the currently processed player even connected?
if (_Func->IsPlayerConnected(first))
{
// Then hide this textdraw on his client
_Func->HideSprite(m_ID, first);
}
}
}
// ------------------------------------------------------------------------------------------------
void CSprite::SetPositionAll(const Vector2i & pos) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->MoveSprite(m_ID, -1, pos.x, pos.y);
}
// ------------------------------------------------------------------------------------------------
void CSprite::SetPositionAllEx(Int32 x, Int32 y) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->MoveSprite(m_ID, -1, x, y);
}
// ------------------------------------------------------------------------------------------------
void CSprite::SetPositionFor(CPlayer & player, const Vector2i & pos) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->MoveSprite(m_ID, player.GetID(), pos.x, pos.y);
}
// ------------------------------------------------------------------------------------------------
void CSprite::SetPositionForEx(CPlayer & player, Int32 x, Int32 y) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->MoveSprite(m_ID, player.GetID(), x, y);
}
// ------------------------------------------------------------------------------------------------
void CSprite::SetPositionRange(Int32 first, Int32 last, const Vector2i & pos) const
{
// Validate the specified range
if (first > last)
{
STHROWF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
for (; first <= last; ++first)
{
// Is the currently processed player even connected?
if (_Func->IsPlayerConnected(first))
{
// Then move this textdraw on his client
_Func->MoveSprite(m_ID, first, pos.x, pos.y);
}
}
}
// ------------------------------------------------------------------------------------------------
void CSprite::SetCenterAll(const Vector2i & pos) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetSpriteCenter(m_ID, -1, pos.x, pos.y);
}
// ------------------------------------------------------------------------------------------------
void CSprite::SetCenterAllEx(Int32 x, Int32 y) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetSpriteCenter(m_ID, -1, x, y);
}
// ------------------------------------------------------------------------------------------------
void CSprite::SetCenterFor(CPlayer & player, const Vector2i & pos) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetSpriteCenter(m_ID, player.GetID(), pos.x, pos.y);
}
// ------------------------------------------------------------------------------------------------
void CSprite::SetCenterForEx(CPlayer & player, Int32 x, Int32 y) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetSpriteCenter(m_ID, player.GetID(), x, y);
}
// ------------------------------------------------------------------------------------------------
void CSprite::SetCenterRange(Int32 first, Int32 last, const Vector2i & pos) const
{
// Validate the specified range
if (first > last)
{
STHROWF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
for (; first <= last; ++first)
{
// Is the currently processed player even connected?
if (_Func->IsPlayerConnected(first))
{
// Then center this textdraw on his client
_Func->SetSpriteCenter(m_ID, first, pos.x, pos.y);
}
}
}
// ------------------------------------------------------------------------------------------------
void CSprite::SetRotationAll(Float32 rot) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateSprite(m_ID, -1, rot);
}
// ------------------------------------------------------------------------------------------------
void CSprite::SetRotationFor(CPlayer & player, Float32 rot) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->RotateSprite(m_ID, player.GetID(), rot);
}
// ------------------------------------------------------------------------------------------------
void CSprite::SetRotationRange(Int32 first, Int32 last, Float32 rot) const
{
// Validate the specified range
if (first > last)
{
STHROWF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
for (; first <= last; ++first)
{
// Is the currently processed player even connected?
if (_Func->IsPlayerConnected(first))
{
// Then rotate this textdraw on his client
_Func->RotateSprite(m_ID, first, rot);
}
}
}
// ------------------------------------------------------------------------------------------------
void CSprite::SetAlphaAll(Uint8 alpha) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetSpriteAlpha(m_ID, -1, alpha);
}
// ------------------------------------------------------------------------------------------------
void CSprite::SetAlphaFor(CPlayer & player, Uint8 alpha) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetSpriteAlpha(m_ID, player.GetID(), alpha);
}
// ------------------------------------------------------------------------------------------------
void CSprite::SetAlphaRange(Int32 first, Int32 last, Uint8 alpha) const
{
// Validate the specified range
if (first > last)
{
STHROWF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
for (; first <= last; ++first)
{
// Is the currently processed player even connected?
if (_Func->IsPlayerConnected(first))
{
// Then colorize this textdraw on his client
_Func->SetSpriteAlpha(m_ID, first, alpha);
}
}
}
// ------------------------------------------------------------------------------------------------
const String & CSprite::GetFilePath() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Core->GetSprite(m_ID).mPath;
}
// ------------------------------------------------------------------------------------------------
static Object & Sprite_CreateEx(CSStr file, Int32 xp, Int32 yp, Int32 xr, Int32 yr,
Float32 angle, Int32 alpha, bool rel)
{
return _Core->NewSprite(-1, file, xp, yp, xr, yr, angle, alpha, rel,
SQMOD_CREATE_DEFAULT, NullObject());
}
// ------------------------------------------------------------------------------------------------
static Object & Sprite_CreateEx(CSStr file, Int32 xp, Int32 yp, Int32 xr, Int32 yr,
Float32 angle, Int32 alpha, bool rel, Int32 header, Object & payload)
{
return _Core->NewSprite(-1, file, xp, yp, xr, yr, angle, alpha, rel, header, payload);
}
// ------------------------------------------------------------------------------------------------
static Object & Sprite_CreateEx(Int32 index, CSStr file, Int32 xp, Int32 yp, Int32 xr, Int32 yr,
Float32 angle, Int32 alpha, bool rel)
{
return _Core->NewSprite(index, file, xp, yp, xr, yr, angle, alpha, rel,
SQMOD_CREATE_DEFAULT, NullObject());
}
// ------------------------------------------------------------------------------------------------
static Object & Sprite_CreateEx(Int32 index, CSStr file, Int32 xp, Int32 yp, Int32 xr, Int32 yr,
Float32 angle, Int32 alpha, bool rel, Int32 header, Object & payload)
{
return _Core->NewSprite(index, file, xp, yp, xr, yr, angle, alpha, rel, header, payload);
}
// ------------------------------------------------------------------------------------------------
static Object & Sprite_Create(CSStr file, const Vector2i & pos, const Vector2i & rot,
Float32 angle, Int32 alpha, bool rel)
{
return _Core->NewSprite(-1, file, pos.x, pos.y, rot.x, rot.y, angle, alpha, rel,
SQMOD_CREATE_DEFAULT, NullObject());
}
// ------------------------------------------------------------------------------------------------
static Object & Sprite_Create(CSStr file, const Vector2i & pos, const Vector2i & rot,
Float32 angle, Int32 alpha, bool rel, Int32 header, Object & payload)
{
return _Core->NewSprite(-1, file, pos.x, pos.y, rot.x, rot.y, angle, alpha, rel, header, payload);
}
// ------------------------------------------------------------------------------------------------
static Object & Sprite_Create(Int32 index, CSStr file, const Vector2i & pos, const Vector2i & rot,
Float32 angle, Int32 alpha, bool rel)
{
return _Core->NewSprite(index, file, pos.x, pos.y, rot.x, rot.y, angle, alpha, rel,
SQMOD_CREATE_DEFAULT, NullObject());
}
// ------------------------------------------------------------------------------------------------
static Object & Sprite_Create(Int32 index, CSStr file, const Vector2i & pos, const Vector2i & rot,
Float32 angle, Int32 alpha, bool rel, Int32 header, Object & payload)
{
return _Core->NewSprite(index, file, pos.x, pos.y, rot.x, rot.y, angle, alpha, rel, header, payload);
}
// ------------------------------------------------------------------------------------------------
static const Object & Sprite_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_SPRITE_POOL))
{
STHROWF("The specified sprite identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Sprites::const_iterator itr = _Core->GetSprites().cbegin();
Core::Sprites::const_iterator end = _Core->GetSprites().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does the identifier match the specified one?
if (itr->mID == id)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a sprite matching the specified identifier
return NullObject();
}
// ------------------------------------------------------------------------------------------------
static const Object & Sprite_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == '\0')
{
STHROWF("The specified sprite tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Sprites::const_iterator itr = _Core->GetSprites().cbegin();
Core::Sprites::const_iterator end = _Core->GetSprites().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a sprite matching the specified tag
return NullObject();
}
// ------------------------------------------------------------------------------------------------
static Array Sprite_FindActive()
{
// Remember the initial stack size
StackGuard sg;
// Obtain the ends of the entity pool
Core::Sprites::const_iterator itr = _Core->GetSprites().cbegin();
Core::Sprites::const_iterator end = _Core->GetSprites().cend();
// Allocate an empty array on the stack
sq_newarray(DefaultVM::Get(), 0);
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Is this entity instance active?
if (VALID_ENTITY(itr->mID))
{
// Push the script object on the stack
sq_pushobject(DefaultVM::Get(), (HSQOBJECT &)((*itr).mObj));
// Append the object at the back of the array
if (SQ_FAILED(sq_arrayappend(DefaultVM::Get(), -1)))
{
STHROWF("Unable to append entity instance to the list");
}
}
}
// Return the array at the top of the stack
return Var< Array >(DefaultVM::Get(), -1).value;
}
// ================================================================================================
void Register_CSprite(HSQUIRRELVM vm)
{
RootTable(vm).Bind(_SC("SqSprite"),
Class< CSprite, NoConstructor< CSprite > >(vm, _SC("SqSprite"))
// Metamethods
.Func(_SC("_cmp"), &CSprite::Cmp)
.SquirrelFunc(_SC("_typename"), &CSprite::Typename)
.Func(_SC("_tostring"), &CSprite::ToString)
// Static Values
.SetStaticValue(_SC("MaxID"), CSprite::Max)
// Core Properties
.Prop(_SC("ID"), &CSprite::GetID)
.Prop(_SC("Tag"), &CSprite::GetTag, &CSprite::SetTag)
.Prop(_SC("Data"), &CSprite::GetData, &CSprite::SetData)
.Prop(_SC("Active"), &CSprite::IsActive)
// Core Methods
.Func(_SC("Bind"), &CSprite::BindEvent)
// Core Overloads
.Overload< bool (CSprite::*)(void) >(_SC("Destroy"), &CSprite::Destroy)
.Overload< bool (CSprite::*)(Int32) >(_SC("Destroy"), &CSprite::Destroy)
.Overload< bool (CSprite::*)(Int32, Object &) >(_SC("Destroy"), &CSprite::Destroy)
// Properties
.Prop(_SC("Path"), &CSprite::GetFilePath)
// Member Methods
.Func(_SC("ShowAll"), &CSprite::ShowAll)
.Func(_SC("ShowTo"), &CSprite::ShowFor)
.Func(_SC("ShowFor"), &CSprite::ShowFor)
.Func(_SC("ShowRange"), &CSprite::ShowRange)
.Func(_SC("HideAll"), &CSprite::HideAll)
.Func(_SC("HideFor"), &CSprite::HideFor)
.Func(_SC("HideFrom"), &CSprite::HideFor)
.Func(_SC("HideRange"), &CSprite::HideRange)
.Func(_SC("SetPositionRange"), &CSprite::SetPositionRange)
.Func(_SC("SetCenterRange"), &CSprite::SetCenterRange)
.Func(_SC("SetRotationAll"), &CSprite::SetRotationAll)
.Func(_SC("SetRotationFor"), &CSprite::SetRotationFor)
.Func(_SC("SetRotationRange"), &CSprite::SetRotationRange)
.Func(_SC("SetAlphaAll"), &CSprite::SetAlphaAll)
.Func(_SC("SetAlphaFor"), &CSprite::SetAlphaFor)
.Func(_SC("SetAlphaRange"), &CSprite::SetAlphaRange)
// Member Overloads
.Overload< void (CSprite::*)(const Vector2i &) const >
(_SC("SetPositionAll"), &CSprite::SetPositionAll)
.Overload< void (CSprite::*)(Int32, Int32) const >
(_SC("SetPositionAll"), &CSprite::SetPositionAllEx)
.Overload< void (CSprite::*)(CPlayer &, const Vector2i &) const >
(_SC("SetPositionFor"), &CSprite::SetPositionFor)
.Overload< void (CSprite::*)(CPlayer &, Int32, Int32) const >
(_SC("SetPositionFor"), &CSprite::SetPositionForEx)
.Overload< void (CSprite::*)(const Vector2i &) const >
(_SC("SetCenterAll"), &CSprite::SetCenterAll)
.Overload< void (CSprite::*)(Int32, Int32) const >
(_SC("SetCenterAll"), &CSprite::SetCenterAllEx)
.Overload< void (CSprite::*)(CPlayer &, const Vector2i &) const >
(_SC("SetCenterFor"), &CSprite::SetCenterFor)
.Overload< void (CSprite::*)(CPlayer &, Int32, Int32) const >
(_SC("SetCenterFor"), &CSprite::SetCenterForEx)
// Static Functions
.StaticFunc(_SC("FindByID"), &Sprite_FindByID)
.StaticFunc(_SC("FindByTag"), &Sprite_FindByTag)
.StaticFunc(_SC("FindActive"), &Sprite_FindActive)
// Static Overloads
.StaticOverload< Object & (*)(CSStr, Int32, Int32, Int32, Int32, Float32, Int32, bool rel) >
(_SC("CreateEx"), &Sprite_CreateEx)
.StaticOverload< Object & (*)(CSStr, Int32, Int32, Int32, Int32, Float32, Int32, bool rel, Int32, Object &) >
(_SC("CreateEx"), &Sprite_CreateEx)
.StaticOverload< Object & (*)(Int32, CSStr, Int32, Int32, Int32, Int32, Float32, Int32, bool rel) >
(_SC("CreateEx"), &Sprite_CreateEx)
.StaticOverload< Object & (*)(Int32, CSStr, Int32, Int32, Int32, Int32, Float32, Int32, bool rel, Int32, Object &) >
(_SC("CreateEx"), &Sprite_CreateEx)
.StaticOverload< Object & (*)(CSStr, const Vector2i &, const Vector2i &, Float32, Int32, bool) >
(_SC("Create"), &Sprite_Create)
.StaticOverload< Object & (*)(CSStr, const Vector2i &, const Vector2i &, Float32, Int32, bool, Int32, Object &) >
(_SC("Create"), &Sprite_Create)
.StaticOverload< Object & (*)(Int32, CSStr, const Vector2i &, const Vector2i &, Float32, Int32, bool) >
(_SC("Create"), &Sprite_Create)
.StaticOverload< Object & (*)(Int32, CSStr, const Vector2i &, const Vector2i &, Float32, Int32, bool, Int32, Object &) >
(_SC("Create"), &Sprite_Create)
);
}
} // Namespace:: SqMod

View File

@@ -1,278 +0,0 @@
#ifndef _ENTITY_SPRITE_HPP_
#define _ENTITY_SPRITE_HPP_
// ------------------------------------------------------------------------------------------------
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Manages a single sprite entity.
*/
class CSprite
{
// --------------------------------------------------------------------------------------------
friend class Core;
private:
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
*/
Int32 m_ID;
/* --------------------------------------------------------------------------------------------
* User tag associated with this instance.
*/
String m_Tag;
/* --------------------------------------------------------------------------------------------
* User data associated with this instance.
*/
Object m_Data;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CSprite(Int32 id);
public:
/* --------------------------------------------------------------------------------------------
* Maximum possible number that could represent an identifier for this entity type.
*/
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
CSprite(const CSprite &) = delete;
/* --------------------------------------------------------------------------------------------
* Move constructor. (disabled)
*/
CSprite(CSprite &&) = delete;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~CSprite();
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
CSprite & operator = (const CSprite &) = delete;
/* --------------------------------------------------------------------------------------------
* Move assignment operator. (disabled)
*/
CSprite & operator = (CSprite &&) = delete;
/* --------------------------------------------------------------------------------------------
* See whether this instance manages a valid entity.
*/
void Validate() const
{
if (INVALID_ENTITY(m_ID))
{
STHROWF("Invalid sprite reference [%s]", m_Tag.c_str());
}
}
/* --------------------------------------------------------------------------------------------
* Used by the script engine to compare two instances of this type.
*/
Int32 Cmp(const CSprite & o) const;
/* --------------------------------------------------------------------------------------------
* Used by the script engine to convert an instance of this type to a string.
*/
const String & ToString() const;
/* --------------------------------------------------------------------------------------------
* Used by the script engine to retrieve the name from instances of this type.
*/
static SQInteger Typename(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Retrieve the identifier of the entity managed by this instance.
*/
Int32 GetID() const
{
return m_ID;
}
/* --------------------------------------------------------------------------------------------
* Check whether this instance manages a valid entity.
*/
bool IsActive() const
{
return VALID_ENTITY(m_ID);
}
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user tag.
*/
const String & GetTag() const;
/* --------------------------------------------------------------------------------------------
* Modify the associated user tag.
*/
void SetTag(CSStr tag);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user data.
*/
Object & GetData();
/* --------------------------------------------------------------------------------------------
* Modify the associated user data.
*/
void SetData(Object & data);
/* --------------------------------------------------------------------------------------------
* Destroy the managed sprite entity.
*/
bool Destroy()
{
return Destroy(0, NullObject());
}
/* --------------------------------------------------------------------------------------------
* Destroy the managed sprite entity.
*/
bool Destroy(Int32 header)
{
return Destroy(header, NullObject());
}
/* --------------------------------------------------------------------------------------------
* Destroy the managed sprite entity.
*/
bool Destroy(Int32 header, Object & payload);
/* --------------------------------------------------------------------------------------------
* Bind to an event supported by this entity type.
*/
void BindEvent(Int32 evid, Object & env, Function & func) const;
/* --------------------------------------------------------------------------------------------
* Show the managed sprite entity to all players on the server.
*/
void ShowAll() const;
/* --------------------------------------------------------------------------------------------
* Show the managed sprite entity to the specified player entity.
*/
void ShowFor(CPlayer & player) const;
/* --------------------------------------------------------------------------------------------
* Show the managed sprite entity to all players in the specified range.
*/
void ShowRange(Int32 first, Int32 last) const;
/* --------------------------------------------------------------------------------------------
* Hide the managed sprite entity from all players on the server.
*/
void HideAll() const;
/* --------------------------------------------------------------------------------------------
* Hide the managed sprite entity from the specified player entity.
*/
void HideFor(CPlayer & player) const;
/* --------------------------------------------------------------------------------------------
* Hide the managed sprite entity from all players in the specified range.
*/
void HideRange(Int32 first, Int32 last) const;
/* --------------------------------------------------------------------------------------------
* Set the position of the managed sprite entity for all players on the server.
*/
void SetPositionAll(const Vector2i & pos) const;
/* --------------------------------------------------------------------------------------------
* Set the position of the managed sprite entity for all players on the server.
*/
void SetPositionAllEx(Int32 x, Int32 y) const;
/* --------------------------------------------------------------------------------------------
* Set the position of the managed sprite entity for the specified player entity.
*/
void SetPositionFor(CPlayer & player, const Vector2i & pos) const;
/* --------------------------------------------------------------------------------------------
* Set the position of the managed sprite entity for the specified player entity.
*/
void SetPositionForEx(CPlayer & player, Int32 x, Int32 y) const;
/* --------------------------------------------------------------------------------------------
* Set the position of the managed sprite entity for all players in the specified range.
*/
void SetPositionRange(Int32 first, Int32 last, const Vector2i & pos) const;
/* --------------------------------------------------------------------------------------------
* Set the center of the managed sprite entity for all players on the server.
*/
void SetCenterAll(const Vector2i & pos) const;
/* --------------------------------------------------------------------------------------------
* Set the center of the managed sprite entity for all players on the server.
*/
void SetCenterAllEx(Int32 x, Int32 y) const;
/* --------------------------------------------------------------------------------------------
* Set the center of the managed sprite entity for the specified player entity.
*/
void SetCenterFor(CPlayer & player, const Vector2i & pos) const;
/* --------------------------------------------------------------------------------------------
* Set the center of the managed sprite entity for the specified player entity.
*/
void SetCenterForEx(CPlayer & player, Int32 x, Int32 y) const;
/* --------------------------------------------------------------------------------------------
* Set the center of the managed sprite entity for all players in the specified range.
*/
void SetCenterRange(Int32 first, Int32 last, const Vector2i & pos) const;
/* --------------------------------------------------------------------------------------------
* Set the rotation of the managed sprite entity for all players on the server.
*/
void SetRotationAll(Float32 rot) const;
/* --------------------------------------------------------------------------------------------
* Set the rotation of the managed sprite entity for the specified player entity.
*/
void SetRotationFor(CPlayer & player, Float32 rot) const;
/* --------------------------------------------------------------------------------------------
* Set the rotation of the managed sprite entity for all players in the specified range.
*/
void SetRotationRange(Int32 first, Int32 last, Float32 rot) const;
/* --------------------------------------------------------------------------------------------
* Set the alpha of the managed sprite entity for all players on the server.
*/
void SetAlphaAll(Uint8 alpha) const;
/* --------------------------------------------------------------------------------------------
* Set the alpha of the managed sprite entity for the specified player entity.
*/
void SetAlphaFor(CPlayer & player, Uint8 alpha) const;
/* --------------------------------------------------------------------------------------------
* Set the alpha of the managed sprite entity for all players in the specified range.
*/
void SetAlphaRange(Int32 first, Int32 last, Uint8 alpha) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the file path of the texture used by the managed sprite entity.
*/
const String & GetFilePath() const;
};
} // Namespace:: SqMod
#endif // _ENTITY_SPRITE_HPP_

View File

@@ -1,563 +0,0 @@
// ------------------------------------------------------------------------------------------------
#include "Entity/Textdraw.hpp"
#include "Entity/Player.hpp"
#include "Base/Vector2i.hpp"
#include "Base/Stack.hpp"
#include "Core.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
const Int32 CTextdraw::Max = SQMOD_TEXTDRAW_POOL;
// ------------------------------------------------------------------------------------------------
SQInteger CTextdraw::Typename(HSQUIRRELVM vm)
{
static SQChar name[] = _SC("SqTextdraw");
sq_pushstring(vm, name, sizeof(name));
return 1;
}
// ------------------------------------------------------------------------------------------------
CTextdraw::CTextdraw(Int32 id)
: m_ID(VALID_ENTITYGETEX(id, SQMOD_TEXTDRAW_POOL))
, m_Tag(ToStrF("%d", id))
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
CTextdraw::~CTextdraw()
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
Int32 CTextdraw::Cmp(const CTextdraw & o) const
{
if (m_ID == o.m_ID)
return 0;
else if (m_ID > o.m_ID)
return 1;
else
return -1;
}
// ------------------------------------------------------------------------------------------------
const String & CTextdraw::ToString() const
{
return m_Tag;
}
// ------------------------------------------------------------------------------------------------
const String & CTextdraw::GetTag() const
{
return m_Tag;
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetTag(CSStr tag)
{
m_Tag.assign(tag);
}
// ------------------------------------------------------------------------------------------------
Object & CTextdraw::GetData()
{
// Validate the managed identifier
Validate();
// Return the requested information
return m_Data;
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetData(Object & data)
{
// Validate the managed identifier
Validate();
// Apply the specified value
m_Data = data;
}
// ------------------------------------------------------------------------------------------------
bool CTextdraw::Destroy(Int32 header, Object & payload)
{
// Validate the managed identifier
Validate();
// Perform the requested operation
return _Core->DelTextdraw(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::BindEvent(Int32 evid, Object & env, Function & func) const
{
// Validate the managed identifier
Validate();
// Obtain the function instance called for this event
Function & event = _Core->GetTextdrawEvent(m_ID, evid);
// Is the specified callback function null?
if (func.IsNull())
{
event.Release(); // Then release the current callback
}
// Assign the specified environment and function
else
{
event = Function(env.GetVM(), env, func.GetFunc());
}
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::ShowAll() const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->ShowTextdraw(m_ID, -1);
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::ShowFor(CPlayer & player) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->ShowTextdraw(m_ID, player.GetID());
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::ShowRange(Int32 first, Int32 last) const
{
// Validate the specified range
if (first > last)
{
STHROWF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
for (; first <= last; ++first)
{
// Is the currently processed player even connected?
if (_Func->IsPlayerConnected(first))
{
// Then show this textdraw on his client
_Func->ShowTextdraw(m_ID, first);
}
}
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::HideAll() const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->HideTextdraw(m_ID, -1);
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::HideFor(CPlayer & player) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->HideTextdraw(m_ID, player.GetID());
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::HideRange(Int32 first, Int32 last) const
{
// Validate the specified range
if (first > last)
{
STHROWF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
for (; first <= last; ++first)
{
// Is the currently processed player even connected?
if (_Func->IsPlayerConnected(first))
{
// Then hide this textdraw on his client
_Func->HideTextdraw(m_ID, first);
}
}
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetPositionAll(const Vector2i & pos) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->MoveTextdraw(m_ID, -1, pos.x, pos.y);
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetPositionAllEx(Int32 x, Int32 y) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->MoveTextdraw(m_ID, -1, x, y);
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetPositionFor(CPlayer & player, const Vector2i & pos) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->MoveTextdraw(m_ID, player.GetID(), pos.x, pos.y);
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetPositionForEx(CPlayer & player, Int32 x, Int32 y) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->MoveTextdraw(m_ID, player.GetID(), x, y);
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetPositionRange(Int32 first, Int32 last, const Vector2i & pos) const
{
// Validate the specified range
if (first > last)
{
STHROWF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
for (; first <= last; ++first)
{
// Is the currently processed player even connected?
if (_Func->IsPlayerConnected(first))
{
// Then move this textdraw on his client
_Func->MoveTextdraw(m_ID, first, pos.x, pos.y);
}
}
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetColorAll(const Color4 & col) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetTextdrawColour(m_ID, -1, col.GetRGBA());
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetColorAllEx(Uint8 r, Uint8 g, Uint8 b, Uint8 a) const
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetTextdrawColour(m_ID, -1, SQMOD_PACK_RGBA(r, g, b, a));
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetColorFor(CPlayer & player, const Color4 & col) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetTextdrawColour(m_ID, player.GetID(), col.GetRGBA());
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetColorForEx(CPlayer & player, Uint8 r, Uint8 g, Uint8 b, Uint8 a) const
{
// Is the specified player even valid?
if (!player.IsActive())
{
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetTextdrawColour(m_ID, player.GetID(), SQMOD_PACK_RGBA(r, g, b, a));
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetColorRange(Int32 first, Int32 last, const Color4 & col) const
{
// Validate the specified range
if (first > last)
{
STHROWF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
// Perform the requested operation
for (const Uint32 color = col.GetRGBA(); first <= last; ++first)
{
// Is the currently processed player even connected?
if (_Func->IsPlayerConnected(first))
{
// Then colorize this textdraw on his client
_Func->SetTextdrawColour(m_ID, first, color);
}
}
}
// ------------------------------------------------------------------------------------------------
const String & CTextdraw::GetText() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Core->GetTextdraw(m_ID).mText;
}
// ------------------------------------------------------------------------------------------------
static Object & Textdraw_CreateEx(CSStr text, Int32 xp, Int32 yp,
Uint8 r, Uint8 g, Uint8 b, Uint8 a, bool rel)
{
return _Core->NewTextdraw(SQMOD_UNKNOWN, text, xp, yp, SQMOD_PACK_ARGB(a, r, g, b), rel,
SQMOD_CREATE_DEFAULT, NullObject());
}
// ------------------------------------------------------------------------------------------------
static Object & Textdraw_CreateEx(CSStr text, Int32 xp, Int32 yp,
Uint8 r, Uint8 g, Uint8 b, Uint8 a, bool rel,
Int32 header, Object & payload)
{
return _Core->NewTextdraw(SQMOD_UNKNOWN, text, xp, yp, SQMOD_PACK_ARGB(a, r, g, b), rel,
header, payload);
}
// ------------------------------------------------------------------------------------------------
static Object & Textdraw_CreateEx(Int32 index, CSStr text, Int32 xp, Int32 yp,
Uint8 r, Uint8 g, Uint8 b, Uint8 a, bool rel)
{
return _Core->NewTextdraw(index,text, xp, yp, SQMOD_PACK_ARGB(a, r, g, b), rel,
SQMOD_CREATE_DEFAULT, NullObject());
}
// ------------------------------------------------------------------------------------------------
static Object & Textdraw_CreateEx(Int32 index, CSStr text, Int32 xp, Int32 yp,
Uint8 r, Uint8 g, Uint8 b, Uint8 a, bool rel,
Int32 header, Object & payload)
{
return _Core->NewTextdraw(index, text, xp, yp, SQMOD_PACK_ARGB(a, r, g, b), rel,
header, payload);
}
// ------------------------------------------------------------------------------------------------
static Object & Textdraw_Create(CSStr text, const Vector2i & pos, const Color4 & color, bool rel)
{
return _Core->NewTextdraw(SQMOD_UNKNOWN, text, pos.x, pos.y, color.GetARGB(), rel,
SQMOD_CREATE_DEFAULT, NullObject());
}
// ------------------------------------------------------------------------------------------------
static Object & Textdraw_Create(CSStr text, const Vector2i & pos, const Color4 & color, bool rel,
Int32 header, Object & payload)
{
return _Core->NewTextdraw(SQMOD_UNKNOWN, text, pos.x, pos.y, color.GetARGB(), rel,
header, payload);
}
// ------------------------------------------------------------------------------------------------
static Object & Textdraw_Create(Int32 index, CSStr text, const Vector2i & pos, const Color4 & color,
bool rel)
{
return _Core->NewTextdraw(index, text, pos.x, pos.y, color.GetARGB(), rel,
SQMOD_CREATE_DEFAULT, NullObject());
}
// ------------------------------------------------------------------------------------------------
static Object & Textdraw_Create(Int32 index, CSStr text, const Vector2i & pos, const Color4 & color,
bool rel, Int32 header, Object & payload)
{
return _Core->NewTextdraw(index, text, pos.x, pos.y, color.GetARGB(), rel, header, payload);
}
// ------------------------------------------------------------------------------------------------
static const Object & Textdraw_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_TEXTDRAW_POOL))
{
STHROWF("The specified textdraw identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Textdraws::const_iterator itr = _Core->GetTextdraws().cbegin();
Core::Textdraws::const_iterator end = _Core->GetTextdraws().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does the identifier match the specified one?
if (itr->mID == id)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a textdraw matching the specified identifier
return NullObject();
}
// ------------------------------------------------------------------------------------------------
static const Object & Textdraw_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == '\0')
{
STHROWF("The specified textdraw tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Textdraws::const_iterator itr = _Core->GetTextdraws().cbegin();
Core::Textdraws::const_iterator end = _Core->GetTextdraws().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
{
return itr->mObj; // Stop searching and return this entity
}
}
// Unable to locate a textdraw matching the specified tag
return NullObject();
}
// ------------------------------------------------------------------------------------------------
static Array Textdraw_FindActive()
{
// Remember the initial stack size
StackGuard sg;
// Obtain the ends of the entity pool
Core::Textdraws::const_iterator itr = _Core->GetTextdraws().cbegin();
Core::Textdraws::const_iterator end = _Core->GetTextdraws().cend();
// Allocate an empty array on the stack
sq_newarray(DefaultVM::Get(), 0);
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Is this entity instance active?
if (VALID_ENTITY(itr->mID))
{
// Push the script object on the stack
sq_pushobject(DefaultVM::Get(), (HSQOBJECT &)((*itr).mObj));
// Append the object at the back of the array
if (SQ_FAILED(sq_arrayappend(DefaultVM::Get(), -1)))
{
STHROWF("Unable to append entity instance to the list");
}
}
}
// Return the array at the top of the stack
return Var< Array >(DefaultVM::Get(), -1).value;
}
// ================================================================================================
void Register_CTextdraw(HSQUIRRELVM vm)
{
RootTable(vm).Bind(_SC("SqTextdraw"),
Class< CTextdraw, NoConstructor< CTextdraw > >(vm, _SC("SqTextdraw"))
// Metamethods
.Func(_SC("_cmp"), &CTextdraw::Cmp)
.SquirrelFunc(_SC("_typename"), &CTextdraw::Typename)
.Func(_SC("_tostring"), &CTextdraw::ToString)
// Static Values
.SetStaticValue(_SC("MaxID"), CTextdraw::Max)
// Core Properties
.Prop(_SC("ID"), &CTextdraw::GetID)
.Prop(_SC("Tag"), &CTextdraw::GetTag, &CTextdraw::SetTag)
.Prop(_SC("Data"), &CTextdraw::GetData, &CTextdraw::SetData)
.Prop(_SC("Active"), &CTextdraw::IsActive)
// Core Methods
.Func(_SC("Bind"), &CTextdraw::BindEvent)
// Core Overloads
.Overload< bool (CTextdraw::*)(void) >(_SC("Destroy"), &CTextdraw::Destroy)
.Overload< bool (CTextdraw::*)(Int32) >(_SC("Destroy"), &CTextdraw::Destroy)
.Overload< bool (CTextdraw::*)(Int32, Object &) >(_SC("Destroy"), &CTextdraw::Destroy)
// Properties
.Prop(_SC("Text"), &CTextdraw::GetText)
// Member Methods
.Func(_SC("ShowAll"), &CTextdraw::ShowAll)
.Func(_SC("ShowTo"), &CTextdraw::ShowFor)
.Func(_SC("ShowFor"), &CTextdraw::ShowFor)
.Func(_SC("ShowRange"), &CTextdraw::ShowRange)
.Func(_SC("HideAll"), &CTextdraw::HideAll)
.Func(_SC("HideFor"), &CTextdraw::HideFor)
.Func(_SC("HideFrom"), &CTextdraw::HideFor)
.Func(_SC("HideRange"), &CTextdraw::HideRange)
.Func(_SC("SetPositionRange"), &CTextdraw::SetPositionRange)
.Func(_SC("SetColorRange"), &CTextdraw::SetColorRange)
// Member Overloads
.Overload< void (CTextdraw::*)(const Vector2i &) const >
(_SC("SetPositionAll"), &CTextdraw::SetPositionAll)
.Overload< void (CTextdraw::*)(Int32, Int32) const >
(_SC("SetPositionAll"), &CTextdraw::SetPositionAllEx)
.Overload< void (CTextdraw::*)(CPlayer &, const Vector2i &) const >
(_SC("SetPositionFor"), &CTextdraw::SetPositionFor)
.Overload< void (CTextdraw::*)(CPlayer &, Int32, Int32) const >
(_SC("SetPositionFor"), &CTextdraw::SetPositionForEx)
.Overload< void (CTextdraw::*)(const Color4 &) const >
(_SC("SetColorAll"), &CTextdraw::SetColorAll)
.Overload< void (CTextdraw::*)(Uint8, Uint8, Uint8, Uint8) const >
(_SC("SetColorAll"), &CTextdraw::SetColorAllEx)
.Overload< void (CTextdraw::*)(CPlayer &, const Color4 &) const >
(_SC("SetColorFor"), &CTextdraw::SetColorFor)
.Overload< void (CTextdraw::*)(CPlayer &, Uint8, Uint8, Uint8, Uint8) const >
(_SC("SetColorFor"), &CTextdraw::SetColorForEx)
// Static Functions
.StaticFunc(_SC("FindByID"), &Textdraw_FindByID)
.StaticFunc(_SC("FindByTag"), &Textdraw_FindByTag)
.StaticFunc(_SC("FindActive"), &Textdraw_FindActive)
// Static Overloads
.StaticOverload< Object & (*)(CSStr, Int32, Int32, Uint8, Uint8, Uint8, Uint8, bool) >
(_SC("CreateEx"), &Textdraw_CreateEx)
.StaticOverload< Object & (*)(CSStr, Int32, Int32, Uint8, Uint8, Uint8, Uint8, bool, Int32, Object &) >
(_SC("CreateEx"), &Textdraw_CreateEx)
.StaticOverload< Object & (*)(Int32, CSStr, Int32, Int32, Uint8, Uint8, Uint8, Uint8, bool) >
(_SC("CreateEx"), &Textdraw_CreateEx)
.StaticOverload< Object & (*)(Int32, CSStr, Int32, Int32, Uint8, Uint8, Uint8, Uint8, bool, Int32, Object &) >
(_SC("CreateEx"), &Textdraw_CreateEx)
.StaticOverload< Object & (*)(CSStr, const Vector2i &, const Color4 &, bool) >
(_SC("Create"), &Textdraw_Create)
.StaticOverload< Object & (*)(CSStr, const Vector2i &, const Color4 &, bool, Int32, Object &) >
(_SC("Create"), &Textdraw_Create)
.StaticOverload< Object & (*)(Int32, CSStr, const Vector2i &, const Color4 &, bool) >
(_SC("Create"), &Textdraw_Create)
.StaticOverload< Object & (*)(Int32, CSStr, const Vector2i &, const Color4 &, bool, Int32, Object &) >
(_SC("Create"), &Textdraw_Create)
);
}
} // Namespace:: SqMod

View File

@@ -1,248 +0,0 @@
#ifndef _ENTITY_TEXTDRAW_HPP_
#define _ENTITY_TEXTDRAW_HPP_
// ------------------------------------------------------------------------------------------------
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Manages a single textdraw entity.
*/
class CTextdraw
{
// --------------------------------------------------------------------------------------------
friend class Core;
private:
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
*/
Int32 m_ID;
/* --------------------------------------------------------------------------------------------
* User tag associated with this instance.
*/
String m_Tag;
/* --------------------------------------------------------------------------------------------
* User data associated with this instance.
*/
Object m_Data;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CTextdraw(Int32 id);
public:
/* --------------------------------------------------------------------------------------------
* Maximum possible number that could represent an identifier for this entity type.
*/
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
CTextdraw(const CTextdraw &) = delete;
/* --------------------------------------------------------------------------------------------
* Move constructor. (disabled)
*/
CTextdraw(CTextdraw &&) = delete;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~CTextdraw();
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
CTextdraw & operator = (const CTextdraw &) = delete;
/* --------------------------------------------------------------------------------------------
* Move assignment operator. (disabled)
*/
CTextdraw & operator = (CTextdraw &&) = delete;
/* --------------------------------------------------------------------------------------------
* See whether this instance manages a valid entity.
*/
void Validate() const
{
if (INVALID_ENTITY(m_ID))
{
STHROWF("Invalid textdraw reference [%s]", m_Tag.c_str());
}
}
/* --------------------------------------------------------------------------------------------
* Used by the script engine to compare two instances of this type.
*/
Int32 Cmp(const CTextdraw & o) const;
/* --------------------------------------------------------------------------------------------
* Used by the script engine to convert an instance of this type to a string.
*/
const String & ToString() const;
/* --------------------------------------------------------------------------------------------
* Used by the script engine to retrieve the name from instances of this type.
*/
static SQInteger Typename(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Retrieve the identifier of the entity managed by this instance.
*/
Int32 GetID() const
{
return m_ID;
}
/* --------------------------------------------------------------------------------------------
* Check whether this instance manages a valid entity.
*/
bool IsActive() const
{
return VALID_ENTITY(m_ID);
}
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user tag.
*/
const String & GetTag() const;
/* --------------------------------------------------------------------------------------------
* Modify the associated user tag.
*/
void SetTag(CSStr tag);
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user data.
*/
Object & GetData();
/* --------------------------------------------------------------------------------------------
* Modify the associated user data.
*/
void SetData(Object & data);
/* --------------------------------------------------------------------------------------------
* Destroy the managed textdraw entity.
*/
bool Destroy()
{
return Destroy(0, NullObject());
}
/* --------------------------------------------------------------------------------------------
* Destroy the managed textdraw entity.
*/
bool Destroy(Int32 header)
{
return Destroy(header, NullObject());
}
/* --------------------------------------------------------------------------------------------
* Destroy the managed textdraw entity.
*/
bool Destroy(Int32 header, Object & payload);
/* --------------------------------------------------------------------------------------------
* Bind to an event supported by this entity type.
*/
void BindEvent(Int32 evid, Object & env, Function & func) const;
/* --------------------------------------------------------------------------------------------
* Show the managed textdraw entity to all players on the server.
*/
void ShowAll() const;
/* --------------------------------------------------------------------------------------------
* Show the managed textdraw entity to the specified player entity.
*/
void ShowFor(CPlayer & player) const;
/* --------------------------------------------------------------------------------------------
* Show the managed textdraw entity to all players in the specified range.
*/
void ShowRange(Int32 first, Int32 last) const;
/* --------------------------------------------------------------------------------------------
* Hide the managed textdraw entity from all players on the server.
*/
void HideAll() const;
/* --------------------------------------------------------------------------------------------
* Hide the managed textdraw entity from the specified player entity.
*/
void HideFor(CPlayer & player) const;
/* --------------------------------------------------------------------------------------------
* Hide the managed textdraw entity from all players in the specified range.
*/
void HideRange(Int32 first, Int32 last) const;
/* --------------------------------------------------------------------------------------------
* Set the position of the managed textdraw entity for all players on the server.
*/
void SetPositionAll(const Vector2i & pos) const;
/* --------------------------------------------------------------------------------------------
* Set the position of the managed textdraw entity for all players on the server.
*/
void SetPositionAllEx(Int32 x, Int32 y) const;
/* --------------------------------------------------------------------------------------------
* Set the position of the managed textdraw entity for the specified player entity.
*/
void SetPositionFor(CPlayer & player, const Vector2i & pos) const;
/* --------------------------------------------------------------------------------------------
* Set the position of the managed textdraw entity for the specified player entity.
*/
void SetPositionForEx(CPlayer & player, Int32 x, Int32 y) const;
/* --------------------------------------------------------------------------------------------
* Set the position of the managed textdraw entity for all players in the specified range.
*/
void SetPositionRange(Int32 first, Int32 last, const Vector2i & pos) const;
/* --------------------------------------------------------------------------------------------
* Set the center of the managed textdraw entity for all players on the server.
*/
void SetColorAll(const Color4 & col) const;
/* --------------------------------------------------------------------------------------------
* Set the color of the managed textdraw entity for all players on the server.
*/
void SetColorAllEx(Uint8 r, Uint8 g, Uint8 b, Uint8 a) const;
/* --------------------------------------------------------------------------------------------
* Set the color of the managed textdraw entity for the specified player entity.
*/
void SetColorFor(CPlayer & player, const Color4 & col) const;
/* --------------------------------------------------------------------------------------------
* Set the color of the managed textdraw entity for the specified player entity.
*/
void SetColorForEx(CPlayer & player, Uint8 r, Uint8 g, Uint8 b, Uint8 a) const;
/* --------------------------------------------------------------------------------------------
* Set the color of the managed textdraw entity for all players in the specified range.
*/
void SetColorRange(Int32 first, Int32 last, const Color4 & col) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the text string used by the managed textdraw entity.
*/
const String & GetText() const;
};
} // Namespace:: SqMod
#endif // _ENTITY_TEXTDRAW_HPP_

File diff suppressed because it is too large Load Diff

View File

@@ -7,6 +7,14 @@
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Circular locks employed by the vehicle manager.
*/
enum VehicleCircularLocks
{
VCL_EMIT_VEHICLE_OPTION = (1 << 0)
};
/* ------------------------------------------------------------------------------------------------
* Manages a single vehicle entity.
*/
@@ -18,8 +26,8 @@ class CVehicle
private:
// --------------------------------------------------------------------------------------------
static Vector2 s_Vector2;
static Vector3 s_Vector3;
static Vector4 s_Vector4;
static Quaternion s_Quaternion;
/* --------------------------------------------------------------------------------------------
@@ -37,6 +45,11 @@ private:
*/
Object m_Data;
/* --------------------------------------------------------------------------------------------
* Prevent events from triggering themselves.
*/
Uint32 m_CircularLocks;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
@@ -167,6 +180,21 @@ public:
*/
bool IsStreamedFor(CPlayer & player) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the current option value of the managed vehicle entity.
*/
bool GetOption(Int32 option_id) const;
/* --------------------------------------------------------------------------------------------
* Modify the current option value of the managed vehicle entity.
*/
void SetOption(Int32 option_id, bool toggle);
/* --------------------------------------------------------------------------------------------
* Modify the current option value of the managed vehicle entity.
*/
void SetOptionEx(Int32 option_id, bool toggle, Int32 header, Object & payload);
/* --------------------------------------------------------------------------------------------
* Retrieve the synchronization source of the managed vehicle entity.
*/
@@ -217,6 +245,11 @@ public:
*/
void SetImmunity(Int32 flags) const;
/* --------------------------------------------------------------------------------------------
* Explode the managed vehicle entity.
*/
void Explode() const;
/* --------------------------------------------------------------------------------------------
* See whether the managed vehicle entity is wrecked.
*/
@@ -305,27 +338,27 @@ public:
/* --------------------------------------------------------------------------------------------
* Retrieve the relative speed of the managed vehicle entity.
*/
const Vector3 & GetRelSpeed() const;
const Vector3 & GetRelativeSpeed() const;
/* --------------------------------------------------------------------------------------------
* Modify the relative speed of the managed vehicle entity.
*/
void SetRelSpeed(const Vector3 & vel) const;
void SetRelativeSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Modify the relative speed of the managed vehicle entity.
*/
void SetRelSpeedEx(Float32 x, Float32 y, Float32 z) const;
void SetRelativeSpeedEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Modify the relative speed of the managed vehicle entity.
*/
void AddRelSpeed(const Vector3 & vel) const;
void AddRelativeSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Modify the relative speed of the managed vehicle entity.
*/
void AddRelSpeedEx(Float32 x, Float32 y, Float32 z) const;
void AddRelativeSpeedEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the turn speed of the managed vehicle entity.
@@ -355,42 +388,42 @@ public:
/* --------------------------------------------------------------------------------------------
* Retrieve the relative turn speed of the managed vehicle entity.
*/
const Vector3 & GetRelTurnSpeed() const;
const Vector3 & GetRelativeTurnSpeed() const;
/* --------------------------------------------------------------------------------------------
* Modify the relative turn speed of the managed vehicle entity.
*/
void SetRelTurnSpeed(const Vector3 & vel) const;
void SetRelativeTurnSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Modify the relative turn speed of the managed vehicle entity.
*/
void SetRelTurnSpeedEx(Float32 x, Float32 y, Float32 z) const;
void SetRelativeTurnSpeedEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Modify the relative turn speed of the managed vehicle entity.
*/
void AddRelTurnSpeed(const Vector3 & vel) const;
void AddRelativeTurnSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Modify the relative turn speed of the managed vehicle entity.
*/
void AddRelTurnSpeedEx(Float32 x, Float32 y, Float32 z) const;
void AddRelativeTurnSpeedEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the spawn position of the managed vehicle entity.
*/
const Vector4 & GetSpawnPosition() const;
const Vector3 & GetSpawnPosition() const;
/* --------------------------------------------------------------------------------------------
* Modify the spawn position of the managed vehicle entity.
*/
void SetSpawnPosition(const Vector4 & pos) const;
void SetSpawnPosition(const Vector3 & pos) const;
/* --------------------------------------------------------------------------------------------
* Modify the spawn position of the managed vehicle entity.
*/
void SetSpawnPositionEx(Float32 x, Float32 y, Float32 z, Float32 w) const;
void SetSpawnPositionEx(Float32 x, Float32 y, Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the spawn rotation of the managed vehicle entity.
@@ -425,12 +458,12 @@ public:
/* --------------------------------------------------------------------------------------------
* Retrieve the respawn timer of the managed vehicle entity.
*/
Uint32 GetRespawnTimer() const;
Uint32 GetIdleRespawnTimer() const;
/* --------------------------------------------------------------------------------------------
* Modify the respawn timer of the managed vehicle entity.
*/
void SetRespawnTimer(Uint32 timer) const;
void SetIdleRespawnTimer(Uint32 millis) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the health of the managed vehicle entity.
@@ -467,16 +500,6 @@ public:
*/
void SetColors(Int32 primary, Int32 secondary) const;
/* --------------------------------------------------------------------------------------------
* See whether the managed vehicle entity is locked.
*/
bool GetLocked() const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed vehicle entity is locked.
*/
void SetLocked(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the part status of the managed vehicle entity.
*/
@@ -507,26 +530,6 @@ public:
*/
void SetDamageData(Uint32 data) const;
/* --------------------------------------------------------------------------------------------
* See whether the managed vehicle entity has alarm.
*/
bool GetAlarm() const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed vehicle entity has alarm.
*/
void SetAlarm(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the managed vehicle entity has lights.
*/
bool GetLights() const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed vehicle entity has lights.
*/
void SetLights(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the radio of the managed vehicle entity.
*/
@@ -538,159 +541,274 @@ public:
void SetRadio(Int32 radio) const;
/* --------------------------------------------------------------------------------------------
* See whether the managed vehicle entity has radio locked.
* Retrieve the turret rotation of the managed vehicle entity.
*/
bool GetRadioLocked() const;
const Vector2 & GetTurretRotation() const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed vehicle entity has radio locked.
* Retrieve the horizontal turret rotation of the managed vehicle entity.
*/
void SetRadioLocked(bool toggle) const;
Float32 GetHorizontalTurretRotation() const;
/* --------------------------------------------------------------------------------------------
* See whether the managed vehicle entity is in ghost state.
* Retrieve the vertical turret rotation of the managed vehicle entity.
*/
bool GetGhostState() const;
/* --------------------------------------------------------------------------------------------
* Set whether the managed vehicle entity is in ghost state.
*/
void SetGhostState(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* Reset all the handling rules for the managed vehicle entity.
*/
void ResetHandling() const;
/* --------------------------------------------------------------------------------------------
* Reset the specified handling rule for the managed vehicle entity.
*/
void ResetHandling(Int32 rule) const;
Float32 GetVerticalTurretRotation() const;
/* --------------------------------------------------------------------------------------------
* See whether the specified handling ruleexists in the managed vehicle entity.
*/
bool ExistsHandling(Int32 rule) const;
bool ExistsHandlingRule(Int32 rule) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the handling data of the managed vehicle entity.
*/
Float32 GetHandlingData(Int32 rule) const;
Float32 GetHandlingRule(Int32 rule) const;
/* --------------------------------------------------------------------------------------------
* Modify the handling data of the managed vehicle entity.
*/
void SetHandlingData(Int32 rule, Float32 data) const;
void SetHandlingRule(Int32 rule, Float32 data) const;
/* --------------------------------------------------------------------------------------------
* Reset the specified handling rule for the managed vehicle entity.
*/
void ResetHandlingRule(Int32 rule) const;
/* --------------------------------------------------------------------------------------------
* Reset all the handling rules for the managed vehicle entity.
*/
void ResetHandlings() const;
/* --------------------------------------------------------------------------------------------
* Embark the specified player entity into the managed vehicle entity.
*/
void Embark(CPlayer & player) const;
bool Embark(CPlayer & player) const;
/* --------------------------------------------------------------------------------------------
* Embark the specified player entity into the managed vehicle entity.
*/
void Embark(CPlayer & player, Int32 slot, bool allocate, bool warp) const;
bool Embark(CPlayer & player, Int32 slot, bool allocate, bool warp) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the x axis of the managed vehicle entity.
*/
Float32 GetPosX() const;
Float32 GetPositionX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the y axis of the managed vehicle entity.
*/
Float32 GetPosY() const;
Float32 GetPositionY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position on the z axis of the managed vehicle entity.
*/
Float32 GetPosZ() const;
Float32 GetPositionZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the x axis of the managed vehicle entity.
*/
void SetPosX(Float32 x) const;
void SetPositionX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the y axis of the managed vehicle entity.
*/
void SetPosY(Float32 y) const;
void SetPositionY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the position on the z axis of the managed vehicle entity.
*/
void SetPosZ(Float32 z) const;
void SetPositionZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation on the x axis of the managed vehicle entity.
*/
Float32 GetRotX() const;
Float32 GetRotationX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation on the y axis of the managed vehicle entity.
*/
Float32 GetRotY() const;
Float32 GetRotationY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation on the z axis of the managed vehicle entity.
*/
Float32 GetRotZ() const;
Float32 GetRotationZ() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation amount of the managed vehicle entity.
*/
Float32 GetRotW() const;
Float32 GetRotationW() const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the x axis of the managed vehicle entity.
*/
void SetRotX(Float32 x) const;
void SetRotationX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the y axis of the managed vehicle entity.
*/
void SetRotY(Float32 y) const;
void SetRotationY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation on the z axis of the managed vehicle entity.
*/
void SetRotZ(Float32 z) const;
void SetRotationZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Modify the rotation amount of the managed vehicle entity.
*/
void SetRotW(Float32 w) const;
void SetRotationW(Float32 w) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the euler rotation on the x axis of the managed vehicle entity.
*/
Float32 GetERotX() const;
Float32 GetEulerRotationX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the euler rotation on the y axis of the managed vehicle entity.
*/
Float32 GetERotY() const;
Float32 GetEulerRotationY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the euler rotation on the z axis of the managed vehicle entity.
*/
Float32 GetERotZ() const;
Float32 GetEulerRotationZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the euler rotation on the x axis of the managed vehicle entity.
*/
void SetERotX(Float32 x) const;
void SetEulerRotationX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the euler rotation on the y axis of the managed vehicle entity.
*/
void SetERotY(Float32 y) const;
void SetEulerRotationY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the euler rotation on the z axis of the managed vehicle entity.
*/
void SetERotZ(Float32 z) const;
void SetEulerRotationZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the velocity on the x axis of the managed vehicle entity.
*/
Float32 GetSpeedX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the velocity on the y axis of the managed vehicle entity.
*/
Float32 GetSpeedY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the velocity on the z axis of the managed vehicle entity.
*/
Float32 GetSpeedZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the velocity on the x axis of the managed vehicle entity.
*/
void SetSpeedX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the velocity on the y axis of the managed vehicle entity.
*/
void SetSpeedY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the velocity on the z axis of the managed vehicle entity.
*/
void SetSpeedZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the relative velocity on the x axis of the managed vehicle entity.
*/
Float32 GetRelativeSpeedX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the relative velocity on the y axis of the managed vehicle entity.
*/
Float32 GetRelativeSpeedY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the relative velocity on the z axis of the managed vehicle entity.
*/
Float32 GetRelativeSpeedZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the relative velocity on the x axis of the managed vehicle entity.
*/
void SetRelativeSpeedX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the relative velocity on the y axis of the managed vehicle entity.
*/
void SetRelativeSpeedY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the relative velocity on the z axis of the managed vehicle entity.
*/
void SetRelativeSpeedZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the turn velocity on the x axis of the managed vehicle entity.
*/
Float32 GetTurnSpeedX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the turn velocity on the y axis of the managed vehicle entity.
*/
Float32 GetTurnSpeedY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the turn velocity on the z axis of the managed vehicle entity.
*/
Float32 GetTurnSpeedZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the turn velocity on the x axis of the managed vehicle entity.
*/
void SetTurnSpeedX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the turn velocity on the y axis of the managed vehicle entity.
*/
void SetTurnSpeedY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the turn velocity on the z axis of the managed vehicle entity.
*/
void SetTurnSpeedZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the relative turn velocity on the x axis of the managed vehicle entity.
*/
Float32 GetRelativeTurnSpeedX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the relative turn velocity on the y axis of the managed vehicle entity.
*/
Float32 GetRelativeTurnSpeedY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the relative turn velocity on the z axis of the managed vehicle entity.
*/
Float32 GetRelativeTurnSpeedZ() const;
/* --------------------------------------------------------------------------------------------
* Modify the relative turn velocity on the x axis of the managed vehicle entity.
*/
void SetRelativeTurnSpeedX(Float32 x) const;
/* --------------------------------------------------------------------------------------------
* Modify the relative turn velocity on the y axis of the managed vehicle entity.
*/
void SetRelativeTurnSpeedY(Float32 y) const;
/* --------------------------------------------------------------------------------------------
* Modify the relative turn velocity on the z axis of the managed vehicle entity.
*/
void SetRelativeTurnSpeedZ(Float32 z) const;
};
} // Namespace:: SqMod