1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-15 22:57:12 +02:00

Dumped the old implementation. Started with a more simple approach.

This commit is contained in:
Sandu Liviu Catalin
2016-02-21 00:25:00 +02:00
parent 96ded94026
commit 06e598acfb
293 changed files with 37439 additions and 92564 deletions

View File

@ -6,364 +6,289 @@
namespace SqMod {
// ------------------------------------------------------------------------------------------------
CBlip::CBlip(const Reference< CBlip > & o)
: Reference(o)
SQChar CBlip::s_StrID[SQMOD_BLIP_POOL][8];
// ------------------------------------------------------------------------------------------------
const Int32 CBlip::Max = SQMOD_BLIP_POOL;
// ------------------------------------------------------------------------------------------------
CBlip::CBlip(Int32 id)
: m_ID(VALID_ENTITYGETEX(id, SQMOD_BLIP_POOL))
, m_Tag(VALID_ENTITY(m_ID) ? s_StrID[m_ID] : _SC("-1"))
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
SQInteger CBlip::GetWorld() const
CBlip::~CBlip()
{
if (VALID_ENTITY(m_ID))
{
RefType::Get(m_ID).World;
}
else
{
BadRef("@world", "get world");
}
return SQMOD_UNKNOWN;
/* ... */
}
// ------------------------------------------------------------------------------------------------
SQInteger CBlip::GetScale() const
Int32 CBlip::Cmp(const CBlip & o) const
{
if (VALID_ENTITY(m_ID))
{
RefType::Get(m_ID).Scale;
}
if (m_ID == o.m_ID)
return 0;
else if (m_ID > o.m_ID)
return 1;
else
{
BadRef("@scale", "get scale");
}
return -1;
}
return SQMOD_UNKNOWN;
CSStr CBlip::ToString() const
{
return VALID_ENTITYEX(m_ID, SQMOD_BLIP_POOL) ? s_StrID[m_ID] : _SC("-1");
}
// ------------------------------------------------------------------------------------------------
CSStr CBlip::GetTag() const
{
return m_Tag.c_str();
}
void CBlip::SetTag(CSStr tag)
{
m_Tag.assign(tag);
}
Object & CBlip::GetData()
{
if (Validate())
return m_Data;
return NullObject();
}
void CBlip::SetData(Object & data)
{
if (Validate())
m_Data = data;
}
// ------------------------------------------------------------------------------------------------
bool CBlip::Destroy(Int32 header, Object & payload)
{
return _Core->DelBlip(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
bool CBlip::BindEvent(Int32 evid, Object & env, Function & func) const
{
if (!Validate())
return false;
Function & event = _Core->GetBlipEvent(m_ID, evid);
if (func.IsNull())
event.Release();
else
event = Function(env.GetVM(), env, func.GetFunc());
return true;
}
// ------------------------------------------------------------------------------------------------
Int32 CBlip::GetWorld() const
{
if (Validate())
return _Core->GetBlip(m_ID).mWorld;
return -1;
}
Int32 CBlip::GetScale() const
{
if (Validate())
return _Core->GetBlip(m_ID).mScale;
return -1;
}
const Vector3 & CBlip::GetPosition() const
{
if (VALID_ENTITY(m_ID))
{
RefType::Get(m_ID).Position;
}
else
{
BadRef("@position", "get position");
}
if (Validate())
return _Core->GetBlip(m_ID).mPosition;
return Vector3::NIL;
}
// ------------------------------------------------------------------------------------------------
SQFloat CBlip::GetPositionX() const
{
if (VALID_ENTITY(m_ID))
{
RefType::Get(m_ID).Position.x;
}
else
{
BadRef("@pos_x", "get x axis");
}
return 0.0;
}
// ------------------------------------------------------------------------------------------------
SQFloat CBlip::GetPositionY() const
{
if (VALID_ENTITY(m_ID))
{
RefType::Get(m_ID).Position.y;
}
else
{
BadRef("@pos_y", "get y axis");
}
return 0.0;
}
// ------------------------------------------------------------------------------------------------
SQFloat CBlip::GetPositionZ() const
{
if (VALID_ENTITY(m_ID))
{
RefType::Get(m_ID).Position.z;
}
else
{
BadRef("@pos_z", "get z axis");
}
return 0.0;
}
// ------------------------------------------------------------------------------------------------
const Color4 & CBlip::GetColor() const
{
if (VALID_ENTITY(m_ID))
{
RefType::Get(m_ID).Color;
}
else
{
BadRef("@color", "get color");
}
if (Validate())
return _Core->GetBlip(m_ID).mColor;
return Color4::NIL;
}
// ------------------------------------------------------------------------------------------------
SQInt32 CBlip::GetSprID() const
Int32 CBlip::GetSprID() const
{
if (VALID_ENTITY(m_ID))
{
RefType::Get(m_ID).SprID;
}
else
{
BadRef("@spr_id", "get sprite id");
}
return SQMOD_UNKNOWN;
if (Validate())
return _Core->GetBlip(m_ID).mSprID;
return -1;
}
// ------------------------------------------------------------------------------------------------
Reference< CBlip > CreateBaseBlip_ES(SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
SQInt32 scale,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
SQInt32 sprid)
Float32 CBlip::GetPosX() const
{
return _Core->NewBlip(SQMOD_UNKNOWN, world, x, y, z, scale, PACK_RGBA(r, g, b, a), sprid,
SQMOD_CREATE_DEFAULT, NullData());
if (Validate())
return _Core->GetBlip(m_ID).mPosition.x;
return 0;
}
Reference< CBlip > CreateBaseBlip_ES(SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
SQInt32 scale,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
SQInt32 sprid,
SQInt32 header, SqObj & payload)
Float32 CBlip::GetPosY() const
{
return _Core->NewBlip(SQMOD_UNKNOWN, world, x, y, z, scale, PACK_RGBA(r, g, b, a), sprid,
if (Validate())
return _Core->GetBlip(m_ID).mPosition.y;
return 0;
}
Float32 CBlip::GetPosZ() const
{
if (Validate())
return _Core->GetBlip(m_ID).mPosition.z;
return 0;
}
// ------------------------------------------------------------------------------------------------
Int32 CBlip::GetColorR() const
{
if (Validate())
return _Core->GetBlip(m_ID).mColor.r;
return 0;
}
Int32 CBlip::GetColorG() const
{
if (Validate())
return _Core->GetBlip(m_ID).mColor.g;
return 0;
}
Int32 CBlip::GetColorB() const
{
if (Validate())
return _Core->GetBlip(m_ID).mColor.b;
return 0;
}
Int32 CBlip::GetColorA() const
{
if (Validate())
return _Core->GetBlip(m_ID).mColor.a;
return 0;
}
// ------------------------------------------------------------------------------------------------
static Object & CreateBlipEx(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,
SQMOD_CREATE_DEFAULT, NullObject());
}
static Object & CreateBlipEx(Int32 world, Float32 x, Float32 y, Float32 z, Int32 scale,
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,
header, payload);
}
// ------------------------------------------------------------------------------------------------
Reference< CBlip > CreateBaseBlip_EF(SQInt32 index, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
SQInt32 scale,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
SQInt32 sprid)
static Object & CreateBlipEx(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, PACK_RGBA(r, g, b, a), sprid,
SQMOD_CREATE_DEFAULT, NullData());
return _Core->NewBlip(index, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
SQMOD_CREATE_DEFAULT, NullObject());
}
Reference< CBlip > CreateBaseBlip_EF(SQInt32 index, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
SQInt32 scale,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
SQInt32 sprid,
SQInt32 header, SqObj & payload)
static Object & CreateBlipEx(Int32 index, Int32 world, Float32 x, Float32 y, Float32 z, Int32 scale,
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Int32 sprid,
Int32 header, Object & payload)
{
return _Core->NewBlip(index, world, x, y, z, scale, PACK_RGBA(r, g, b, a), sprid,
return _Core->NewBlip(index, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
header, payload);
}
// ------------------------------------------------------------------------------------------------
Reference< CBlip > CreateBaseBlip_CS(SQInt32 world, const Vector3 & pos,
SQInt32 scale, const Color4 & color, SQInt32 sprid)
static Object & CreateBlip(Int32 world, const Vector3 & pos, Int32 scale, const Color4 & color,
Int32 sprid)
{
return _Core->NewBlip(SQMOD_UNKNOWN, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
SQMOD_CREATE_DEFAULT, NullData());
return _Core->NewBlip(-1, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
SQMOD_CREATE_DEFAULT, NullObject());
}
Reference< CBlip > CreateBaseBlip_CS(SQInt32 world, const Vector3 & pos,
SQInt32 scale, const Color4 & color, SQInt32 sprid,
SQInt32 header, SqObj & payload)
static Object & CreateBlip(Int32 world, const Vector3 & pos, Int32 scale, const Color4 & color,
Int32 sprid, Int32 header, Object & payload)
{
return _Core->NewBlip(SQMOD_UNKNOWN, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
return _Core->NewBlip(-1, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
header, payload);
}
// ------------------------------------------------------------------------------------------------
Reference< CBlip > CreateBaseBlip_CF(SQInt32 index, SQInt32 world, const Vector3 & pos,
SQInt32 scale, const Color4 & color, SQInt32 sprid)
static Object & CreateBlip(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,
SQMOD_CREATE_DEFAULT, NullData());
SQMOD_CREATE_DEFAULT, NullObject());
}
Reference< CBlip > CreateBaseBlip_CF(SQInt32 index, SQInt32 world, const Vector3 & pos,
SQInt32 scale, const Color4 & color, SQInt32 sprid,
SQInt32 header, SqObj & payload)
{
return _Core->NewBlip(index, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CBlip CreateBlip_ES(SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
SQInt32 scale,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
SQInt32 sprid)
{
return _Core->NewBlip(SQMOD_UNKNOWN, world, x, y, z, scale, PACK_RGBA(r, g, b, a), sprid,
SQMOD_CREATE_DEFAULT, NullData());
}
CBlip CreateBlip_ES(SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
SQInt32 scale,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
SQInt32 sprid,
SQInt32 header, SqObj & payload)
{
return _Core->NewBlip(SQMOD_UNKNOWN, world, x, y, z, scale, PACK_RGBA(r, g, b, a), sprid,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CBlip CreateBlip_EF(SQInt32 index, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
SQInt32 scale,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
SQInt32 sprid)
{
return _Core->NewBlip(index, world, x, y, z, scale, PACK_RGBA(r, g, b, a), sprid,
SQMOD_CREATE_DEFAULT, NullData());
}
CBlip CreateBlip_EF(SQInt32 index, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
SQInt32 scale,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
SQInt32 sprid,
SQInt32 header, SqObj & payload)
{
return _Core->NewBlip(index, world, x, y, z, scale, PACK_RGBA(r, g, b, a), sprid,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CBlip CreateBlip_CS(SQInt32 world, const Vector3 & pos,
SQInt32 scale, const Color4 & color, SQInt32 sprid)
{
return _Core->NewBlip(SQMOD_UNKNOWN, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
SQMOD_CREATE_DEFAULT, NullData());
}
CBlip CreateBlip_CS(SQInt32 world, const Vector3 & pos,
SQInt32 scale, const Color4 & color, SQInt32 sprid,
SQInt32 header, SqObj & payload)
{
return _Core->NewBlip(SQMOD_UNKNOWN, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CBlip CreateBlip_CF(SQInt32 index, SQInt32 world, const Vector3 & pos,
SQInt32 scale, const Color4 & color, SQInt32 sprid)
{
return _Core->NewBlip(index, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
SQMOD_CREATE_DEFAULT, NullData());
}
CBlip CreateBlip_CF(SQInt32 index, SQInt32 world, const Vector3 & pos,
SQInt32 scale, const Color4 & color, SQInt32 sprid,
SQInt32 header, SqObj & payload)
static Object & CreateBlip(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,
header, payload);
}
// ================================================================================================
bool Register_CBlip(HSQUIRRELVM vm)
void Register_CBlip(HSQUIRRELVM vm)
{
// Attempt to register the base reference type before the actual implementation
if (!Register_Reference< CBlip >(vm, _SC("BaseBlip")))
{
LogFtl("Unable to register the base class <BaseBlip> for <CBlip> type");
// Registration failed
return false;
}
// Typedef the base reference type for simplicity
typedef Reference< CBlip > RefType;
// Output debugging information
LogDbg("Beginning registration of <CBlip> type");
// Attempt to register the actual reference that implements all of the entity functionality
Sqrat::RootTable(vm).Bind(_SC("CBlip"), Sqrat::DerivedClass< CBlip, RefType >(vm, _SC("CBlip"))
/* Constructors */
.Ctor()
.Ctor< SQInt32 >()
RootTable(vm).Bind(_SC("SqBlip"),
Class< CBlip, NoConstructor< CBlip > >(vm, _SC("SqBlip"))
/* Metamethods */
.Func(_SC("_cmp"), &CBlip::Cmp)
.Func(_SC("_tostring"), &CBlip::ToString)
/* Core Properties */
.Prop(_SC("ID"), &CBlip::GetID)
.Prop(_SC("Tag"), &CBlip::GetTag, &CBlip::SetTag)
.Prop(_SC("Data"), &CBlip::GetData, &CBlip::SetData)
.Prop(_SC("MaxID"), &CBlip::GetMaxID)
.Prop(_SC("Active"), &CBlip::IsActive)
/* Core Functions */
.Func(_SC("Bind"), &CBlip::BindEvent)
/* Core Overloads */
.Overload< bool (CBlip::*)(void) >(_SC("Destroy"), &CBlip::Destroy)
.Overload< bool (CBlip::*)(Int32) >(_SC("Destroy"), &CBlip::Destroy)
.Overload< bool (CBlip::*)(Int32, Object &) >(_SC("Destroy"), &CBlip::Destroy)
/* Properties */
.Prop(_SC("world"), &CBlip::GetWorld)
.Prop(_SC("scale"), &CBlip::GetScale)
.Prop(_SC("pos"), &CBlip::GetPosition)
.Prop(_SC("position"), &CBlip::GetPosition)
.Prop(_SC("color"), &CBlip::GetColor)
.Prop(_SC("spr_id"), &CBlip::GetSprID)
.Prop(_SC("pos_x"), &CBlip::GetPositionX)
.Prop(_SC("pos_y"), &CBlip::GetPositionY)
.Prop(_SC("pos_z"), &CBlip::GetPositionZ)
.Prop(_SC("World"), &CBlip::GetWorld)
.Prop(_SC("Scale"), &CBlip::GetScale)
.Prop(_SC("Pos"), &CBlip::GetPosition)
.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)
);
// Output debugging information
LogDbg("Registration of <CBlip> type was successful");
// Output debugging information
LogDbg("Beginning registration of <Blip> functions");
// Register global functions related to this entity type
Sqrat::RootTable(vm)
/* Create BaseBlip [E]xtended [S]ubstitute */
.Overload< RefType (*)(SQInt32, SQFloat, SQFloat, SQFloat, SQInt32, Uint8, Uint8, Uint8, Uint8, SQInt32) >
(_SC("CreateBaseBlip_ES"), &CreateBaseBlip_ES)
.Overload< RefType (*)(SQInt32, SQFloat, SQFloat, SQFloat, SQInt32, Uint8, Uint8, Uint8, Uint8, SQInt32, SQInt32, SqObj &) >
(_SC("CreateBaseBlip_ES"), &CreateBaseBlip_ES)
/* Create BaseBlip [E]xtended [F]Full */
.Overload< RefType (*)(SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, SQInt32, Uint8, Uint8, Uint8, Uint8, SQInt32) >
(_SC("CreateBaseBlip_EF"), &CreateBaseBlip_EF)
.Overload< RefType (*)(SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, SQInt32, Uint8, Uint8, Uint8, Uint8, SQInt32, SQInt32, SqObj &) >
(_SC("CreateBaseBlip_EF"), &CreateBaseBlip_EF)
/* Create BaseBlip [C]ompact [S]ubstitute */
.Overload< RefType (*)(SQInt32, const Vector3 &, SQInt32, const Color4 &, SQInt32) >
(_SC("CreateBaseBlip_CS"), &CreateBaseBlip_CS)
.Overload< RefType (*)(SQInt32, const Vector3 &, SQInt32, const Color4 &, SQInt32, SQInt32, SqObj &) >
(_SC("CreateBaseBlip_CS"), &CreateBaseBlip_CS)
/* Create BaseBlip [C]ompact [F]ull */
.Overload< RefType (*)(SQInt32, SQInt32, const Vector3 &, SQInt32, const Color4 &, SQInt32) >
(_SC("CreateBaseBlip_CF"), &CreateBaseBlip_CF)
.Overload< RefType (*)(SQInt32, SQInt32, const Vector3 &, SQInt32, const Color4 &, SQInt32, SQInt32, SqObj &) >
(_SC("CreateBaseBlip_CF"), &CreateBaseBlip_CF)
/* Create CBlip [E]xtended [S]ubstitute */
.Overload< CBlip (*)(SQInt32, SQFloat, SQFloat, SQFloat, SQInt32, Uint8, Uint8, Uint8, Uint8, SQInt32) >
(_SC("CreateBlip_ES"), &CreateBlip_ES)
.Overload< CBlip (*)(SQInt32, SQFloat, SQFloat, SQFloat, SQInt32, Uint8, Uint8, Uint8, Uint8, SQInt32, SQInt32, SqObj &) >
(_SC("CreateBlip_ES"), &CreateBlip_ES)
/* Create CBlip [E]xtended [F]Full */
.Overload< CBlip (*)(SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, SQInt32, Uint8, Uint8, Uint8, Uint8, SQInt32) >
(_SC("CreateBlip_EF"), &CreateBlip_EF)
.Overload< CBlip (*)(SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, SQInt32, Uint8, Uint8, Uint8, Uint8, SQInt32, SQInt32, SqObj &) >
(_SC("CreateBlip_EF"), &CreateBlip_EF)
/* Create CBlip [C]ompact [S]ubstitute */
.Overload< CBlip (*)(SQInt32, const Vector3 &, SQInt32, const Color4 &, SQInt32) >
(_SC("CreateBlip_CS"), &CreateBlip_CS)
.Overload< CBlip (*)(SQInt32, const Vector3 &, SQInt32, const Color4 &, SQInt32, SQInt32, SqObj &) >
(_SC("CreateBlip_CS"), &CreateBlip_CS)
/* Create CBlip [C]ompact [F]ull */
.Overload< CBlip (*)(SQInt32, SQInt32, const Vector3 &, SQInt32, const Color4 &, SQInt32) >
(_SC("CreateBlip_CF"), &CreateBlip_CF)
.Overload< CBlip (*)(SQInt32, SQInt32, const Vector3 &, SQInt32, const Color4 &, SQInt32, SQInt32, SqObj &) >
(_SC("CreateBlip_CF"), &CreateBlip_CF);
// Output debugging information
LogDbg("Registration of <Blip> functions was successful");
// Registration succeeded
return true;
RootTable(vm)
.Overload< Object & (*)(Int32, Float32, Float32, Float32, Int32, Uint8, Uint8, Uint8, Uint8, Int32) >
(_SC("CreateBlipEx"), &CreateBlipEx)
.Overload< Object & (*)(Int32, Float32, Float32, Float32, Int32, Uint8, Uint8, Uint8, Uint8, Int32, Int32, Object &) >
(_SC("CreateBlipEx"), &CreateBlipEx)
.Overload< Object & (*)(Int32, Int32, Float32, Float32, Float32, Int32, Uint8, Uint8, Uint8, Uint8, Int32) >
(_SC("CreateBlipEx"), &CreateBlipEx)
.Overload< Object & (*)(Int32, Int32, Float32, Float32, Float32, Int32, Uint8, Uint8, Uint8, Uint8, Int32, Int32, Object &) >
(_SC("CreateBlipEx"), &CreateBlipEx)
.Overload< Object & (*)(Int32, const Vector3 &, Int32, const Color4 &, Int32) >
(_SC("CreateBlip"), &CreateBlip)
.Overload< Object & (*)(Int32, const Vector3 &, Int32, const Color4 &, Int32, Int32, Object &) >
(_SC("CreateBlip"), &CreateBlip)
.Overload< Object & (*)(Int32, Int32, const Vector3 &, Int32, const Color4 &, Int32) >
(_SC("CreateBlip"), &CreateBlip)
.Overload< Object & (*)(Int32, Int32, const Vector3 &, Int32, const Color4 &, Int32, Int32, Object &) >
(_SC("CreateBlip"), &CreateBlip);
}
} // Namespace:: SqMod
} // Namespace:: SqMod

View File

@ -2,69 +2,145 @@
#define _ENTITY_BLIP_HPP_
// ------------------------------------------------------------------------------------------------
#include "Entity.hpp"
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Class responsible for managing the referenced blip instance.
* Manages Blip instances.
*/
class CBlip : public Reference< CBlip >
class CBlip
{
// --------------------------------------------------------------------------------------------
friend class Core;
private:
/* --------------------------------------------------------------------------------------------
* Cached identifiers for fast integer to string conversion.
*/
static SQChar s_StrID[SQMOD_BLIP_POOL][8];
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
*/
Int32 m_ID;
/* --------------------------------------------------------------------------------------------
* User tag and data associated with this instance.
*/
String m_Tag;
Object m_Data;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CBlip(Int32 id);
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
CBlip(const CBlip &);
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
CBlip & operator = (const CBlip &);
public:
/* --------------------------------------------------------------------------------------------
* Import the constructors, destructors and assignment operators from the base class.
*/
using RefType::Reference;
// --------------------------------------------------------------------------------------------
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* Construct a reference from a base reference.
* Destructor.
*/
CBlip(const Reference< CBlip > & o);
~CBlip();
/* --------------------------------------------------------------------------------------------
* Retrieve the world in which the referenced blip instance exists.
* See whether this instance manages a valid entity.
*/
SQInteger GetWorld() const;
bool Validate() const
{
if (VALID_ENTITY(m_ID))
return true;
SqThrow("Invalid blip reference [%s]", m_Tag.c_str());
return false;
}
/* --------------------------------------------------------------------------------------------
* Retrieve the scale of the referenced blip instance.
* Used by the script engine to compare two instances of this type.
*/
SQInteger GetScale() const;
Int32 Cmp(const CBlip & o) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position of the referenced blip instance.
* Used by the script engine to convert an instance of this type to a string.
*/
CSStr ToString() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the identifier of the entity managed by this instance.
*/
Int32 GetID() const { return m_ID; }
/* --------------------------------------------------------------------------------------------
* Retrieve the maximum possible identifier to an entity of this type.
*/
Int32 GetMaxID() const { return SQMOD_BLIP_POOL; }
/* --------------------------------------------------------------------------------------------
* Check whether this instance manages a valid entity.
*/
bool IsActive() const { return VALID_ENTITY(m_ID); }
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user tag.
*/
CSStr 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 entity instance.
*/
bool Destroy(Int32 header, Object & payload);
bool Destroy() { return Destroy(0, NullObject()); }
bool Destroy(Int32 header) { return Destroy(header, NullObject()); }
// --------------------------------------------------------------------------------------------
bool BindEvent(Int32 evid, Object & env, Function & func) const;
// --------------------------------------------------------------------------------------------
Int32 GetWorld() const;
Int32 GetScale() const;
const Vector3 & GetPosition() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the x axis position of the referenced blip instance.
*/
SQFloat GetPositionX() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the y axis position of the referenced blip instance.
*/
SQFloat GetPositionY() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the z axis position of the referenced blip instance.
*/
SQFloat GetPositionZ() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the color of the referenced blip instance.
*/
const Color4 & GetColor() const;
Int32 GetSprID() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the sprite identifier of the referenced blip instance.
*/
SQInt32 GetSprID() const;
// --------------------------------------------------------------------------------------------
Float32 GetPosX() const;
Float32 GetPosY() const;
Float32 GetPosZ() const;
Int32 GetColorR() const;
Int32 GetColorG() const;
Int32 GetColorB() const;
Int32 GetColorA() const;
};
} // Namespace:: SqMod
#endif // _ENTITY_BLIP_HPP_
#endif // _ENTITY_BLIP_HPP_

View File

@ -1,447 +1,403 @@
// ------------------------------------------------------------------------------------------------
#include "Entity/Checkpoint.hpp"
#include "Entity/Player.hpp"
#include "Base/Color4.hpp"
#include "Base/Vector3.hpp"
#include "Core.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
Color4 CCheckpoint::s_Color4;
Vector3 CCheckpoint::s_Vector3;
Color4 CCheckpoint::s_Color4;
Vector3 CCheckpoint::s_Vector3;
// ------------------------------------------------------------------------------------------------
SQUint32 CCheckpoint::s_ColorR;
SQUint32 CCheckpoint::s_ColorG;
SQUint32 CCheckpoint::s_ColorB;
SQUint32 CCheckpoint::s_ColorA;
Uint32 CCheckpoint::s_ColorR;
Uint32 CCheckpoint::s_ColorG;
Uint32 CCheckpoint::s_ColorB;
Uint32 CCheckpoint::s_ColorA;
// ------------------------------------------------------------------------------------------------
CCheckpoint::CCheckpoint(const Reference< CCheckpoint > & o)
: Reference(o)
SQChar CCheckpoint::s_StrID[SQMOD_CHECKPOINT_POOL][8];
// ------------------------------------------------------------------------------------------------
const Int32 CCheckpoint::Max = SQMOD_CHECKPOINT_POOL;
// ------------------------------------------------------------------------------------------------
CCheckpoint::CCheckpoint(Int32 id)
: m_ID(VALID_ENTITYGETEX(id, SQMOD_CHECKPOINT_POOL))
, m_Tag(VALID_ENTITY(m_ID) ? s_StrID[m_ID] : _SC("-1"))
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
bool CCheckpoint::IsStreamedFor(const Reference< CPlayer > & player) const
CCheckpoint::~CCheckpoint()
{
if (VALID_ENTITY(m_ID) && player)
{
return _Func->IsCheckpointStreamedForPlayer(m_ID, player);
}
else if (!player)
{
BadArg("streamed_for", "see whether is streamed for player", _SCI32(player));
}
else
{
BadRef("streamed_for", "see whether is streamed for player");
}
/* ... */
}
// ------------------------------------------------------------------------------------------------
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;
}
CSStr CCheckpoint::ToString() const
{
return VALID_ENTITYEX(m_ID, SQMOD_CHECKPOINT_POOL) ? s_StrID[m_ID] : _SC("-1");
}
// ------------------------------------------------------------------------------------------------
CSStr CCheckpoint::GetTag() const
{
return m_Tag.c_str();
}
void CCheckpoint::SetTag(CSStr tag)
{
m_Tag.assign(tag);
}
Object & CCheckpoint::GetData()
{
if (Validate())
return m_Data;
return NullObject();
}
void CCheckpoint::SetData(Object & data)
{
if (Validate())
m_Data = data;
}
// ------------------------------------------------------------------------------------------------
bool CCheckpoint::Destroy(Int32 header, Object & payload)
{
return _Core->DelCheckpoint(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
bool CCheckpoint::BindEvent(Int32 evid, Object & env, Function & func) const
{
if (!Validate())
return false;
Function & event = _Core->GetCheckpointEvent(m_ID, evid);
if (func.IsNull())
event.Release();
else
event = Function(env.GetVM(), env, func.GetFunc());
return true;
}
// ------------------------------------------------------------------------------------------------
bool CCheckpoint::IsStreamedFor(CPlayer & player) const
{
if (!player.IsActive())
SqThrow("Invalid player argument: null");
else if (Validate())
return _Func->IsCheckpointStreamedForPlayer(m_ID, player.GetID());
return false;
}
// ------------------------------------------------------------------------------------------------
SQInt32 CCheckpoint::GetWorld() const
Int32 CCheckpoint::GetWorld() const
{
if (VALID_ENTITY(m_ID))
{
if (Validate())
return _Func->GetCheckpointWorld(m_ID);
}
else
{
BadRef("@world", "get world");
}
return SQMOD_UNKNOWN;
return -1;
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetWorld(SQInt32 world) const
void CCheckpoint::SetWorld(Int32 world) const
{
if (VALID_ENTITY(m_ID))
{
if (Validate())
_Func->SetCheckpointWorld(m_ID, world);
}
else
{
BadRef("@world", "set world");
}
}
// ------------------------------------------------------------------------------------------------
const Color4 & CCheckpoint::GetColor() const
{
// Clear any previous color
s_Color4.Clear();
// Attempt to retrieve the color
if (VALID_ENTITY(m_ID))
if (Validate())
{
_Func->GetCheckpointColor(m_ID, &s_ColorR, &s_ColorG, &s_ColorB, &s_ColorA);
s_Color4.Set(s_ColorR, s_ColorG, s_ColorB, s_ColorA);
}
else
{
BadRef("@color", "get color");
}
// Return the color that could be retrieved
return s_Color4;
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetColor(const Color4 & col) const
{
if (VALID_ENTITY(m_ID))
{
if (Validate())
_Func->SetCheckpointColor(m_ID, col.r, col.g, col.b, col.a);
}
else
{
BadRef("@color", "set color");
}
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetColorEx(Uint8 r, Uint8 g, Uint8 b, Uint8 a) const
{
if (VALID_ENTITY(m_ID))
{
if (Validate())
_Func->SetCheckpointColor(m_ID, r, g, b, a);
}
else
{
BadRef("set_color", "set color");
}
}
// ------------------------------------------------------------------------------------------------
const Vector3 & CCheckpoint::GetPosition() const
{
// Clear any previous position
s_Vector3.Clear();
// Attempt to retrieve the position
if (VALID_ENTITY(m_ID))
{
if (Validate())
_Func->GetCheckpointPos(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z);
}
else
{
BadRef("@position", "get position");
}
// Return the position that could be retrieved
return s_Vector3;
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetPosition(const Vector3 & pos) const
{
if (VALID_ENTITY(m_ID))
{
if (Validate())
_Func->SetCheckpointPos(m_ID, pos.x, pos.y, pos.z);
}
else
{
BadRef("@position", "set position");
}
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetPositionEx(SQFloat x, SQFloat y, SQFloat z) const
void CCheckpoint::SetPositionEx(Float32 x, Float32 y, Float32 z) const
{
if (VALID_ENTITY(m_ID))
{
if (Validate())
_Func->SetCheckpointPos(m_ID, x, y, z);
}
else
{
BadRef("set_position", "set position");
}
}
// ------------------------------------------------------------------------------------------------
SQFloat CCheckpoint::GetRadius() const
Float32 CCheckpoint::GetRadius() const
{
if (VALID_ENTITY(m_ID))
{
return _Func->GetCheckpointRadius(m_ID);
}
else
{
BadRef("@radius", "get radius");
}
return 0.0;
if (Validate())
_Func->GetCheckpointRadius(m_ID);
return 0;
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetRadius(SQFloat radius) const
void CCheckpoint::SetRadius(Float32 radius) const
{
if (VALID_ENTITY(m_ID))
{
if (Validate())
_Func->SetCheckpointRadius(m_ID, radius);
}
else
{
BadRef("@radius", "set radius");
}
}
// ------------------------------------------------------------------------------------------------
Reference< CPlayer > CCheckpoint::GetOwner() const
Object & CCheckpoint::GetOwner() const
{
if (VALID_ENTITY(m_ID))
{
return Reference< CPlayer >(_Func->GetCheckpointOwner(m_ID));
}
else
{
BadRef("@owner", "get owner");
}
return Reference< CPlayer >();
if (Validate())
return _Core->GetPlayer(_Func->GetCheckpointOwner(m_ID)).mObj;
return NullObject();
}
// ------------------------------------------------------------------------------------------------
SQInt32 CCheckpoint::GetOwnerID() const
Int32 CCheckpoint::GetOwnerID() const
{
if (VALID_ENTITY(m_ID))
{
if (Validate())
return _Func->GetCheckpointOwner(m_ID);
}
else
return -1;
}
// ------------------------------------------------------------------------------------------------
Float32 CCheckpoint::GetPosX() const
{
s_Vector3.x = 0;
if (Validate())
_Func->GetCheckpointPos(m_ID, &s_Vector3.x, NULL, NULL);
return s_Vector3.x;
}
Float32 CCheckpoint::GetPosY() const
{
s_Vector3.y = 0;
if (Validate())
_Func->GetCheckpointPos(m_ID, NULL, &s_Vector3.y, NULL);
return s_Vector3.y;
}
Float32 CCheckpoint::GetPosZ() const
{
s_Vector3.z = 0;
if (Validate())
_Func->GetCheckpointPos(m_ID, NULL, NULL, &s_Vector3.z);
return s_Vector3.z;
}
// ------------------------------------------------------------------------------------------------
void CCheckpoint::SetPosX(Float32 x) const
{
if (Validate())
{
BadRef("@owner_id", "get owner id");
_Func->GetCheckpointPos(m_ID, NULL, &s_Vector3.y, &s_Vector3.z);
_Func->SetCheckpointPos(m_ID, x, s_Vector3.y, s_Vector3.z);
}
}
return SQMOD_UNKNOWN;
void CCheckpoint::SetPosY(Float32 y) const
{
if (Validate())
{
_Func->GetCheckpointPos(m_ID, &s_Vector3.x, NULL, &s_Vector3.z);
_Func->SetCheckpointPos(m_ID, s_Vector3.x, y, s_Vector3.z);
}
}
void CCheckpoint::SetPosZ(Float32 z) const
{
if (Validate())
{
_Func->GetCheckpointPos(m_ID, &s_Vector3.x, &s_Vector3.y, NULL);
_Func->SetCheckpointPos(m_ID, s_Vector3.z, s_Vector3.y, z);
}
}
// ------------------------------------------------------------------------------------------------
Reference< CCheckpoint > CreateBaseCheckpoint_PEF(SQInt32 player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
SQFloat radius)
Uint32 CCheckpoint::GetColR() const
{
return _Core->NewCheckpoint(player, world, x, y, z, r, g, b, a, radius,
SQMOD_CREATE_DEFAULT, NullData());
s_ColorR = 0;
if (Validate())
_Func->GetCheckpointColor(m_ID, &s_ColorR, NULL, NULL, NULL);
return s_ColorR;
}
Reference< CCheckpoint > CreateBaseCheckpoint_PEF(SQInt32 player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
SQFloat radius,
SQInt32 header, SqObj & payload)
Uint32 CCheckpoint::GetColG() const
{
return _Core->NewCheckpoint(player, world, x, y, z, r, g, b, a, radius,
header, payload);
s_ColorG = 0;
if (Validate())
_Func->GetCheckpointColor(m_ID, NULL, &s_ColorG, NULL, NULL);
return s_ColorG;
}
Uint32 CCheckpoint::GetColB() const
{
s_ColorB = 0;
if (Validate())
_Func->GetCheckpointColor(m_ID, NULL, NULL, &s_ColorB, NULL);
return s_ColorB;
}
Uint32 CCheckpoint::GetColA() const
{
s_ColorA = 0;
if (Validate())
_Func->GetCheckpointColor(m_ID, NULL, NULL, NULL, &s_ColorA);
return s_ColorA;
}
// ------------------------------------------------------------------------------------------------
Reference< CCheckpoint > CreateBaseCheckpoint_PCF(SQInt32 player, SQInt32 world,
const Vector3 & pos, const Color4 & color, SQFloat radius)
void CCheckpoint::SetColR(Uint32 r) const
{
return _Core->NewCheckpoint(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, color.a, radius,
SQMOD_CREATE_DEFAULT, NullData());
if (Validate())
{
_Func->GetCheckpointColor(m_ID, NULL, &s_ColorG, &s_ColorB, &s_ColorA);
_Func->SetCheckpointColor(m_ID, r, s_ColorG, s_ColorB, s_ColorA);
}
}
Reference< CCheckpoint > CreateBaseCheckpoint_PCF(SQInt32 player, SQInt32 world,
const Vector3 & pos, const Color4 & color, SQFloat radius,
SQInt32 header, SqObj & payload)
void CCheckpoint::SetColG(Uint32 g) const
{
return _Core->NewCheckpoint(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, color.a, radius,
header, payload);
if (Validate())
{
_Func->GetCheckpointColor(m_ID, &s_ColorR, NULL, &s_ColorB, &s_ColorA);
_Func->SetCheckpointColor(m_ID, s_ColorR, g, s_ColorB, s_ColorA);
}
}
void CCheckpoint::SetColB(Uint32 b) const
{
if (Validate())
{
_Func->GetCheckpointColor(m_ID, &s_ColorB, &s_ColorG, NULL, &s_ColorA);
_Func->SetCheckpointColor(m_ID, s_ColorB, s_ColorG, b, s_ColorA);
}
}
void CCheckpoint::SetColA(Uint32 a) const
{
if (Validate())
{
_Func->GetCheckpointColor(m_ID, &s_ColorA, &s_ColorG, &s_ColorB, NULL);
_Func->SetCheckpointColor(m_ID, s_ColorA, s_ColorG, s_ColorB, a);
}
}
// ------------------------------------------------------------------------------------------------
Reference< CCheckpoint > CreateBaseCheckpoint_EF(const Reference< CPlayer > & player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
SQFloat radius)
static Object & CreateCheckpointEx(CPlayer & player, Int32 world, Float32 x, Float32 y, Float32 z,
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Float32 radius)
{
return _Core->NewCheckpoint(player, world, x, y, z, r, g, b, a, radius,
SQMOD_CREATE_DEFAULT, NullData());
return _Core->NewCheckpoint(player.GetID(), world, x, y, z, r, g, b, a, radius,
SQMOD_CREATE_DEFAULT, NullObject());
}
Reference< CCheckpoint > CreateBaseCheckpoint_EF(const Reference< CPlayer > & player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
SQFloat radius,
SQInt32 header, SqObj & payload)
static Object & CreateCheckpointEx(CPlayer & player, Int32 world, Float32 x, Float32 y, Float32 z,
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Float32 radius,
Int32 header, Object & payload)
{
return _Core->NewCheckpoint(player, world, x, y, z, r, g, b, a, radius,
header, payload);
return _Core->NewCheckpoint(player.GetID(), world, x, y, z, r, g, b, a, radius, header, payload);
}
// ------------------------------------------------------------------------------------------------
Reference< CCheckpoint > CreateBaseCheckpoint_CF(const Reference< CPlayer > & player, SQInt32 world,
const Vector3 & pos, const Color4 & color, SQFloat radius)
static Object & CreateCheckpoint(CPlayer & player, Int32 world, const Vector3 & pos,
const Color4 & color, Float32 radius)
{
return _Core->NewCheckpoint(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, color.a, radius,
SQMOD_CREATE_DEFAULT, NullData());
return _Core->NewCheckpoint(player.GetID(), world, pos.x, pos.y, pos.z,
color.r, color.g, color.b, color.a, radius,
SQMOD_CREATE_DEFAULT, NullObject());
}
Reference< CCheckpoint > CreateBaseCheckpoint_CF(const Reference< CPlayer > & player, SQInt32 world,
const Vector3 & pos, const Color4 & color, SQFloat radius,
SQInt32 header, SqObj & payload)
static Object & CreateCheckpoint(CPlayer & player, Int32 world, const Vector3 & pos,
const Color4 & color, Float32 radius, Int32 header, Object & payload)
{
return _Core->NewCheckpoint(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, color.a, radius,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CCheckpoint CreateCheckpoint_PEF(SQInt32 player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
SQFloat radius)
{
return _Core->NewCheckpoint(player, world, x, y, z, r, g, b, a, radius,
SQMOD_CREATE_DEFAULT, NullData());
}
CCheckpoint CreateCheckpoint_PEF(SQInt32 player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
SQFloat radius,
SQInt32 header, SqObj & payload)
{
return _Core->NewCheckpoint(player, world, x, y, z, r, g, b, a, radius,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CCheckpoint CreateCheckpoint_PCF(SQInt32 player, SQInt32 world,
const Vector3 & pos, const Color4 & color, SQFloat radius)
{
return _Core->NewCheckpoint(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, color.a, radius,
SQMOD_CREATE_DEFAULT, NullData());
}
CCheckpoint CreateCheckpoint_PCF(SQInt32 player, SQInt32 world,
const Vector3 & pos, const Color4 & color, SQFloat radius,
SQInt32 header, SqObj & payload)
{
return _Core->NewCheckpoint(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, color.a, radius,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CCheckpoint CreateCheckpoint_EF(const Reference< CPlayer > & player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
SQFloat radius)
{
return _Core->NewCheckpoint(player, world, x, y, z, r, g, b, a, radius,
SQMOD_CREATE_DEFAULT, NullData());
}
CCheckpoint CreateCheckpoint_EF(const Reference< CPlayer > & player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
SQFloat radius,
SQInt32 header, SqObj & payload)
{
return _Core->NewCheckpoint(player, world, x, y, z, r, g, b, a, radius,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CCheckpoint CreateCheckpoint_CF(const Reference< CPlayer > & player, SQInt32 world,
const Vector3 & pos, const Color4 & color, SQFloat radius)
{
return _Core->NewCheckpoint(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, color.a, radius,
SQMOD_CREATE_DEFAULT, NullData());
}
CCheckpoint CreateCheckpoint_CF(const Reference< CPlayer > & player, SQInt32 world,
const Vector3 & pos, const Color4 & color, SQFloat radius,
SQInt32 header, SqObj & payload)
{
return _Core->NewCheckpoint(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, color.a, radius,
header, payload);
return _Core->NewCheckpoint(player.GetID(), world, pos.x, pos.y, pos.z,
color.r, color.g, color.b, color.a, radius, header, payload);
}
// ================================================================================================
bool Register_CCheckpoint(HSQUIRRELVM vm)
void Register_CCheckpoint(HSQUIRRELVM vm)
{
// Attempt to register the base reference type before the actual implementation
if (!Register_Reference< CCheckpoint >(vm, _SC("BaseCheckpoint")))
{
LogFtl("Unable to register the base class <BaseCheckpoint> for <CCheckpoint> type");
// Registration failed
return false;
}
// Typedef the base reference type for simplicity
typedef Reference< CCheckpoint > RefType;
// Output debugging information
LogDbg("Beginning registration of <CCheckpoint> type");
// Attempt to register the actual reference that implements all of the entity functionality
Sqrat::RootTable(vm).Bind(_SC("CCheckpoint"), Sqrat::DerivedClass< CCheckpoint, RefType >(vm, _SC("CCheckpoint"))
/* Constructors */
.Ctor()
.Ctor< SQInt32 >()
RootTable(vm).Bind(_SC("SqCheckpoint"),
Class< CCheckpoint, NoConstructor< CCheckpoint > >(vm, _SC("SqCheckpoint"))
/* Metamethods */
.Func(_SC("_cmp"), &CCheckpoint::Cmp)
.Func(_SC("_tostring"), &CCheckpoint::ToString)
/* Core Properties */
.Prop(_SC("ID"), &CCheckpoint::GetID)
.Prop(_SC("Tag"), &CCheckpoint::GetTag, &CCheckpoint::SetTag)
.Prop(_SC("Data"), &CCheckpoint::GetData, &CCheckpoint::SetData)
.Prop(_SC("MaxID"), &CCheckpoint::GetMaxID)
.Prop(_SC("Active"), &CCheckpoint::IsActive)
/* Core Functions */
.Func(_SC("Bind"), &CCheckpoint::BindEvent)
/* Core Overloads */
.Overload< bool (CCheckpoint::*)(void) >(_SC("Destroy"), &CCheckpoint::Destroy)
.Overload< bool (CCheckpoint::*)(Int32) >(_SC("Destroy"), &CCheckpoint::Destroy)
.Overload< bool (CCheckpoint::*)(Int32, Object &) >(_SC("Destroy"), &CCheckpoint::Destroy)
/* Properties */
.Prop(_SC("world"), &CCheckpoint::GetWorld, &CCheckpoint::SetWorld)
.Prop(_SC("color"), &CCheckpoint::GetColor, &CCheckpoint::SetColor)
.Prop(_SC("position"), &CCheckpoint::GetPosition, &CCheckpoint::SetPosition)
.Prop(_SC("radius"), &CCheckpoint::GetRadius, &CCheckpoint::SetRadius)
.Prop(_SC("owner"), &CCheckpoint::GetOwner)
.Prop(_SC("owner_id"), &CCheckpoint::GetOwnerID)
.Prop(_SC("World"), &CCheckpoint::GetWorld, &CCheckpoint::SetWorld)
.Prop(_SC("Color"), &CCheckpoint::GetColor, &CCheckpoint::SetColor)
.Prop(_SC("Pos"), &CCheckpoint::GetPosition, &CCheckpoint::SetPosition)
.Prop(_SC("Position"), &CCheckpoint::GetPosition, &CCheckpoint::SetPosition)
.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)
/* Functions */
.Func(_SC("streamed_for"), &CCheckpoint::IsStreamedFor)
.Func(_SC("set_color"), &CCheckpoint::SetColorEx)
.Func(_SC("set_position"), &CCheckpoint::SetPositionEx)
.Func(_SC("StreamedFor"), &CCheckpoint::IsStreamedFor)
.Func(_SC("SetColor"), &CCheckpoint::SetColorEx)
.Func(_SC("SetPos"), &CCheckpoint::SetPositionEx)
.Func(_SC("SetPosition"), &CCheckpoint::SetPositionEx)
);
// Output debugging information
LogDbg("Registration of <CCheckpoint> type was successful");
// Output debugging information
LogDbg("Beginning registration of <Checkpoint> functions");
// Register global functions related to this entity type
Sqrat::RootTable(vm)
/* Create BaseCheckpoint [P]rimitive [E]xtended [F]Full */
.Overload< RefType (*)(SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, Uint8, SQFloat) >
(_SC("CreateBaseCheckpoint_PEF"), &CreateBaseCheckpoint_PEF)
.Overload< RefType (*)(SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, Uint8, SQFloat, SQInt32, SqObj &) >
(_SC("CreateBaseCheckpoint_PEF"), &CreateBaseCheckpoint_PEF)
/* Create BaseCheckpoint [P]rimitive [C]ompact [F]ull */
.Overload< RefType (*)(SQInt32, SQInt32, const Vector3 &, const Color4 &, SQFloat) >
(_SC("CreateBaseCheckpoint_PCF"), &CreateBaseCheckpoint_PCF)
.Overload< RefType (*)(SQInt32, SQInt32, const Vector3 &, const Color4 &, SQFloat, SQInt32, SqObj &) >
(_SC("CreateBaseCheckpoint_PCF"), &CreateBaseCheckpoint_PCF)
/* Create BaseCheckpoint [E]xtended [F]Full */
.Overload< RefType (*)(const Reference< CPlayer > &, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, Uint8, SQFloat) >
(_SC("CreateBaseCheckpoint_EF"), &CreateBaseCheckpoint_EF)
.Overload< RefType (*)(const Reference< CPlayer > &, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, Uint8, SQFloat, SQInt32, SqObj &) >
(_SC("CreateBaseCheckpoint_EF"), &CreateBaseCheckpoint_EF)
/* Create BaseCheckpoint [C]ompact [F]ull */
.Overload< RefType (*)(const Reference< CPlayer > &, SQInt32, const Vector3 &, const Color4 &, SQFloat) >
(_SC("CreateBaseCheckpoint_CF"), &CreateBaseCheckpoint_CF)
.Overload< RefType (*)(const Reference< CPlayer > &, SQInt32, const Vector3 &, const Color4 &, SQFloat, SQInt32, SqObj &) >
(_SC("CreateBaseCheckpoint_CF"), &CreateBaseCheckpoint_CF)
/* Create CCheckpoint [P]rimitive [E]xtended [F]Full */
.Overload< CCheckpoint (*)(SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, Uint8, SQFloat) >
(_SC("CreateCheckpoint_PEF"), &CreateCheckpoint_PEF)
.Overload< CCheckpoint (*)(SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, Uint8, SQFloat, SQInt32, SqObj &) >
(_SC("CreateCheckpoint_PEF"), &CreateCheckpoint_PEF)
/* Create CCheckpoint [P]rimitive [C]ompact [F]ull */
.Overload< CCheckpoint (*)(SQInt32, SQInt32, const Vector3 &, const Color4 &, SQFloat) >
(_SC("CreateCheckpoint_PCF"), &CreateCheckpoint_PCF)
.Overload< CCheckpoint (*)(SQInt32, SQInt32, const Vector3 &, const Color4 &, SQFloat, SQInt32, SqObj &) >
(_SC("CreateCheckpoint_PCF"), &CreateCheckpoint_PCF)
/* Create CCheckpoint [E]xtended [F]Full */
.Overload< CCheckpoint (*)(const Reference< CPlayer > &, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, Uint8, SQFloat) >
(_SC("CreateCheckpoint_EF"), &CreateCheckpoint_EF)
.Overload< CCheckpoint (*)(const Reference< CPlayer > &, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, Uint8, SQFloat, SQInt32, SqObj &) >
(_SC("CreateCheckpoint_EF"), &CreateCheckpoint_EF)
/* Create CCheckpoint [C]ompact [F]ull */
.Overload< CCheckpoint (*)(const Reference< CPlayer > &, SQInt32, const Vector3 &, const Color4 &, SQFloat) >
(_SC("CreateCheckpoint_CF"), &CreateCheckpoint_CF)
.Overload< CCheckpoint (*)(const Reference< CPlayer > &, SQInt32, const Vector3 &, const Color4 &, SQFloat, SQInt32, SqObj &) >
(_SC("CreateCheckpoint_CF"), &CreateCheckpoint_CF);
// Output debugging information
LogDbg("Registration of <Checkpoint> functions was successful");
// Registration succeeded
return true;
RootTable(vm)
.Overload< Object & (*)(CPlayer &, Int32, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32) >
(_SC("CreateCheckpointEx"), &CreateCheckpointEx)
.Overload< Object & (*)(CPlayer &, Int32, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32, Int32, Object &) >
(_SC("CreateCheckpointEx"), &CreateCheckpointEx)
.Overload< Object & (*)(CPlayer &, Int32, const Vector3 &, const Color4 &, Float32) >
(_SC("CreateCheckpoint"), &CreateCheckpoint)
.Overload< Object & (*)(CPlayer &, Int32, const Vector3 &, const Color4 &, Float32, Int32, Object &) >
(_SC("CreateCheckpoint"), &CreateCheckpoint);
}
} // Namespace:: SqMod
} // Namespace:: SqMod

View File

@ -2,99 +2,164 @@
#define _ENTITY_CHECKPOINT_HPP_
// ------------------------------------------------------------------------------------------------
#include "Entity.hpp"
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Class responsible for managing the referenced checkpoint instance.
* Manages Checkpoint instances.
*/
class CCheckpoint : public Reference< CCheckpoint >
class CCheckpoint
{
// --------------------------------------------------------------------------------------------
static Color4 s_Color4;
static Vector3 s_Vector3;
friend class Core;
private:
// --------------------------------------------------------------------------------------------
static SQUint32 s_ColorR, s_ColorG, s_ColorB, s_ColorA;
static Color4 s_Color4;
static Vector3 s_Vector3;
// --------------------------------------------------------------------------------------------
static Uint32 s_ColorR, s_ColorG, s_ColorB, s_ColorA;
/* --------------------------------------------------------------------------------------------
* Cached identifiers for fast integer to string conversion.
*/
static SQChar s_StrID[SQMOD_CHECKPOINT_POOL][8];
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
*/
Int32 m_ID;
/* --------------------------------------------------------------------------------------------
* User tag and data associated with this instance.
*/
String m_Tag;
Object m_Data;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CCheckpoint(Int32 id);
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
CCheckpoint(const CCheckpoint &);
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
CCheckpoint & operator = (const CCheckpoint &);
public:
/* --------------------------------------------------------------------------------------------
* Import the constructors, destructors and assignment operators from the base class.
*/
using RefType::Reference;
// --------------------------------------------------------------------------------------------
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* Construct a reference from a base reference.
* Destructor.
*/
CCheckpoint(const Reference< CCheckpoint > & o);
~CCheckpoint();
/* --------------------------------------------------------------------------------------------
* See if the referenced checkpoint instance is streamed for the specified player.
* See whether this instance manages a valid entity.
*/
bool IsStreamedFor(const Reference< CPlayer > & player) const;
bool Validate() const
{
if (VALID_ENTITY(m_ID))
return true;
SqThrow("Invalid checkpoint reference [%s]", m_Tag.c_str());
return false;
}
/* --------------------------------------------------------------------------------------------
* Retrieve the world in which the referenced checkpoint instance exists.
* Used by the script engine to compare two instances of this type.
*/
SQInt32 GetWorld() const;
Int32 Cmp(const CCheckpoint & o) const;
/* --------------------------------------------------------------------------------------------
* Change the world in which the referenced checkpoint instance exists.
* Used by the script engine to convert an instance of this type to a string.
*/
void SetWorld(SQInt32 world) const;
CSStr ToString() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the color of the referenced checkpoint instance.
* Retrieve the identifier of the entity managed by this instance.
*/
Int32 GetID() const { return m_ID; }
/* --------------------------------------------------------------------------------------------
* Retrieve the maximum possible identifier to an entity of this type.
*/
Int32 GetMaxID() const { return SQMOD_CHECKPOINT_POOL; }
/* --------------------------------------------------------------------------------------------
* Check whether this instance manages a valid entity.
*/
bool IsActive() const { return VALID_ENTITY(m_ID); }
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user tag.
*/
CSStr 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);
// --------------------------------------------------------------------------------------------
bool Destroy(Int32 header, Object & payload);
bool Destroy() { return Destroy(0, NullObject()); }
bool Destroy(Int32 header) { return Destroy(header, NullObject()); }
// --------------------------------------------------------------------------------------------
bool BindEvent(Int32 evid, Object & env, Function & func) const;
// --------------------------------------------------------------------------------------------
bool IsStreamedFor(CPlayer & player) const;
Int32 GetWorld() const;
void SetWorld(Int32 world) const;
const Color4 & GetColor() const;
/* --------------------------------------------------------------------------------------------
* Change the color of the referenced checkpoint instance.
*/
void SetColor(const Color4 & col) const;
/* --------------------------------------------------------------------------------------------
* Change the color of the referenced checkpoint instance.
*/
void SetColorEx(Uint8 r, Uint8 g, Uint8 b, Uint8 a) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position of the referenced checkpoint instance.
*/
const Vector3 & GetPosition() const;
/* --------------------------------------------------------------------------------------------
* Change the position of the referenced checkpoint instance.
*/
void SetPosition(const Vector3 & pos) const;
void SetPositionEx(Float32 x, Float32 y, Float32 z) const;
Float32 GetRadius() const;
void SetRadius(Float32 radius) const;
Object & GetOwner() const;
Int32 GetOwnerID() const;
/* --------------------------------------------------------------------------------------------
* Change the position of the referenced checkpoint instance.
*/
void SetPositionEx(SQFloat x, SQFloat y, SQFloat z) const;
// --------------------------------------------------------------------------------------------
Float32 GetPosX() const;
Float32 GetPosY() const;
Float32 GetPosZ() const;
void SetPosX(Float32 x) const;
void SetPosY(Float32 y) const;
void SetPosZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the radius of the referenced checkpoint instance.
*/
SQFloat GetRadius() const;
/* --------------------------------------------------------------------------------------------
* Change the radius of the referenced checkpoint instance.
*/
void SetRadius(SQFloat radius) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the owner of the referenced checkpoint instance.
*/
Reference< CPlayer > GetOwner() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the owner identifier of the referenced checkpoint instance.
*/
SQInt32 GetOwnerID() const;
// --------------------------------------------------------------------------------------------
Uint32 GetColR() const;
Uint32 GetColG() const;
Uint32 GetColB() const;
Uint32 GetColA() const;
void SetColR(Uint32 r) const;
void SetColG(Uint32 g) const;
void SetColB(Uint32 b) const;
void SetColA(Uint32 a) const;
};
} // Namespace:: SqMod

View File

@ -0,0 +1,383 @@
// ------------------------------------------------------------------------------------------------
#include "Entity/Forcefield.hpp"
#include "Entity/Player.hpp"
#include "Base/Color3.hpp"
#include "Base/Vector3.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;
// ------------------------------------------------------------------------------------------------
SQChar CForcefield::s_StrID[SQMOD_FORCEFIELD_POOL][8];
// ------------------------------------------------------------------------------------------------
const Int32 CForcefield::Max = SQMOD_FORCEFIELD_POOL;
// ------------------------------------------------------------------------------------------------
CForcefield::CForcefield(Int32 id)
: m_ID(VALID_ENTITYGETEX(id, SQMOD_FORCEFIELD_POOL))
, m_Tag(VALID_ENTITY(m_ID) ? s_StrID[m_ID] : _SC("-1"))
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
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;
}
CSStr CForcefield::ToString() const
{
return VALID_ENTITYEX(m_ID, SQMOD_FORCEFIELD_POOL) ? s_StrID[m_ID] : _SC("-1");
}
// ------------------------------------------------------------------------------------------------
CSStr CForcefield::GetTag() const
{
return m_Tag.c_str();
}
void CForcefield::SetTag(CSStr tag)
{
m_Tag.assign(tag);
}
Object & CForcefield::GetData()
{
if (Validate())
return m_Data;
return NullObject();
}
void CForcefield::SetData(Object & data)
{
if (Validate())
m_Data = data;
}
// ------------------------------------------------------------------------------------------------
bool CForcefield::Destroy(Int32 header, Object & payload)
{
return _Core->DelForcefield(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
bool CForcefield::BindEvent(Int32 evid, Object & env, Function & func) const
{
if (!Validate())
return false;
Function & event = _Core->GetForcefieldEvent(m_ID, evid);
if (func.IsNull())
event.Release();
else
event = Function(env.GetVM(), env, func.GetFunc());
return true;
}
// ------------------------------------------------------------------------------------------------
bool CForcefield::IsStreamedFor(CPlayer & player) const
{
if (!player.IsActive())
SqThrow("Invalid player argument: null");
else if (Validate())
return _Func->IsSphereStreamedForPlayer(m_ID, player.GetID());
return false;
}
Int32 CForcefield::GetWorld() const
{
if (Validate())
return _Func->GetSphereWorld(m_ID);
return -1;
}
void CForcefield::SetWorld(Int32 world) const
{
if (Validate())
_Func->SetSphereWorld(m_ID, world);
}
const Color3 & CForcefield::GetColor() const
{
s_Color3.Clear();
if (Validate())
{
_Func->GetSphereColor(m_ID, &s_ColorR, &s_ColorG, &s_ColorB);
s_Color3.Set(s_ColorR, s_ColorG, s_ColorB);
}
return s_Color3;
}
void CForcefield::SetColor(const Color3 & col) const
{
if (Validate())
_Func->SetSphereColor(m_ID, col.r, col.g, col.b);
}
void CForcefield::SetColorEx(Uint8 r, Uint8 g, Uint8 b) const
{
if (Validate())
_Func->SetSphereColor(m_ID, r, g, b);
}
const Vector3 & CForcefield::GetPosition() const
{
s_Vector3.Clear();
if (Validate())
_Func->GetSpherePos(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z);
return s_Vector3;
}
void CForcefield::SetPosition(const Vector3 & pos) const
{
if (Validate())
_Func->SetSpherePos(m_ID, pos.x, pos.y, pos.z);
}
void CForcefield::SetPositionEx(Float32 x, Float32 y, Float32 z) const
{
if (Validate())
_Func->SetSpherePos(m_ID, x, y, z);
}
Float32 CForcefield::GetRadius() const
{
if (Validate())
_Func->GetSphereRadius(m_ID);
return 0;
}
void CForcefield::SetRadius(Float32 radius) const
{
if (Validate())
_Func->SetSphereRadius(m_ID, radius);
}
Object & CForcefield::GetOwner() const
{
if (Validate())
return _Core->GetPlayer(_Func->GetSphereOwner(m_ID)).mObj;
return NullObject();
}
Int32 CForcefield::GetOwnerID() const
{
if (Validate())
_Func->GetSphereOwner(m_ID);
return -1;
}
// ------------------------------------------------------------------------------------------------
Float32 CForcefield::GetPosX() const
{
s_Vector3.x = 0;
if (Validate())
_Func->GetSpherePos(m_ID, &s_Vector3.x, NULL, NULL);
return s_Vector3.x;
}
Float32 CForcefield::GetPosY() const
{
s_Vector3.y = 0;
if (Validate())
_Func->GetSpherePos(m_ID, NULL, &s_Vector3.y, NULL);
return s_Vector3.y;
}
Float32 CForcefield::GetPosZ() const
{
s_Vector3.z = 0;
if (Validate())
_Func->GetSpherePos(m_ID, NULL, NULL, &s_Vector3.z);
return s_Vector3.z;
}
// ------------------------------------------------------------------------------------------------
void CForcefield::SetPosX(Float32 x) const
{
if (Validate())
{
_Func->GetSpherePos(m_ID, NULL, &s_Vector3.y, &s_Vector3.z);
_Func->SetSpherePos(m_ID, x, s_Vector3.y, s_Vector3.z);
}
}
void CForcefield::SetPosY(Float32 y) const
{
if (Validate())
{
_Func->GetSpherePos(m_ID, &s_Vector3.x, NULL, &s_Vector3.z);
_Func->SetSpherePos(m_ID, s_Vector3.x, y, s_Vector3.z);
}
}
void CForcefield::SetPosZ(Float32 z) const
{
if (Validate())
{
_Func->GetSpherePos(m_ID, &s_Vector3.x, &s_Vector3.y, NULL);
_Func->SetSpherePos(m_ID, s_Vector3.z, s_Vector3.y, z);
}
}
// ------------------------------------------------------------------------------------------------
Uint32 CForcefield::GetColR() const
{
s_ColorR = 0;
if (Validate())
_Func->GetSphereColor(m_ID, &s_ColorR, NULL, NULL);
return s_ColorR;
}
Uint32 CForcefield::GetColG() const
{
s_ColorG = 0;
if (Validate())
_Func->GetSphereColor(m_ID, NULL, &s_ColorG, NULL);
return s_ColorG;
}
Uint32 CForcefield::GetColB() const
{
s_ColorB = 0;
if (Validate())
_Func->GetSphereColor(m_ID, NULL, NULL, &s_ColorB);
return s_ColorB;
}
// ------------------------------------------------------------------------------------------------
void CForcefield::SetColR(Uint32 r) const
{
if (Validate())
{
_Func->GetSphereColor(m_ID, NULL, &s_ColorG, &s_ColorB);
_Func->SetSphereColor(m_ID, r, s_ColorG, s_ColorB);
}
}
void CForcefield::SetColG(Uint32 g) const
{
if (Validate())
{
_Func->GetSphereColor(m_ID, &s_ColorR, NULL, &s_ColorB);
_Func->SetSphereColor(m_ID, s_ColorR, g, s_ColorB);
}
}
void CForcefield::SetColB(Uint32 b) const
{
if (Validate())
{
_Func->GetSphereColor(m_ID, &s_ColorB, &s_ColorG, NULL);
_Func->SetSphereColor(m_ID, s_ColorB, s_ColorG, b);
}
}
// ------------------------------------------------------------------------------------------------
static Object & CreateForcefieldEx(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 & CreateForcefieldEx(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 & CreateForcefield(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 & CreateForcefield(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);
}
// ================================================================================================
void Register_CForcefield(HSQUIRRELVM vm)
{
RootTable(vm).Bind(_SC("SqForcefield"),
Class< CForcefield, NoConstructor< CForcefield > >(vm, _SC("SqForcefield"))
/* Metamethods */
.Func(_SC("_cmp"), &CForcefield::Cmp)
.Func(_SC("_tostring"), &CForcefield::ToString)
/* Core Properties */
.Prop(_SC("ID"), &CForcefield::GetID)
.Prop(_SC("Tag"), &CForcefield::GetTag, &CForcefield::SetTag)
.Prop(_SC("Data"), &CForcefield::GetData, &CForcefield::SetData)
.Prop(_SC("MaxID"), &CForcefield::GetMaxID)
.Prop(_SC("Active"), &CForcefield::IsActive)
/* Core Functions */
.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)
/* Functions */
.Func(_SC("StreamedFor"), &CForcefield::IsStreamedFor)
.Func(_SC("SetColor"), &CForcefield::SetColorEx)
.Func(_SC("SetPos"), &CForcefield::SetPositionEx)
.Func(_SC("SetPosition"), &CForcefield::SetPositionEx)
);
RootTable(vm)
.Overload< Object & (*)(CPlayer &, Int32, Float32, Float32, Float32, Uint8, Uint8, Uint8, Float32) >
(_SC("CreateForcefieldEx"), &CreateForcefieldEx)
.Overload< Object & (*)(CPlayer &, Int32, Float32, Float32, Float32, Uint8, Uint8, Uint8, Float32, Int32, Object &) >
(_SC("CreateForcefieldEx"), &CreateForcefieldEx)
.Overload< Object & (*)(CPlayer &, Int32, const Vector3 &, const Color3 &, Float32) >
(_SC("CreateForcefield"), &CreateForcefield)
.Overload< Object & (*)(CPlayer &, Int32, const Vector3 &, const Color3 &, Float32, Int32, Object &) >
(_SC("CreateForcefield"), &CreateForcefield);
}
} // Namespace:: SqMod

View File

@ -0,0 +1,166 @@
#ifndef _ENTITY_FORCEFIELD_HPP_
#define _ENTITY_FORCEFIELD_HPP_
// ------------------------------------------------------------------------------------------------
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Manages Forcefield instances.
*/
class CForcefield
{
// --------------------------------------------------------------------------------------------
friend class Core;
private:
// --------------------------------------------------------------------------------------------
static Color3 s_Color3;
static Vector3 s_Vector3;
// --------------------------------------------------------------------------------------------
static Uint32 s_ColorR, s_ColorG, s_ColorB;
/* --------------------------------------------------------------------------------------------
* Cached identifiers for fast integer to string conversion.
*/
static SQChar s_StrID[SQMOD_FORCEFIELD_POOL][8];
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
*/
Int32 m_ID;
/* --------------------------------------------------------------------------------------------
* User tag and data associated with this instance.
*/
String m_Tag;
Object m_Data;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CForcefield(Int32 id);
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
CForcefield(const CForcefield &);
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
CForcefield & operator = (const CForcefield &);
public:
// --------------------------------------------------------------------------------------------
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~CForcefield();
/* --------------------------------------------------------------------------------------------
* See whether this instance manages a valid entity.
*/
bool Validate() const
{
if (VALID_ENTITY(m_ID))
return true;
SqThrow("Invalid forcefield reference [%s]", m_Tag.c_str());
return false;
}
/* --------------------------------------------------------------------------------------------
* 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.
*/
CSStr ToString() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the identifier of the entity managed by this instance.
*/
Int32 GetID() const { return m_ID; }
/* --------------------------------------------------------------------------------------------
* Retrieve the maximum possible identifier to an entity of this type.
*/
Int32 GetMaxID() const { return SQMOD_FORCEFIELD_POOL; }
/* --------------------------------------------------------------------------------------------
* Check whether this instance manages a valid entity.
*/
bool IsActive() const { return VALID_ENTITY(m_ID); }
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user tag.
*/
CSStr 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);
// --------------------------------------------------------------------------------------------
bool Destroy(Int32 header, Object & payload);
bool Destroy() { return Destroy(0, NullObject()); }
bool Destroy(Int32 header) { return Destroy(header, NullObject()); }
// --------------------------------------------------------------------------------------------
bool BindEvent(Int32 evid, Object & env, Function & func) const;
// --------------------------------------------------------------------------------------------
bool IsStreamedFor(CPlayer & player) const;
Int32 GetWorld() const;
void SetWorld(Int32 world) const;
const Color3 & GetColor() const;
void SetColor(const Color3 & col) const;
void SetColorEx(Uint8 r, Uint8 g, Uint8 b) const;
const Vector3 & GetPosition() const;
void SetPosition(const Vector3 & pos) const;
void SetPositionEx(Float32 x, Float32 y, Float32 z) const;
Float32 GetRadius() const;
void SetRadius(Float32 radius) const;
Object & GetOwner() const;
Int32 GetOwnerID() const;
// --------------------------------------------------------------------------------------------
Float32 GetPosX() const;
Float32 GetPosY() const;
Float32 GetPosZ() const;
void SetPosX(Float32 x) const;
void SetPosY(Float32 y) const;
void SetPosZ(Float32 z) const;
// --------------------------------------------------------------------------------------------
Uint32 GetColR() const;
Uint32 GetColG() const;
Uint32 GetColB() const;
void SetColR(Uint32 r) const;
void SetColG(Uint32 g) const;
void SetColB(Uint32 b) const;
};
} // Namespace:: SqMod
#endif // _ENTITY_FORCEFIELD_HPP_

View File

@ -1,197 +1,184 @@
// ------------------------------------------------------------------------------------------------
#include "Entity/Keybind.hpp"
#include "Core.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
CKeybind::CKeybind(const Reference< CKeybind > & o)
: Reference(o)
SQChar CKeybind::s_StrID[SQMOD_KEYBIND_POOL][8];
// ------------------------------------------------------------------------------------------------
const Int32 CKeybind::Max = SQMOD_KEYBIND_POOL;
// ------------------------------------------------------------------------------------------------
CKeybind::CKeybind(Int32 id)
: m_ID(VALID_ENTITYGETEX(id, SQMOD_KEYBIND_POOL))
, m_Tag(VALID_ENTITY(m_ID) ? s_StrID[m_ID] : _SC("-1"))
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
SQInt32 CKeybind::GetPrimary() const
CKeybind::~CKeybind()
{
if (VALID_ENTITY(m_ID))
{
RefType::Get(m_ID).Primary;
}
else
{
BadRef("@primary", "get primary keycode");
}
return SQMOD_UNKNOWN;
/* ... */
}
// ------------------------------------------------------------------------------------------------
SQInt32 CKeybind::GetSecondary() const
Int32 CKeybind::Cmp(const CKeybind & o) const
{
if (VALID_ENTITY(m_ID))
{
RefType::Get(m_ID).Secondary;
}
if (m_ID == o.m_ID)
return 0;
else if (m_ID > o.m_ID)
return 1;
else
{
BadRef("@secondary", "get secondary keycode");
}
return -1;
}
return SQMOD_UNKNOWN;
CSStr CKeybind::ToString() const
{
return VALID_ENTITYEX(m_ID, SQMOD_KEYBIND_POOL) ? s_StrID[m_ID] : _SC("-1");
}
// ------------------------------------------------------------------------------------------------
SQInt32 CKeybind::GetAlternative() const
CSStr CKeybind::GetTag() const
{
if (VALID_ENTITY(m_ID))
{
RefType::Get(m_ID).Alternative;
}
else
{
BadRef("@alternative", "get alternative keycode");
}
return m_Tag.c_str();
}
return SQMOD_UNKNOWN;
void CKeybind::SetTag(CSStr tag)
{
m_Tag.assign(tag);
}
Object & CKeybind::GetData()
{
if (Validate())
return m_Data;
return NullObject();
}
void CKeybind::SetData(Object & data)
{
if (Validate())
m_Data = data;
}
// ------------------------------------------------------------------------------------------------
bool CKeybind::Destroy(Int32 header, Object & payload)
{
return _Core->DelKeybind(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
bool CKeybind::BindEvent(Int32 evid, Object & env, Function & func) const
{
if (!Validate())
return false;
Function & event = _Core->GetKeybindEvent(m_ID, evid);
if (func.IsNull())
event.Release();
else
event = Function(env.GetVM(), env, func.GetFunc());
return true;
}
// ------------------------------------------------------------------------------------------------
Int32 CKeybind::GetPrimary() const
{
if (Validate())
return _Core->GetKeybind(m_ID).mPrimary;
return -1;
}
Int32 CKeybind::GetSecondary() const
{
if (Validate())
return _Core->GetKeybind(m_ID).mSecondary;
return -1;
}
Int32 CKeybind::GetAlternative() const
{
if (Validate())
return _Core->GetKeybind(m_ID).mAlternative;
return -1;
}
bool CKeybind::IsRelease() const
{
if (VALID_ENTITY(m_ID))
{
RefType::Get(m_ID).Release;
}
else
{
BadRef("@is_release", "see whether it reacts on release");
}
if (Validate())
return _Core->GetKeybind(m_ID).mRelease;
return false;
}
// ------------------------------------------------------------------------------------------------
Reference< CKeybind > CreateBaseKeybind_ES(bool release,
SQInt32 primary, SQInt32 secondary, SQInt32 alternative)
static Object & CreateKeybindEx(Int32 slot, bool release, Int32 primary, Int32 secondary,
Int32 alternative)
{
return _Core->NewKeybind(SQMOD_UNKNOWN, release, primary, secondary, alternative,
SQMOD_CREATE_DEFAULT, NullData());
return _Core->NewKeybind(slot, release, primary, secondary, alternative,
SQMOD_CREATE_DEFAULT, NullObject());
}
Reference< CKeybind > CreateBaseKeybind_ES(bool release,
SQInt32 primary, SQInt32 secondary, SQInt32 alternative,
SQInt32 header, SqObj & payload)
static Object & CreateKeybindEx(Int32 slot, bool release, Int32 primary, Int32 secondary,
Int32 alternative, Int32 header, Object & payload)
{
return _Core->NewKeybind(SQMOD_UNKNOWN, release, primary, secondary, alternative,
header, payload);
return _Core->NewKeybind(slot, release, primary, secondary, alternative, header, payload);
}
// ------------------------------------------------------------------------------------------------
Reference< CKeybind > CreateBaseKeybind_EF(SQInt32 slot, bool release,
SQInt32 primary, SQInt32 secondary, SQInt32 alternative)
static Object & CreateKeybind(bool release, Int32 primary, Int32 secondary, Int32 alternative)
{
return _Core->NewKeybind(slot, release, primary, secondary, alternative,
SQMOD_CREATE_DEFAULT, NullData());
return _Core->NewKeybind(-1, release, primary, secondary, alternative,
SQMOD_CREATE_DEFAULT, NullObject());
}
Reference< CKeybind > CreateBaseKeybind_EF(SQInt32 slot, bool release,
SQInt32 primary, SQInt32 secondary, SQInt32 alternative,
SQInt32 header, SqObj & payload)
static Object & CreateKeybind(bool release, Int32 primary, Int32 secondary, Int32 alternative,
Int32 header, Object & payload)
{
return _Core->NewKeybind(slot, release, primary, secondary, alternative,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CKeybind CreateKeybind_ES(bool release,
SQInt32 primary, SQInt32 secondary, SQInt32 alternative)
{
return _Core->NewKeybind(SQMOD_UNKNOWN, release, primary, secondary, alternative,
SQMOD_CREATE_DEFAULT, NullData());
}
CKeybind CreateKeybind_ES(bool release,
SQInt32 primary, SQInt32 secondary, SQInt32 alternative,
SQInt32 header, SqObj & payload)
{
return _Core->NewKeybind(SQMOD_UNKNOWN, release, primary, secondary, alternative,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CKeybind CreateKeybind_EF(SQInt32 slot, bool release,
SQInt32 primary, SQInt32 secondary, SQInt32 alternative)
{
return _Core->NewKeybind(slot, release, primary, secondary, alternative,
SQMOD_CREATE_DEFAULT, NullData());
}
CKeybind CreateKeybind_EF(SQInt32 slot, bool release,
SQInt32 primary, SQInt32 secondary, SQInt32 alternative,
SQInt32 header, SqObj & payload)
{
return _Core->NewKeybind(slot, release, primary, secondary, alternative,
header, payload);
return _Core->NewKeybind(-1, release, primary, secondary, alternative, header, payload);
}
// ================================================================================================
bool Register_CKeybind(HSQUIRRELVM vm)
void Register_CKeybind(HSQUIRRELVM vm)
{
// Attempt to register the base reference type before the actual implementation
if (!Register_Reference< CKeybind >(vm, _SC("BaseKeybind")))
{
LogFtl("Unable to register the base class <BaseKeybind> for <CKeybind> type");
// Registration failed
return false;
}
// Typedef the base reference type for simplicity
typedef Reference< CKeybind > RefType;
// Output debugging information
LogDbg("Beginning registration of <CKeybind> type");
// Attempt to register the actual reference that implements all of the entity functionality
Sqrat::RootTable(vm).Bind(_SC("CKeybind"), Sqrat::DerivedClass< CKeybind, RefType >(vm, _SC("CKeybind"))
/* Constructors */
.Ctor()
.Ctor< SQInt32 >()
RootTable(vm).Bind(_SC("SqKeybind"),
Class< CKeybind, NoConstructor< CKeybind > >(vm, _SC("SqKeybind"))
/* Metamethods */
.Func(_SC("_cmp"), &CKeybind::Cmp)
.Func(_SC("_tostring"), &CKeybind::ToString)
/* Core Properties */
.Prop(_SC("ID"), &CKeybind::GetID)
.Prop(_SC("Tag"), &CKeybind::GetTag, &CKeybind::SetTag)
.Prop(_SC("Data"), &CKeybind::GetData, &CKeybind::SetData)
.Prop(_SC("MaxID"), &CKeybind::GetMaxID)
.Prop(_SC("Active"), &CKeybind::IsActive)
/* Core Functions */
.Func(_SC("Bind"), &CKeybind::BindEvent)
/* Core Overloads */
.Overload< bool (CKeybind::*)(void) >(_SC("Destroy"), &CKeybind::Destroy)
.Overload< bool (CKeybind::*)(Int32) >(_SC("Destroy"), &CKeybind::Destroy)
.Overload< bool (CKeybind::*)(Int32, Object &) >(_SC("Destroy"), &CKeybind::Destroy)
/* Properties */
.Prop(_SC("primary"), &CKeybind::GetPrimary)
.Prop(_SC("secondary"), &CKeybind::GetSecondary)
.Prop(_SC("alternative"), &CKeybind::GetAlternative)
.Prop(_SC("is_release"), &CKeybind::IsRelease)
.Prop(_SC("Primary"), &CKeybind::GetPrimary)
.Prop(_SC("Secondary"), &CKeybind::GetSecondary)
.Prop(_SC("Alternative"), &CKeybind::GetAlternative)
.Prop(_SC("Release"), &CKeybind::IsRelease)
);
// Output debugging information
LogDbg("Registration of <CKeybind> type was successful");
// Output debugging information
LogDbg("Beginning registration of <Keybind> functions");
// Register global functions related to this entity type
Sqrat::RootTable(vm)
/* Create BaseKeybind [E]xtended [S]ubstitute */
.Overload< RefType (*)(bool, SQInt32, SQInt32, SQInt32) >
(_SC("CreateBaseKeybind_ES"), &CreateBaseKeybind_ES)
.Overload< RefType (*)(bool, SQInt32, SQInt32, SQInt32, SQInt32, SqObj &) >
(_SC("CreateBaseKeybind_ES"), &CreateBaseKeybind_ES)
/* Create BaseKeybind [E]xtended [F]Full */
.Overload< RefType (*)(SQInt32, bool, SQInt32, SQInt32, SQInt32) >
(_SC("CreateBaseKeybind_EF"), &CreateBaseKeybind_EF)
.Overload< RefType (*)(SQInt32, bool, SQInt32, SQInt32, SQInt32, SQInt32, SqObj &) >
(_SC("CreateBaseKeybind_EF"), &CreateBaseKeybind_EF)
/* Create CKeybind [E]xtended [S]ubstitute */
.Overload< CKeybind (*)(bool, SQInt32, SQInt32, SQInt32) >
(_SC("CreateKeybind_ES"), &CreateKeybind_ES)
.Overload< CKeybind (*)(bool, SQInt32, SQInt32, SQInt32, SQInt32, SqObj &) >
(_SC("CreateKeybind_ES"), &CreateKeybind_ES)
/* Create CKeybind [E]xtended [F]Full */
.Overload< CKeybind (*)(SQInt32, bool, SQInt32, SQInt32, SQInt32) >
(_SC("CreateKeybind_EF"), &CreateKeybind_EF)
.Overload< CKeybind (*)(SQInt32, bool, SQInt32, SQInt32, SQInt32, SQInt32, SqObj &) >
(_SC("CreateKeybind_EF"), &CreateKeybind_EF);
// Output debugging information
LogDbg("Registration of <Keybind> functions was successful");
// Registration succeeded
return true;
RootTable(vm)
.Overload< Object & (*)(Int32, bool, Int32, Int32, Int32) >
(_SC("CreateKeybindEx"), &CreateKeybindEx)
.Overload< Object & (*)(Int32, bool, Int32, Int32, Int32, Int32, Object &) >
(_SC("CreateKeybindEx"), &CreateKeybindEx)
.Overload< Object & (*)(bool, Int32, Int32, Int32) >
(_SC("CreateKeybind"), &CreateKeybind)
.Overload< Object & (*)(bool, Int32, Int32, Int32, Int32, Object &) >
(_SC("CreateKeybind"), &CreateKeybind);
}
} // Namespace:: SqMod
} // Namespace:: SqMod

View File

@ -2,46 +2,130 @@
#define _ENTITY_KEYBIND_HPP_
// ------------------------------------------------------------------------------------------------
#include "Entity.hpp"
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Class responsible for managing the referenced keybind instance.
* Manages Keybind instances.
*/
class CKeybind : public Reference< CKeybind >
class CKeybind
{
// --------------------------------------------------------------------------------------------
friend class Core;
private:
/* --------------------------------------------------------------------------------------------
* Cached identifiers for fast integer to string conversion.
*/
static SQChar s_StrID[SQMOD_KEYBIND_POOL][8];
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
*/
Int32 m_ID;
/* --------------------------------------------------------------------------------------------
* User tag and data associated with this instance.
*/
String m_Tag;
Object m_Data;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CKeybind(Int32 id);
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
CKeybind(const CKeybind &);
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
CKeybind & operator = (const CKeybind &);
public:
/* --------------------------------------------------------------------------------------------
* Import the constructors, destructors and assignment operators from the base class.
*/
using RefType::Reference;
// --------------------------------------------------------------------------------------------
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* Construct a reference from a base reference.
* Destructor.
*/
CKeybind(const Reference< CKeybind > & o);
~CKeybind();
/* --------------------------------------------------------------------------------------------
* Retrieve the primary key code of the referenced keybind instance.
* See whether this instance manages a valid entity.
*/
SQInt32 GetPrimary() const;
bool Validate() const
{
if (VALID_ENTITY(m_ID))
return true;
SqThrow("Invalid keybind reference [%s]", m_Tag.c_str());
return false;
}
/* --------------------------------------------------------------------------------------------
* Retrieve the secondary key code of the referenced keybind instance.
* Used by the script engine to compare two instances of this type.
*/
SQInt32 GetSecondary() const;
Int32 Cmp(const CKeybind & o) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the alternative key code of the referenced keybind instance.
* Used by the script engine to convert an instance of this type to a string.
*/
SQInt32 GetAlternative() const;
CSStr ToString() const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced keybind instance reacts to key press events.
* Retrieve the identifier of the entity managed by this instance.
*/
Int32 GetID() const { return m_ID; }
/* --------------------------------------------------------------------------------------------
* Retrieve the maximum possible identifier to an entity of this type.
*/
Int32 GetMaxID() const { return SQMOD_KEYBIND_POOL; }
/* --------------------------------------------------------------------------------------------
* Check whether this instance manages a valid entity.
*/
bool IsActive() const { return VALID_ENTITY(m_ID); }
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user tag.
*/
CSStr 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);
// --------------------------------------------------------------------------------------------
bool Destroy(Int32 header, Object & payload);
bool Destroy() { return Destroy(0, NullObject()); }
bool Destroy(Int32 header) { return Destroy(header, NullObject()); }
// --------------------------------------------------------------------------------------------
bool BindEvent(Int32 evid, Object & env, Function & func) const;
// --------------------------------------------------------------------------------------------
Int32 GetPrimary() const;
Int32 GetSecondary() const;
Int32 GetAlternative() const;
bool IsRelease() const;
};

File diff suppressed because it is too large Load Diff

View File

@ -2,239 +2,176 @@
#define _ENTITY_OBJECT_HPP_
// ------------------------------------------------------------------------------------------------
#include "Entity.hpp"
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Class responsible for managing the referenced object instance.
* Manages Object instances.
*/
class CObject : public Reference< CObject >
class CObject
{
// --------------------------------------------------------------------------------------------
static CModel s_Model;
friend class Core;
private:
// --------------------------------------------------------------------------------------------
static Vector3 s_Vector3;
static Quaternion s_Quaternion;
/* --------------------------------------------------------------------------------------------
* Cached identifiers for fast integer to string conversion.
*/
static SQChar s_StrID[SQMOD_OBJECT_POOL][8];
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
*/
Int32 m_ID;
/* --------------------------------------------------------------------------------------------
* User tag and data associated with this instance.
*/
String m_Tag;
Object m_Data;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CObject(Int32 id);
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
CObject(const CObject &);
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
CObject & operator = (const CObject &);
public:
/* --------------------------------------------------------------------------------------------
* Import the constructors, destructors and assignment operators from the base class.
*/
using RefType::Reference;
// --------------------------------------------------------------------------------------------
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* Construct a reference from a base reference.
* Destructor.
*/
CObject(const Reference< CObject > & o);
~CObject();
/* --------------------------------------------------------------------------------------------
* See if the referenced object instance is streamed for the specified player.
* See whether this instance manages a valid entity.
*/
bool IsStreamedFor(const Reference< CPlayer > & player) const;
bool Validate() const
{
if (VALID_ENTITY(m_ID))
return true;
SqThrow("Invalid object reference [%s]", m_Tag.c_str());
return false;
}
/* --------------------------------------------------------------------------------------------
* Retrieve the model of the referenced object instance.
* Used by the script engine to compare two instances of this type.
*/
const CModel & GetModel() const;
Int32 Cmp(const CObject & o) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the model identifier of the referenced object instance.
* Used by the script engine to convert an instance of this type to a string.
*/
SQInt32 GetModelID() const;
CSStr ToString() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the world in which the referenced object instance exists.
* Retrieve the identifier of the entity managed by this instance.
*/
SQInt32 GetWorld() const;
Int32 GetID() const { return m_ID; }
/* --------------------------------------------------------------------------------------------
* Change the world in which the referenced object instance exists.
* Retrieve the maximum possible identifier to an entity of this type.
*/
void SetWorld(SQInt32 world) const;
Int32 GetMaxID() const { return SQMOD_OBJECT_POOL; }
/* --------------------------------------------------------------------------------------------
* Retrieve the alpha of the referenced object instance.
* Check whether this instance manages a valid entity.
*/
SQInt32 GetAlpha() const;
bool IsActive() const { return VALID_ENTITY(m_ID); }
/* --------------------------------------------------------------------------------------------
* Change the alpha of the referenced object instance.
* Retrieve the associated user tag.
*/
void SetAlpha(SQInt32 alpha) const;
CSStr GetTag() const;
/* --------------------------------------------------------------------------------------------
* Change the alpha of the referenced object instance over the specified time.
* Modify the associated user tag.
*/
void SetAlphaEx(SQInt32 alpha, SQInt32 time) const;
void SetTag(CSStr tag);
/* --------------------------------------------------------------------------------------------
* Move the referenced object instance to the specified position instantly.
* Retrieve the associated user data.
*/
void MoveToPr(const Vector3 & pos) const;
Object & GetData();
/* --------------------------------------------------------------------------------------------
* Move the referenced object instance to the specified position over the specified time.
* Modify the associated user data.
*/
void MoveTo(const Vector3 & pos, SQInt32 time) const;
void SetData(Object & data);
/* --------------------------------------------------------------------------------------------
* Move the referenced object instance to the specified position instantly.
*/
void MoveToEx(SQFloat x, SQFloat y, SQFloat z) const;
// --------------------------------------------------------------------------------------------
bool Destroy(Int32 header, Object & payload);
bool Destroy() { return Destroy(0, NullObject()); }
bool Destroy(Int32 header) { return Destroy(header, NullObject()); }
/* --------------------------------------------------------------------------------------------
* Move the referenced object instance to the specified position over the specified time.
*/
void MoveToEx(SQFloat x, SQFloat y, SQFloat z, SQInt32 time) const;
// --------------------------------------------------------------------------------------------
bool BindEvent(Int32 evid, Object & env, Function & func) const;
/* --------------------------------------------------------------------------------------------
* Move the referenced object instance by the specified position instantly.
*/
void MoveByPr(const Vector3 & pos) const;
/* --------------------------------------------------------------------------------------------
* Move the referenced object instance by the specified position over the specified time.
*/
void MoveBy(const Vector3 & pos, SQInt32 time) const;
/* --------------------------------------------------------------------------------------------
* Move the referenced object instance by the specified position instantly.
*/
void MoveByEx(SQFloat x, SQFloat y, SQFloat z) const;
/* --------------------------------------------------------------------------------------------
* Move the referenced object instance by the specified position over the specified time.
*/
void MoveByEx(SQFloat x, SQFloat y, SQFloat z, SQInt32 time) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position of the referenced object instance.
*/
// --------------------------------------------------------------------------------------------
bool IsStreamedFor(CPlayer & player) const;
Int32 GetModel() const;
Int32 GetWorld() const;
void SetWorld(Int32 world) const;
Int32 GetAlpha() const;
void SetAlpha(Int32 alpha) const;
void SetAlphaEx(Int32 alpha, Int32 time) const;
void MoveTo(const Vector3 & pos, Int32 time) const;
void MoveToEx(Float32 x, Float32 y, Float32 z, Int32 time) const;
void MoveBy(const Vector3 & pos, Int32 time) const;
void MoveByEx(Float32 x, Float32 y, Float32 z, Int32 time) const;
const Vector3 & GetPosition();
/* --------------------------------------------------------------------------------------------
* Change the position of the referenced object instance.
*/
void SetPosition(const Vector3 & pos) const;
/* --------------------------------------------------------------------------------------------
* Change the position of the referenced object instance.
*/
void SetPositionEx(SQFloat x, SQFloat y, SQFloat z) const;
/* --------------------------------------------------------------------------------------------
* Rotate the referenced object instance to the specified rotation instantly.
*/
void RotateToPr(const Quaternion & rot) const;
/* --------------------------------------------------------------------------------------------
* Rotate the referenced object instance to the specified rotation over the specified time.
*/
void RotateTo(const Quaternion & rot, SQInt32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the referenced object instance to the specified rotation instantly.
*/
void RotateToEx(SQFloat x, SQFloat y, SQFloat z, SQFloat w) const;
/* --------------------------------------------------------------------------------------------
* Rotate the referenced object instance to the specified rotation over the specified time.
*/
void RotateToEx(SQFloat x, SQFloat y, SQFloat z, SQFloat w, SQInt32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the referenced object instance to the specified euler rotation instantly.
*/
void RotateToEulerPr(const Vector3 & rot) const;
/* --------------------------------------------------------------------------------------------
* Rotate the referenced object instance to the specified euler rotation over the specified time.
*/
void RotateToEuler(const Vector3 & rot, SQInt32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the referenced object instance to the specified euler rotation instantly.
*/
void RotateToEulerEx(SQFloat x, SQFloat y, SQFloat z) const;
/* --------------------------------------------------------------------------------------------
* Rotate the referenced object instance to the specified euler rotation over the specified time.
*/
void RotateToEulerEx(SQFloat x, SQFloat y, SQFloat z, SQInt32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the referenced object instance by the specified rotation instantly.
*/
void RotateByPr(const Quaternion & rot) const;
/* --------------------------------------------------------------------------------------------
* Rotate the referenced object instance by the specified rotation over the specified time.
*/
void RotateBy(const Quaternion & rot, SQInt32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the referenced object instance by the specified rotation instantly.
*/
void RotateByEx(SQFloat x, SQFloat y, SQFloat z, SQFloat w) const;
/* --------------------------------------------------------------------------------------------
* Rotate the referenced object instance by the specified rotation over the specified time.
*/
void RotateByEx(SQFloat x, SQFloat y, SQFloat z, SQFloat w, SQInt32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the referenced object instance by the specified euler rotation instantly.
*/
void RotateByEulerPr(const Vector3 & rot) const;
/* --------------------------------------------------------------------------------------------
* Rotate the referenced object instance by the specified euler rotation over the specified time.
*/
void RotateByEuler(const Vector3 & rot, SQInt32 time) const;
/* --------------------------------------------------------------------------------------------
* Rotate the referenced object instance by the specified euler rotation instantly.
*/
void RotateByEulerEx(SQFloat x, SQFloat y, SQFloat z) const;
/* --------------------------------------------------------------------------------------------
* Rotate the referenced object instance by the specified euler rotation over the specified time.
*/
void RotateByEulerEx(SQFloat x, SQFloat y, SQFloat z, SQInt32 time) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation of the referenced object instance.
*/
void SetPositionEx(Float32 x, Float32 y, Float32 z) const;
void RotateTo(const Quaternion & rot, Int32 time) const;
void RotateToEx(Float32 x, Float32 y, Float32 z, Float32 w, Int32 time) const;
void RotateToEuler(const Vector3 & rot, Int32 time) const;
void RotateToEulerEx(Float32 x, Float32 y, Float32 z, Int32 time) const;
void RotateBy(const Quaternion & rot, Int32 time) const;
void RotateByEx(Float32 x, Float32 y, Float32 z, Float32 w, Int32 time) const;
void RotateByEuler(const Vector3 & rot, Int32 time) const;
void RotateByEulerEx(Float32 x, Float32 y, Float32 z, Int32 time) const;
const Quaternion & GetRotation();
/* --------------------------------------------------------------------------------------------
* Retrieve the euler rotation of the referenced object instance.
*/
const Vector3 & GetRotationEuler();
/* --------------------------------------------------------------------------------------------
* See whether the referenced object instance reports gunshots.
*/
bool GetShotReport() const;
/* --------------------------------------------------------------------------------------------
* Set whether the referenced object instance reports gunshots.
*/
void SetShotReport(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced object instance reports player bumps.
*/
bool GetBumpReport() const;
/* --------------------------------------------------------------------------------------------
* Set whether the referenced object instance reports player bumps.
*/
void SetBumpReport(bool toggle) const;
// --------------------------------------------------------------------------------------------
Float32 GetPosX() const;
Float32 GetPosY() const;
Float32 GetPosZ() const;
void SetPosX(Float32 x) const;
void SetPosY(Float32 y) const;
void SetPosZ(Float32 z) const;
// --------------------------------------------------------------------------------------------
Float32 GetRotX() const;
Float32 GetRotY() const;
Float32 GetRotZ() const;
Float32 GetRotW() const;
Float32 GetERotX() const;
Float32 GetERotY() const;
Float32 GetERotZ() const;
};
} // Namespace:: SqMod

View File

@ -1,480 +1,332 @@
// ------------------------------------------------------------------------------------------------
#include "Entity/Pickup.hpp"
#include "Misc/Model.hpp"
#include "Entity/Player.hpp"
#include "Base/Vector3.hpp"
#include "Core.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
CModel CPickup::s_Model;
Vector3 CPickup::s_Vector3;
// ------------------------------------------------------------------------------------------------
Vector3 CPickup::s_Vector3;
SQChar CPickup::s_StrID[SQMOD_PICKUP_POOL][8];
// ------------------------------------------------------------------------------------------------
CPickup::CPickup(const Reference< CPickup > & o)
: Reference(o)
const Int32 CPickup::Max = SQMOD_PICKUP_POOL;
// ------------------------------------------------------------------------------------------------
CPickup::CPickup(Int32 id)
: m_ID(VALID_ENTITYGETEX(id, SQMOD_PICKUP_POOL))
, m_Tag(VALID_ENTITY(m_ID) ? s_StrID[m_ID] : _SC("-1"))
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
bool CPickup::IsStreamedFor(const Reference< CPlayer > & player) const
CPickup::~CPickup()
{
if (VALID_ENTITY(m_ID) && player)
{
return _Func->IsPickupStreamedForPlayer(m_ID, player);
}
else if (!player)
{
BadArg("streamed_for", "see whether is streamed for player", _SCI32(player));
}
else
{
BadRef("streamed_for", "see whether is streamed for player");
}
/* ... */
}
// ------------------------------------------------------------------------------------------------
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;
}
CSStr CPickup::ToString() const
{
return VALID_ENTITYEX(m_ID, SQMOD_PICKUP_POOL) ? s_StrID[m_ID] : _SC("-1");
}
// ------------------------------------------------------------------------------------------------
CSStr CPickup::GetTag() const
{
return m_Tag.c_str();
}
void CPickup::SetTag(CSStr tag)
{
m_Tag.assign(tag);
}
Object & CPickup::GetData()
{
if (Validate())
return m_Data;
return NullObject();
}
void CPickup::SetData(Object & data)
{
if (Validate())
m_Data = data;
}
// ------------------------------------------------------------------------------------------------
bool CPickup::Destroy(Int32 header, Object & payload)
{
return _Core->DelPickup(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
bool CPickup::BindEvent(Int32 evid, Object & env, Function & func) const
{
if (!Validate())
return false;
Function & event = _Core->GetPickupEvent(m_ID, evid);
if (func.IsNull())
event.Release();
else
event = Function(env.GetVM(), env, func.GetFunc());
return true;
}
// ------------------------------------------------------------------------------------------------
bool CPickup::IsStreamedFor(CPlayer & player) const
{
if (!player.IsActive())
SqThrow("Invalid player argument: null");
else if (Validate())
return _Func->IsPickupStreamedForPlayer(m_ID, player.GetID());
return false;
}
// ------------------------------------------------------------------------------------------------
const CModel & CPickup::GetModel() const
Int32 CPickup::GetModel() const
{
// Clear any previous model
s_Model.SetID(SQMOD_UNKNOWN);
// Attempt to retrieve the model
if (VALID_ENTITY(m_ID))
{
s_Model.SetID(_Func->PickupGetModel(m_ID));
}
else
{
BadRef("@model", "get model");
}
// Return the model that could be retrieved
return s_Model;
}
// ------------------------------------------------------------------------------------------------
SQInt32 CPickup::GetModelID() const
{
if (VALID_ENTITY(m_ID))
{
if (Validate())
return _Func->PickupGetModel(m_ID);
}
else
{
BadRef("@model", "get model id");
}
return SQMOD_UNKNOWN;
return -1;
}
// ------------------------------------------------------------------------------------------------
SQInt32 CPickup::GetWorld() const
Int32 CPickup::GetWorld() const
{
if (VALID_ENTITY(m_ID))
{
if (Validate())
return _Func->GetPickupWorld(m_ID);
}
else
{
BadRef("@world", "get world");
}
return SQMOD_UNKNOWN;
return -1;
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetWorld(SQInt32 world) const
void CPickup::SetWorld(Int32 world) const
{
if (VALID_ENTITY(m_ID))
{
if (Validate())
_Func->SetPickupWorld(m_ID, world);
}
else
{
BadRef("@world", "set world");
}
}
// ------------------------------------------------------------------------------------------------
SQInt32 CPickup::GetAlpha() const
Int32 CPickup::GetAlpha() const
{
if (VALID_ENTITY(m_ID))
{
return _Func->PickupGetAlpha(m_ID);
}
else
{
BadRef("@alpha", "get alpha");
}
return SQMOD_UNKNOWN;
if (Validate())
return _Func->GetVehicleModel(m_ID);
return -1;
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetAlpha(SQInt32 alpha) const
void CPickup::SetAlpha(Int32 alpha) const
{
if (VALID_ENTITY(m_ID))
{
if (Validate())
_Func->PickupSetAlpha(m_ID, alpha);
}
else
{
BadRef("@alpha", "set alpha");
}
}
// ------------------------------------------------------------------------------------------------
bool CPickup::GetAutomatic() const
{
if (VALID_ENTITY(m_ID))
{
if (Validate())
return _Func->PickupIsAutomatic(m_ID);
}
else
{
BadRef("@automatic", "see if is automatic");
}
return false;
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetAutomatic(bool toggle) const
{
if (VALID_ENTITY(m_ID))
{
if (Validate())
_Func->PickupSetAutomatic(m_ID, toggle);
}
else
{
BadRef("@automatic", "set whether is automatic");
}
}
// ------------------------------------------------------------------------------------------------
SQInt32 CPickup::GetAutoTimer() const
Int32 CPickup::GetAutoTimer() const
{
if (VALID_ENTITY(m_ID))
{
if (Validate())
return _Func->GetPickupAutoTimer(m_ID);
}
else
{
BadRef("@auto_timer", "get auto timer");
}
return SQMOD_UNKNOWN;
return -1;
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetAutoTimer(SQInt32 timer) const
void CPickup::SetAutoTimer(Int32 timer) const
{
if (VALID_ENTITY(m_ID))
{
if (Validate())
_Func->SetPickupAutoTimer(m_ID, timer);
}
else
{
BadRef("@auto_timer", "set auto timer");
}
}
// ------------------------------------------------------------------------------------------------
void CPickup::Refresh() const
{
if (VALID_ENTITY(m_ID))
{
if (Validate())
_Func->PickupRefresh(m_ID);
}
else
{
BadRef("refresh", "refresh pickup");
}
}
// ------------------------------------------------------------------------------------------------
const Vector3 & CPickup::GetPosition()
{
// Clear any previous position
s_Vector3.Clear();
// Attempt to retrieve the position
if (VALID_ENTITY(m_ID))
{
if (Validate())
_Func->PickupGetPos(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z);
}
else
{
BadRef("@position", "get position");
}
// Return the position that could be retrieved
return s_Vector3;
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetPosition(const Vector3 & pos) const
{
if (VALID_ENTITY(m_ID))
{
if (Validate())
_Func->PickupSetPos(m_ID, pos.x, pos.y, pos.z);
}
else
{
BadRef("@position", "set position");
}
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetPositionEx(SQFloat x, SQFloat y, SQFloat z) const
void CPickup::SetPositionEx(Float32 x, Float32 y, Float32 z) const
{
if (VALID_ENTITY(m_ID))
{
if (Validate())
_Func->PickupSetPos(m_ID, x, y, z);
}
else
{
BadRef("set_position", "set position");
}
}
// ------------------------------------------------------------------------------------------------
SQInt32 CPickup::GetQuantity() const
Int32 CPickup::GetQuantity() const
{
if (VALID_ENTITY(m_ID))
{
if (Validate())
return _Func->PickupGetQuantity(m_ID);
}
else
return -1;
}
// ------------------------------------------------------------------------------------------------
Float32 CPickup::GetPosX() const
{
s_Vector3.x = 0;
if (Validate())
_Func->PickupGetPos(m_ID, &s_Vector3.x, NULL, NULL);
return s_Vector3.x;
}
Float32 CPickup::GetPosY() const
{
s_Vector3.y = 0;
if (Validate())
_Func->PickupGetPos(m_ID, NULL, &s_Vector3.y, NULL);
return s_Vector3.y;
}
Float32 CPickup::GetPosZ() const
{
s_Vector3.z = 0;
if (Validate())
_Func->PickupGetPos(m_ID, NULL, NULL, &s_Vector3.z);
return s_Vector3.z;
}
// ------------------------------------------------------------------------------------------------
void CPickup::SetPosX(Float32 x) const
{
if (Validate())
{
BadRef("@quantity", "get quantity");
_Func->PickupGetPos(m_ID, NULL, &s_Vector3.y, &s_Vector3.z);
_Func->PickupSetPos(m_ID, x, s_Vector3.y, s_Vector3.z);
}
}
return SQMOD_UNKNOWN;
void CPickup::SetPosY(Float32 y) const
{
if (Validate())
{
_Func->PickupGetPos(m_ID, &s_Vector3.x, NULL, &s_Vector3.z);
_Func->PickupSetPos(m_ID, s_Vector3.x, y, s_Vector3.z);
}
}
void CPickup::SetPosZ(Float32 z) const
{
if (Validate())
{
_Func->PickupGetPos(m_ID, &s_Vector3.x, &s_Vector3.y, NULL);
_Func->PickupSetPos(m_ID, s_Vector3.z, s_Vector3.y, z);
}
}
// ------------------------------------------------------------------------------------------------
Reference< CPickup > CreateBasePickup_PEF(SQInt32 model, SQInt32 world, SQInt32 quantity,
SQFloat x, SQFloat y, SQFloat z,
SQInt32 alpha, bool automatic)
static Object & CreatePickupEx(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,
SQMOD_CREATE_DEFAULT, NullData());
SQMOD_CREATE_DEFAULT, NullObject());
}
Reference< CPickup > CreateBasePickup_PEF(SQInt32 model, SQInt32 world, SQInt32 quantity,
SQFloat x, SQFloat y, SQFloat z,
SQInt32 alpha, bool automatic,
SQInt32 header, SqObj & payload)
static Object & CreatePickupEx(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->NewPickup(model, world, quantity, x, y, z, alpha, automatic, header, payload);
}
// ------------------------------------------------------------------------------------------------
Reference< CPickup > CreateBasePickup_PCF(SQInt32 model, SQInt32 world, SQInt32 quantity,
const Vector3 & pos, SQInt32 alpha, bool automatic)
static Object & CreatePickup(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,
SQMOD_CREATE_DEFAULT, NullData());
SQMOD_CREATE_DEFAULT, NullObject());
}
Reference< CPickup > CreateBasePickup_PCF(SQInt32 model, SQInt32 world, SQInt32 quantity,
const Vector3 & pos, SQInt32 alpha, bool automatic,
SQInt32 header, SqObj & payload)
{
return _Core->NewPickup(model, world, quantity, pos.x, pos.y, pos.z, alpha, automatic,
header, payload);
}
// ------------------------------------------------------------------------------------------------
Reference< CPickup > CreateBasePickup_EF(const CModel & model, SQInt32 world, SQInt32 quantity,
SQFloat x, SQFloat y, SQFloat z,
SQInt32 alpha, bool automatic)
{
return _Core->NewPickup(model, world, quantity, x, y, z, alpha, automatic,
SQMOD_CREATE_DEFAULT, NullData());
}
Reference< CPickup > CreateBasePickup_EF(const CModel & model, SQInt32 world, SQInt32 quantity,
SQFloat x, SQFloat y, SQFloat z,
SQInt32 alpha, bool automatic,
SQInt32 header, SqObj & payload)
{
return _Core->NewPickup(model, world, quantity, x, y, z, alpha, automatic,
header, payload);
}
// ------------------------------------------------------------------------------------------------
Reference< CPickup > CreateBasePickup_CF(const CModel & model, SQInt32 world, SQInt32 quantity,
const Vector3 & pos, SQInt32 alpha, bool automatic)
{
return _Core->NewPickup(model, world, quantity, pos.x, pos.y, pos.z, alpha, automatic,
SQMOD_CREATE_DEFAULT, NullData());
}
Reference< CPickup > CreateBasePickup_CF(const CModel & model, SQInt32 world, SQInt32 quantity,
const Vector3 & pos, SQInt32 alpha, bool automatic,
SQInt32 header, SqObj & payload)
{
return _Core->NewPickup(model, world, quantity, pos.x, pos.y, pos.z, alpha, automatic,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CPickup CreatePickup_PEF(SQInt32 model, SQInt32 world, SQInt32 quantity,
SQFloat x, SQFloat y, SQFloat z,
SQInt32 alpha, bool automatic)
{
return _Core->NewPickup(model, world, quantity, x, y, z, alpha, automatic,
SQMOD_CREATE_DEFAULT, NullData());
}
CPickup CreatePickup_PEF(SQInt32 model, SQInt32 world, SQInt32 quantity,
SQFloat x, SQFloat y, SQFloat z,
SQInt32 alpha, bool automatic,
SQInt32 header, SqObj & payload)
{
return _Core->NewPickup(model, world, quantity, x, y, z, alpha, automatic,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CPickup CreatePickup_PCF(SQInt32 model, SQInt32 world, SQInt32 quantity,
const Vector3 & pos, SQInt32 alpha, bool automatic)
{
return _Core->NewPickup(model, world, quantity, pos.x, pos.y, pos.z, alpha, automatic,
SQMOD_CREATE_DEFAULT, NullData());
}
CPickup CreatePickup_PCF(SQInt32 model, SQInt32 world, SQInt32 quantity,
const Vector3 & pos, SQInt32 alpha, bool automatic,
SQInt32 header, SqObj & payload)
{
return _Core->NewPickup(model, world, quantity, pos.x, pos.y, pos.z, alpha, automatic,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CPickup CreatePickup_EF(const CModel & model, SQInt32 world, SQInt32 quantity,
SQFloat x, SQFloat y, SQFloat z,
SQInt32 alpha, bool automatic)
{
return _Core->NewPickup(model, world, quantity, x, y, z, alpha, automatic,
SQMOD_CREATE_DEFAULT, NullData());
}
CPickup CreatePickup_EF(const CModel & model, SQInt32 world, SQInt32 quantity,
SQFloat x, SQFloat y, SQFloat z,
SQInt32 alpha, bool automatic,
SQInt32 header, SqObj & payload)
{
return _Core->NewPickup(model, world, quantity, x, y, z, alpha, automatic,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CPickup CreatePickup_CF(const CModel & model, SQInt32 world, SQInt32 quantity,
const Vector3 & pos, SQInt32 alpha, bool automatic)
{
return _Core->NewPickup(model, world, quantity, pos.x, pos.y, pos.z, alpha, automatic,
SQMOD_CREATE_DEFAULT, NullData());
}
CPickup CreatePickup_CF(const CModel & model, SQInt32 world, SQInt32 quantity,
const Vector3 & pos, SQInt32 alpha, bool automatic,
SQInt32 header, SqObj & payload)
static Object & CreatePickup(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,
header, payload);
}
// ================================================================================================
bool Register_CPickup(HSQUIRRELVM vm)
void Register_CPickup(HSQUIRRELVM vm)
{
// Attempt to register the base reference type before the actual implementation
if (!Register_Reference< CPickup >(vm, _SC("BasePickup")))
{
LogFtl("Unable to register the base class <BasePickup> for <CPickup> type");
// Registration failed
return false;
}
// Typedef the base reference type for simplicity
typedef Reference< CPickup > RefType;
// Output debugging information
LogDbg("Beginning registration of <CPickup> type");
// Attempt to register the actual reference that implements all of the entity functionality
Sqrat::RootTable(vm).Bind(_SC("CPickup"), Sqrat::DerivedClass< CPickup, RefType >(vm, _SC("CPickup"))
/* Constructors */
.Ctor()
.Ctor< SQInt32 >()
RootTable(vm).Bind(_SC("SqPickup"),
Class< CPickup, NoConstructor< CPickup > >(vm, _SC("SqPickup"))
/* Metamethods */
.Func(_SC("_cmp"), &CPickup::Cmp)
.Func(_SC("_tostring"), &CPickup::ToString)
/* Core Properties */
.Prop(_SC("ID"), &CPickup::GetID)
.Prop(_SC("Tag"), &CPickup::GetTag, &CPickup::SetTag)
.Prop(_SC("Data"), &CPickup::GetData, &CPickup::SetData)
.Prop(_SC("MaxID"), &CPickup::GetMaxID)
.Prop(_SC("Active"), &CPickup::IsActive)
/* Core Functions */
.Func(_SC("Bind"), &CPickup::BindEvent)
/* Core Overloads */
.Overload< bool (CPickup::*)(void) >(_SC("Destroy"), &CPickup::Destroy)
.Overload< bool (CPickup::*)(Int32) >(_SC("Destroy"), &CPickup::Destroy)
.Overload< bool (CPickup::*)(Int32, Object &) >(_SC("Destroy"), &CPickup::Destroy)
/* Properties */
.Prop(_SC("model"), &CPickup::GetModel)
.Prop(_SC("model_id"), &CPickup::GetModelID)
.Prop(_SC("world"), &CPickup::GetWorld, &CPickup::SetWorld)
.Prop(_SC("alpha"), &CPickup::GetAlpha, &CPickup::SetAlpha)
.Prop(_SC("automatic"), &CPickup::GetAutomatic, &CPickup::SetAutomatic)
.Prop(_SC("auto_timer"), &CPickup::GetAutoTimer, &CPickup::SetAutoTimer)
.Prop(_SC("position"), &CPickup::GetPosition, &CPickup::SetPosition)
.Prop(_SC("quantity"), &CPickup::GetQuantity)
.Prop(_SC("Model"), &CPickup::GetModel)
.Prop(_SC("World"), &CPickup::GetWorld, &CPickup::SetWorld)
.Prop(_SC("Alpha"), &CPickup::GetAlpha, &CPickup::SetAlpha)
.Prop(_SC("Auto"), &CPickup::GetAutomatic, &CPickup::SetAutomatic)
.Prop(_SC("Automatic"), &CPickup::GetAutomatic, &CPickup::SetAutomatic)
.Prop(_SC("Timer"), &CPickup::GetAutoTimer, &CPickup::SetAutoTimer)
.Prop(_SC("Autotimer"), &CPickup::GetAutoTimer, &CPickup::SetAutoTimer)
.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)
/* Functions */
.Func(_SC("streamed_for"), &CPickup::IsStreamedFor)
.Func(_SC("refresh"), &CPickup::Refresh)
.Func(_SC("set_position"), &CPickup::SetPositionEx)
.Func(_SC("StreamedFor"), &CPickup::IsStreamedFor)
.Func(_SC("Refresh"), &CPickup::Refresh)
.Func(_SC("SetPos"), &CPickup::SetPositionEx)
.Func(_SC("SetPosition"), &CPickup::SetPositionEx)
);
// Output debugging information
LogDbg("Registration of <CPickup> type was successful");
// Output debugging information
LogDbg("Beginning registration of <Pickup> functions");
// Register global functions related to this entity type
Sqrat::RootTable(vm)
/* Create BasePickup [P]rimitive [E]xtended [F]Full */
.Overload< RefType (*)(SQInt32, SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, SQInt32, bool) >
(_SC("CreateBasePickup_PEF"), &CreateBasePickup_PEF)
.Overload< RefType (*)(SQInt32, SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, SQInt32, bool, SQInt32, SqObj &) >
(_SC("CreateBasePickup_PEF"), &CreateBasePickup_PEF)
/* Create BasePickup [P]rimitive [C]ompact [F]ull */
.Overload< RefType (*)(SQInt32, SQInt32, SQInt32, const Vector3 &, SQInt32, bool) >
(_SC("CreateBasePickup_PCF"), &CreateBasePickup_PCF)
.Overload< RefType (*)(SQInt32, SQInt32, SQInt32, const Vector3 &, SQInt32, bool, SQInt32, SqObj &) >
(_SC("CreateBasePickup_PCF"), &CreateBasePickup_PCF)
/* Create BasePickup [E]xtended [F]Full */
.Overload< RefType (*)(const CModel &, SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, SQInt32, bool) >
(_SC("CreateBasePickup_EF"), &CreateBasePickup_EF)
.Overload< RefType (*)(const CModel &, SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, SQInt32, bool, SQInt32, SqObj &) >
(_SC("CreateBasePickup_EF"), &CreateBasePickup_EF)
/* Create BasePickup [C]ompact [F]ull */
.Overload< RefType (*)(const CModel &, SQInt32, SQInt32, const Vector3 &, SQInt32, bool) >
(_SC("CreateBasePickup_CF"), &CreateBasePickup_CF)
.Overload< RefType (*)(const CModel &, SQInt32, SQInt32, const Vector3 &, SQInt32, bool, SQInt32, SqObj &) >
(_SC("CreateBasePickup_CF"), &CreateBasePickup_CF)
/* Create CPickup [P]rimitive [E]xtended [F]Full */
.Overload< CPickup (*)(SQInt32, SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, SQInt32, bool) >
(_SC("CreatePickup_PEF"), &CreatePickup_PEF)
.Overload< CPickup (*)(SQInt32, SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, SQInt32, bool, SQInt32, SqObj &) >
(_SC("CreatePickup_PEF"), &CreatePickup_PEF)
/* Create CPickup [P]rimitive [C]ompact [F]ull */
.Overload< CPickup (*)(SQInt32, SQInt32, SQInt32, const Vector3 &, SQInt32, bool) >
(_SC("CreatePickup_PCF"), &CreatePickup_PCF)
.Overload< CPickup (*)(SQInt32, SQInt32, SQInt32, const Vector3 &, SQInt32, bool, SQInt32, SqObj &) >
(_SC("CreatePickup_PCF"), &CreatePickup_PCF)
/* Create CPickup [E]xtended [F]Full */
.Overload< CPickup (*)(const CModel &, SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, SQInt32, bool) >
(_SC("CreatePickup_EF"), &CreatePickup_EF)
.Overload< CPickup (*)(const CModel &, SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, SQInt32, bool, SQInt32, SqObj &) >
(_SC("CreatePickup_EF"), &CreatePickup_EF)
/* Create CPickup [C]ompact [F]ull */
.Overload< CPickup (*)(const CModel &, SQInt32, SQInt32, const Vector3 &, SQInt32, bool) >
(_SC("CreatePickup_CF"), &CreatePickup_CF)
.Overload< CPickup (*)(const CModel &, SQInt32, SQInt32, const Vector3 &, SQInt32, bool, SQInt32, SqObj &) >
(_SC("CreatePickup_CF"), &CreatePickup_CF);
// Output debugging information
LogDbg("Registration of <Pickup> functions was successful");
// Registration succeeded
return true;
RootTable(vm)
.Overload< Object & (*)(Int32, Int32, Int32, Float32, Float32, Float32, Int32, bool) >
(_SC("CreatePickupEx"), &CreatePickupEx)
.Overload< Object & (*)(Int32, Int32, Int32, Float32, Float32, Float32, Int32, bool, Int32, Object &) >
(_SC("CreatePickupEx"), &CreatePickupEx)
.Overload< Object & (*)(Int32, Int32, Int32, const Vector3 &, Int32, bool) >
(_SC("CreatePickup"), &CreatePickup)
.Overload< Object & (*)(Int32, Int32, Int32, const Vector3 &, Int32, bool, Int32, Object &) >
(_SC("CreatePickup"), &CreatePickup);
}
} // Namespace:: SqMod
} // Namespace:: SqMod

View File

@ -2,113 +2,153 @@
#define _ENTITY_PICKUP_HPP_
// ------------------------------------------------------------------------------------------------
#include "Entity.hpp"
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Class responsible for managing the referenced pickup instance.
* Manages Pickup instances.
*/
class CPickup : public Reference< CPickup >
class CPickup
{
// --------------------------------------------------------------------------------------------
static CModel s_Model;
friend class Core;
private:
// --------------------------------------------------------------------------------------------
static Vector3 s_Vector3;
/* --------------------------------------------------------------------------------------------
* Cached identifiers for fast integer to string conversion.
*/
static SQChar s_StrID[SQMOD_PICKUP_POOL][8];
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
*/
Int32 m_ID;
/* --------------------------------------------------------------------------------------------
* User tag and data associated with this instance.
*/
String m_Tag;
Object m_Data;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CPickup(Int32 id);
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
CPickup(const CPickup &);
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
CPickup & operator = (const CPickup &);
public:
/* --------------------------------------------------------------------------------------------
* Import the constructors, destructors and assignment operators from the base class.
*/
using RefType::Reference;
// --------------------------------------------------------------------------------------------
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* Construct a reference from a base reference.
* Destructor.
*/
CPickup(const Reference< CPickup > & o);
~CPickup();
/* --------------------------------------------------------------------------------------------
* See if the referenced pickup instance is streamed for the specified player.
* See whether this instance manages a valid entity.
*/
bool IsStreamedFor(const Reference< CPlayer > & player) const;
bool Validate() const
{
if (VALID_ENTITY(m_ID))
return true;
SqThrow("Invalid pickup reference [%s]", m_Tag.c_str());
return false;
}
/* --------------------------------------------------------------------------------------------
* Retrieve the model of the referenced pickup instance.
* Used by the script engine to compare two instances of this type.
*/
const CModel & GetModel() const;
Int32 Cmp(const CPickup & o) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the model identifier of the referenced pickup instance.
* Used by the script engine to convert an instance of this type to a string.
*/
SQInt32 GetModelID() const;
CSStr ToString() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the world in which the referenced pickup instance exists.
* Retrieve the identifier of the entity managed by this instance.
*/
SQInt32 GetWorld() const;
Int32 GetID() const { return m_ID; }
/* --------------------------------------------------------------------------------------------
* Change the world in which the referenced pickup instance exists.
* Retrieve the maximum possible identifier to an entity of this type.
*/
void SetWorld(SQInt32 world) const;
Int32 GetMaxID() const { return SQMOD_PICKUP_POOL; }
/* --------------------------------------------------------------------------------------------
* Retrieve the alpha of the referenced pickup instance.
* Check whether this instance manages a valid entity.
*/
SQInt32 GetAlpha() const;
bool IsActive() const { return VALID_ENTITY(m_ID); }
/* --------------------------------------------------------------------------------------------
* Change the alpha of the referenced pickup instance.
* Retrieve the associated user tag.
*/
void SetAlpha(SQInt32 alpha) const;
CSStr GetTag() const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced pickup instance is automatic.
* 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);
// --------------------------------------------------------------------------------------------
bool Destroy(Int32 header, Object & payload);
bool Destroy() { return Destroy(0, NullObject()); }
bool Destroy(Int32 header) { return Destroy(header, NullObject()); }
// --------------------------------------------------------------------------------------------
bool BindEvent(Int32 evid, Object & env, Function & func) const;
// --------------------------------------------------------------------------------------------
bool IsStreamedFor(CPlayer & player) const;
Int32 GetModel() const;
Int32 GetWorld() const;
void SetWorld(Int32 world) const;
Int32 GetAlpha() const;
void SetAlpha(Int32 alpha) const;
bool GetAutomatic() const;
/* --------------------------------------------------------------------------------------------
* Set whether the referenced pickup instance is automatic.
*/
void SetAutomatic(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the automatic timer of the referenced pickup instance.
*/
SQInt32 GetAutoTimer() const;
/* --------------------------------------------------------------------------------------------
* Change the automatic timer of the referenced pickup instance.
*/
void SetAutoTimer(SQInt32 timer) const;
/* --------------------------------------------------------------------------------------------
* Refresh the referenced pickup instance.
*/
Int32 GetAutoTimer() const;
void SetAutoTimer(Int32 timer) const;
void Refresh() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position of the referenced pickup instance.
*/
const Vector3 & GetPosition();
/* --------------------------------------------------------------------------------------------
* Change the position of the referenced pickup instance.
*/
void SetPosition(const Vector3 & pos) const;
void SetPositionEx(Float32 x, Float32 y, Float32 z) const;
Int32 GetQuantity() const;
/* --------------------------------------------------------------------------------------------
* Change the position of the referenced pickup instance.
*/
void SetPositionEx(SQFloat x, SQFloat y, SQFloat z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the quantity of the referenced pickup instance.
*/
SQInt32 GetQuantity() const;
// --------------------------------------------------------------------------------------------
Float32 GetPosX() const;
Float32 GetPosY() const;
Float32 GetPosZ() const;
void SetPosX(Float32 x) const;
void SetPosY(Float32 y) const;
void SetPosZ(Float32 z) const;
};
} // Namespace:: SqMod

File diff suppressed because it is too large Load Diff

View File

@ -2,738 +2,262 @@
#define _ENTITY_PLAYER_HPP_
// ------------------------------------------------------------------------------------------------
#include "Entity.hpp"
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Class responsible for managing the referenced player instance.
* Manages Player instances.
*/
class CPlayer : public Reference< CPlayer >
class CPlayer
{
// --------------------------------------------------------------------------------------------
static CSkin s_Skin;
static CWeapon s_Weapon;
friend class Core;
private:
// --------------------------------------------------------------------------------------------
static Color3 s_Color3;
static Vector3 s_Vector3;
static Color3 s_Color3;
static Vector3 s_Vector3;
// --------------------------------------------------------------------------------------------
static SQChar s_Buffer[MAX_PLAYER_TEMPORARY_BUFFER];
static SQChar s_Buffer[SQMOD_PLAYER_TMP_BUFFER];
/* --------------------------------------------------------------------------------------------
* Cached identifiers for fast integer to string conversion.
*/
static SQChar s_StrID[SQMOD_PLAYER_POOL][8];
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
*/
Int32 m_ID;
/* --------------------------------------------------------------------------------------------
* User tag and data associated with this instance.
*/
String m_Tag;
Object m_Data;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CPlayer(Int32 id);
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
CPlayer(const CPlayer &);
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
CPlayer & operator = (const CPlayer &);
public:
/* --------------------------------------------------------------------------------------------
* Import the constructors, destructors and assignment operators from the base class.
*/
using RefType::Reference;
// --------------------------------------------------------------------------------------------
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* Construct a reference from a base reference.
* Destructor.
*/
CPlayer(const Reference< CPlayer > & o);
~CPlayer();
/* --------------------------------------------------------------------------------------------
* See whether the referenced player instance has administrator privileges.
* See whether this instance manages a valid entity.
*/
SQInt32 GetLevel() const;
bool Validate() const
{
if (VALID_ENTITY(m_ID))
return true;
SqThrow("Invalid player reference [%s]", m_Tag.c_str());
return false;
}
/* --------------------------------------------------------------------------------------------
* Set whether the referenced player instance has administrator privileges.
* Used by the script engine to compare two instances of this type.
*/
void SetLevel(SQInt32 toggle) const;
Int32 Cmp(const CPlayer & o) const;
/* --------------------------------------------------------------------------------------------
* Get whether referenced player instance uses the global or local message prefixes.
* Used by the script engine to convert an instance of this type to a string.
*/
bool GetLocalPrefixes() const;
CSStr ToString() const;
/* --------------------------------------------------------------------------------------------
* Set whether referenced player instance uses the global or local message prefixes.
* Retrieve the identifier of the entity managed by this instance.
*/
void SetLocalPrefixes(bool toggle) const;
Int32 GetID() const { return m_ID; }
/* --------------------------------------------------------------------------------------------
* Get whether referenced player instance uses the global or local message color.
* Retrieve the maximum possible identifier to an entity of this type.
*/
bool GetLocalMessageColor() const;
Int32 GetMaxID() const { return SQMOD_PLAYER_POOL; }
/* --------------------------------------------------------------------------------------------
* Set whether referenced player instance uses the global or local message color.
* Check whether this instance manages a valid entity.
*/
void SetLocalMessageColor(bool toggle) const;
bool IsActive() const { return VALID_ENTITY(m_ID); }
/* --------------------------------------------------------------------------------------------
* Get whether referenced player instance uses the global or local announcement style.
* Retrieve the associated user tag.
*/
bool GetLocalAnnounceStyle() const;
CSStr GetTag() const;
/* --------------------------------------------------------------------------------------------
* Set whether referenced player instance uses the global or local announcement style.
* Modify the associated user tag.
*/
void SetLocalAnnounceStyle(bool toggle) const;
void SetTag(CSStr tag);
/* --------------------------------------------------------------------------------------------
* Retrieve the local message prefix at the specified index for the referenced player instance.
* Retrieve the associated user data.
*/
const SQChar * GetMessagePrefix(SQUint32 index) const;
Object & GetData();
/* --------------------------------------------------------------------------------------------
* Change the local message prefix at the specified index for the referenced player instance.
* Modify the associated user data.
*/
void SetMessagePrefix(SQUint32 index, const SQChar * prefix) const;
void SetData(Object & data);
/* --------------------------------------------------------------------------------------------
* Retrieve the local message color for the referenced player instance.
*/
SQUint32 GetMessageColor() const;
// --------------------------------------------------------------------------------------------
bool BindEvent(Int32 evid, Object & env, Function & func) const;
/* --------------------------------------------------------------------------------------------
* Change the local message color for the referenced player instance.
*/
void SetMessageColor(SQUint32 color) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the local announcement style for the referenced player instance.
*/
SQInt32 GetAnnounceStyle() const;
/* --------------------------------------------------------------------------------------------
* Change the local announcement style for the referenced player instance.
*/
void SetAnnounceStyle(SQInt32 style) const;
/* --------------------------------------------------------------------------------------------
* See if the referenced player instance is streamed for the specified player.
*/
bool IsStreamedFor(const Reference < CPlayer > & player) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the class of the referenced player instance.
*/
SQInt32 GetClass() const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced player instance has administrator privileges.
*/
// --------------------------------------------------------------------------------------------
bool IsStreamedFor(CPlayer & player) const;
Int32 GetClass() const;
bool GetAdmin() const;
/* --------------------------------------------------------------------------------------------
* Set whether the referenced player instance has administrator privileges.
*/
void SetAdmin(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the ip address of the referenced player instance.
*/
const SQChar * GetIP() const;
/* --------------------------------------------------------------------------------------------
* Kick the referenced player instance from the server.
*/
CSStr GetIP() const;
void Kick() const;
/* --------------------------------------------------------------------------------------------
* Ban the referenced player instance from the server.
*/
void Ban() const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced player instance is connected.
*/
bool IsConnected() const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced player instance is spawned.
*/
bool IsSpawned() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the key of the referenced player instance.
*/
SQUint32 GetKey() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the world in which the referenced player instance exists.
*/
SQInt32 GetWorld() const;
/* --------------------------------------------------------------------------------------------
* Change the world in which the referenced player instance exists.
*/
void SetWorld(SQInt32 world) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the secondary world of the referenced player instance.
*/
SQInt32 GetSecWorld() const;
/* --------------------------------------------------------------------------------------------
* Change the secondary world of the referenced player instance.
*/
void SetSecWorld(SQInt32 world) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the unique world of the referenced player instance.
*/
SQInt32 GetUniqueWorld() const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced player instance is compatible with the specified world.
*/
bool IsWorldCompatible(SQInt32 world) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the current state of the referenced player instance.
*/
SQInt32 GetState() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the nick name of the referenced player instance.
*/
const SQChar * GetName() const;
/* --------------------------------------------------------------------------------------------
* Change the nick name of the referenced player instance.
*/
void SetName(const SQChar * name) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the team of the referenced player instance.
*/
SQInt32 GetTeam() const;
/* --------------------------------------------------------------------------------------------
* Change the team of the referenced player instance.
*/
void SetTeam(SQInt32 team) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the skin of the referenced player instance.
*/
const CSkin & GetSkin() const;
/* --------------------------------------------------------------------------------------------
* Change the skin of the referenced player instance.
*/
void SetSkin(const CSkin & skin) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the skin identifier of the referenced player instance.
*/
SQInt32 GetSkinID() const;
/* --------------------------------------------------------------------------------------------
* Change the skin identifier of the referenced player instance.
*/
void SetSkinID(SQInt32 skin) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the color of the referenced player instance.
*/
Uint32 GetKey() const;
Int32 GetWorld() const;
void SetWorld(Int32 world) const;
Int32 GetSecWorld() const;
void SetSecWorld(Int32 world) const;
Int32 GetUniqueWorld() const;
bool IsWorldCompatible(Int32 world) const;
CSStr GetName() const;
void SetName(CSStr name) const;
Int32 GetTeam() const;
void SetTeam(Int32 team) const;
Int32 GetSkin() const;
void SetSkin(Int32 skin) const;
const Color3 & GetColor() const;
/* --------------------------------------------------------------------------------------------
* Change the color of the referenced player instance.
*/
void SetColor(const Color3 & color) const;
/* --------------------------------------------------------------------------------------------
* Change the color of the referenced player instance.
*/
void SetColorEx(uint8 r, uint8 g, uint8 b) const;
/* --------------------------------------------------------------------------------------------
* Force the referenced player instance to spawn in the game.
*/
void SetColorEx(Uint8 r, Uint8 g, Uint8 b) const;
void ForceSpawn() const;
/* --------------------------------------------------------------------------------------------
* Force the referenced player instance to select a class.
*/
void ForceSelect() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the money amount of the referenced player instance.
*/
SQInt32 GetMoney() const;
/* --------------------------------------------------------------------------------------------
* Change the money amount of the referenced player instance.
*/
void SetMoney(SQInt32 amount) const;
/* --------------------------------------------------------------------------------------------
* Give a certain amount of money to the referenced player instance.
*/
void GiveMoney(SQInt32 amount) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the score of the referenced player instance.
*/
SQInt32 GetScore() const;
/* --------------------------------------------------------------------------------------------
* Change the score of the referenced player instance.
*/
void SetScore(SQInt32 score) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the connection latency of the referenced player instance.
*/
SQInt32 GetPing() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the frames per second of the referenced player instance.
*/
SQFloat GetFPS() const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced player instance is typing.
*/
Int32 GetMoney() const;
void SetMoney(Int32 amount) const;
void GiveMoney(Int32 amount) const;
Int32 GetScore() const;
void SetScore(Int32 score) const;
Int32 GetPing() const;
Float32 GetFPS() const;
bool IsTyping() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the unique user identifier of the referenced player instance.
*/
const SQChar * GetUID() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the unique user identifier version 2 of the referenced player instance.
*/
const SQChar * GetUID2() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the current health of the referenced player instance.
*/
SQFloat GetHealth() const;
/* --------------------------------------------------------------------------------------------
* Change the health of the referenced player instance.
*/
void SetHealth(SQFloat amount) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the current health of the referenced player instance.
*/
SQFloat GetArmour() const;
/* --------------------------------------------------------------------------------------------
* Change the health of the referenced player instance.
*/
void SetArmour(SQFloat amount) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the immunity flags of the referenced player instance.
*/
SQInt32 GetImmunity() const;
/* --------------------------------------------------------------------------------------------
* Change the immunity flags of the referenced player instance.
*/
void SetImmunity(SQInt32 flags) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position of the referenced player instance.
*/
CSStr GetUID() const;
CSStr GetUID2() const;
Float32 GetHealth() const;
void SetHealth(Float32 amount) const;
Float32 GetArmor() const;
void SetArmor(Float32 amount) const;
Int32 GetImmunity() const;
void SetImmunity(Int32 flags) const;
const Vector3 & GetPosition() const;
/* --------------------------------------------------------------------------------------------
* Change the position of the referenced player instance.
*/
void SetPosition(const Vector3 & pos) const;
/* --------------------------------------------------------------------------------------------
* Change the position of the referenced player instance.
*/
void SetPositionEx(SQFloat x, SQFloat y, SQFloat z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the speed of the referenced player instance.
*/
void SetPositionEx(Float32 x, Float32 y, Float32 z) const;
const Vector3 & GetSpeed() const;
/* --------------------------------------------------------------------------------------------
* Change the speed of the referenced player instance.
*/
void SetSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Change the speed of the referenced player instance.
*/
void SetSpeedEx(SQFloat x, SQFloat y, SQFloat z) const;
/* --------------------------------------------------------------------------------------------
* Change the speed of the referenced player instance.
*/
void SetSpeedEx(Float32 x, Float32 y, Float32 z) const;
void AddSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Change the speed of the referenced player instance.
*/
void AddSpeedEx(SQFloat x, SQFloat y, SQFloat z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the heading angle of the referenced player instance.
*/
SQFloat GetHeading() const;
/* --------------------------------------------------------------------------------------------
* Change the heading angle of the referenced player instance.
*/
void SetHeading(SQFloat angle) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the alpha of the referenced player instance.
*/
SQInt32 GetAlpha() const;
/* --------------------------------------------------------------------------------------------
* Change the alpha of the referenced player instance.
*/
void SetAlpha(SQInt32 alpha, SQInt32 fade) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the vehicle status of the referenced player instance.
*/
SQInt32 GetVehicleStatus() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the occupied vehicle slot by the referenced player instance.
*/
SQInt32 GetOccupiedSlot() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the vehicle in which the referenced player instance is embarked.
*/
Reference < CVehicle > GetVehicle() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the vehicle identifier in which the referenced player instance is embarked.
*/
SQInt32 GetVehicleID() const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced player instance can be controlled.
*/
void AddSpeedEx(Float32 x, Float32 y, Float32 z) const;
Float32 GetHeading() const;
void SetHeading(Float32 angle) const;
Int32 GetAlpha() const;
void SetAlpha(Int32 alpha, Int32 fade) const;
Int32 GetVehicleStatus() const;
Int32 GetOccupiedSlot() const;
Object & GetVehicle() const;
Int32 GetVehicleID() const;
bool GetControllable() const;
/* --------------------------------------------------------------------------------------------
* Set whether the referenced player instance can be controlled.
*/
void SetControllable(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced player instance can driveby.
*/
bool GetDriveby() const;
/* --------------------------------------------------------------------------------------------
* Set whether the referenced player instance can driveby.
*/
void SetDriveby(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced player instance has white scanlines.
*/
bool GetWhiteScanlines() const;
/* --------------------------------------------------------------------------------------------
* Set whether the referenced player instance has white scanlines.
*/
void SetWhiteScanlines(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced player instance has green scanlines.
*/
bool GetGreenScanlines() const;
/* --------------------------------------------------------------------------------------------
* Set whether the referenced player instance has green scanlines.
*/
void SetGreenScanlines(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced player instance has widescreen.
*/
bool GetWidescreen() const;
/* --------------------------------------------------------------------------------------------
* Set whether the referenced player instance has widescreen.
*/
void SetWidescreen(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced player instance displays markers.
*/
bool GetShowMarkers() const;
/* --------------------------------------------------------------------------------------------
* Set whether the referenced player instance displays markers.
*/
void SetShowMarkers(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced player instance has attacking privileges.
*/
bool GetAttackPriv() const;
/* --------------------------------------------------------------------------------------------
* Set whether the referenced player instance has attacking privileges.
*/
void SetAttackPriv(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced player instance has markers.
*/
bool GetHasMarker() const;
/* --------------------------------------------------------------------------------------------
* Set whether the referenced player instance has markers.
*/
void SetHasMarker(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced player instance has chat tags.
*/
bool GetChatTags() const;
/* --------------------------------------------------------------------------------------------
* Set whether the referenced player instance has chat tags.
*/
void SetChatTags(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced player instance is under drunk effects.
*/
bool GetDrunkEffects() const;
/* --------------------------------------------------------------------------------------------
* Set whether the referenced player instance is under drunk effects.
*/
void SetDrunkEffects(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the weapon of the referenced player instance.
*/
const CWeapon & GetWeapon() const;
/* --------------------------------------------------------------------------------------------
* Change the weapon of the referenced player instance.
*/
void SetWeapon(const CWeapon & wep) const;
/* --------------------------------------------------------------------------------------------
* Change the weapon of the referenced player instance.
*/
void SetWeaponEx(const CWeapon & wep, SQInt32 ammo) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the weapon identifier of the referenced player instance.
*/
SQInt32 GetWeaponID() const;
/* --------------------------------------------------------------------------------------------
* Change the weapon of the referenced player instance.
*/
void SetWeaponID(SQInt32 wep) const;
/* --------------------------------------------------------------------------------------------
* Change the weapon of the referenced player instance.
*/
void SetWeaponIDEx(SQInt32 wep, SQInt32 ammo) const;
/* --------------------------------------------------------------------------------------------
* Give a weapon of the referenced player instance.
*/
void GiveWeapon(const CWeapon & wep) const;
/* --------------------------------------------------------------------------------------------
* Give a weapon of the referenced player instance.
*/
void GiveWeaponEx(const CWeapon & wep, SQInt32 ammo) const;
/* --------------------------------------------------------------------------------------------
* Give a weapon of the referenced player instance.
*/
void GiveWeaponIDEx(SQInt32 wep, SQInt32 ammo) const;
/* --------------------------------------------------------------------------------------------
* Strip the referenced player instance of all weapons.
*/
Int32 GetWeapon() const;
void SetWeapon(Int32 wep, Int32 ammo) const;
void GiveWeapon(Int32 wep, Int32 ammo) const;
void StripWeapons() const;
/* --------------------------------------------------------------------------------------------
* Change the camera position of the referenced player instance.
*/
void SetCameraPosition(const Vector3 & pos, const Vector3 & aim) const;
/* --------------------------------------------------------------------------------------------
* Change the camera position of the referenced player instance.
*/
void SetCameraPosition(SQFloat xp, SQFloat yp, SQFloat zp, SQFloat xa, SQFloat ya, SQFloat za) const;
/* --------------------------------------------------------------------------------------------
* Restore the camera position of the referenced player instance.
*/
void SetCameraPosition(Float32 xp, Float32 yp, Float32 zp, Float32 xa, Float32 ya, Float32 za) const;
void RestoreCamera() const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced player instance has camera locked.
*/
bool IsCameraLocked() const;
/* --------------------------------------------------------------------------------------------
* Change the animation of the referenced player instance.
*/
void SetAnimation(SQInt32 group, SQInt32 anim) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the wanted level of the referenced player instance.
*/
SQInt32 GetWantedLevel() const;
/* --------------------------------------------------------------------------------------------
* Change the wanted level of the referenced player instance.
*/
void SetWantedLevel(SQInt32 level) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the vehicle that the referenced player instance is standing on.
*/
Reference < CVehicle > StandingOnVehicle() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the object that the referenced player instance is standing on.
*/
Reference < CObject > StandingOnObject() const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced player instance is away.
*/
void SetAnimation(Int32 group, Int32 anim) const;
Int32 GetWantedLevel() const;
void SetWantedLevel(Int32 level) const;
Object & StandingOnVehicle() const;
Object & StandingOnObject() const;
bool IsAway() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the player that the referenced player instance is spectating.
*/
Reference < CPlayer > GetSpectator() const;
/* --------------------------------------------------------------------------------------------
* Set the referenced player instance to spectate the specified player instance.
*/
void SetSpectator(const Reference < CPlayer > & target) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the player that the referenced player instance is spectating.
*/
Reference < CPlayer > Spectating() const;
/* --------------------------------------------------------------------------------------------
* Set the referenced player instance to spectate the specified player instance.
*/
void Spectate(const Reference < CPlayer > & target) const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced player instance is burning.
*/
Object & GetSpectator() const;
void SetSpectator(CPlayer & target) const;
bool IsBurning() const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced player instance is crouched.
*/
bool IsCrouched() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the current action of the referenced player instance.
*/
SQInt32 GetAction() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the game keys of the referenced player instance.
*/
SQInt32 GetGameKeys() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the aim position of the referenced player instance.
*/
Int32 GetState() const;
Int32 GetAction() const;
Int32 GetGameKeys() const;
const Vector3 & GetAimPos() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the aim direction of the referenced player instance.
*/
const Vector3 & GetAimDir() const;
/* --------------------------------------------------------------------------------------------
* Embark the referenced player instance into the specified vehicle instance.
*/
void Embark(const Reference < CVehicle > & vehicle) const;
/* --------------------------------------------------------------------------------------------
* Embark the referenced player instance into the specified vehicle instance.
*/
void Embark(const Reference < CVehicle > & vehicle, SQInt32 slot, bool allocate, bool warp) const;
/* --------------------------------------------------------------------------------------------
* Disembark the referenced player instance from the currently embarked vehicle instance.
*/
void Embark(CVehicle & vehicle) const;
void Embark(CVehicle & vehicle, Int32 slot, bool allocate, bool warp) const;
void Disembark() const;
bool Redirect(CSStr ip, Uint32 port, CSStr nick, CSStr pass, CSStr user);
Int32 GetAuthority() const;
void SetAuthority(Int32 level) const;
CSStr GetMessagePrefix(Uint32 index) const;
void SetMessagePrefix(Uint32 index, CSStr prefix) const;
Uint32 GetMessageColor() const;
void SetMessageColor(Uint32 color) const;
Int32 GetAnnounceStyle() const;
void SetAnnounceStyle(Int32 style) const;
/* --------------------------------------------------------------------------------------------
* Redirect the referenced player instance to the specified server.
*/
bool Redirect(const SQChar * ip, SQUint32 port, const SQChar * nick, \
const SQChar * pass, const SQChar * user);
// --------------------------------------------------------------------------------------------
Float32 GetPosX() const;
Float32 GetPosY() const;
Float32 GetPosZ() const;
void SetPosX(Float32 x) const;
void SetPosY(Float32 y) const;
void SetPosZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* Send a normal colored message to the referenced player instance.
*/
// --------------------------------------------------------------------------------------------
static SQInteger Msg(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Send a normal prefixed message to the referenced player instance.
*/
static SQInteger MsgP(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Send a normal colored message to the referenced player instance.
*/
static SQInteger MsgEx(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Send a normal message to the referenced player instance.
*/
static SQInteger Message(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Send an announcement message to the referenced player instance.
*/
static SQInteger Announce(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Send a styled announcement message to the referenced player instance.
*/
static SQInteger AnnounceEx(HSQUIRRELVM vm);
protected:
/* --------------------------------------------------------------------------------------------
* Fetch the message prefix that a certain player instance must use.
*/
static const SQChar * FetchMessagePrefix(SQInt32 player, SQUint32 index);
/* --------------------------------------------------------------------------------------------
* Fetch the message color that a certain player instance must use.
*/
static SQUint32 FetchMessageColor(SQInt32 player);
/* --------------------------------------------------------------------------------------------
* Fetch the announce type that a certain player instance must use.
*/
static SQInteger FetchAnnounceStyle(SQInt32 player);
};
} // Namespace:: SqMod
#endif // _ENTITY_PLAYER_HPP_
#endif // _ENTITY_PLAYER_HPP_

View File

@ -1,446 +0,0 @@
#include "Entity/Sphere.hpp"
#include "Base/Color3.hpp"
#include "Core.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
Color3 CSphere::s_Color3;
Vector3 CSphere::s_Vector3;
// ------------------------------------------------------------------------------------------------
SQUint32 CSphere::s_ColorR;
SQUint32 CSphere::s_ColorG;
SQUint32 CSphere::s_ColorB;
// ------------------------------------------------------------------------------------------------
CSphere::CSphere(const Reference< CSphere > & o)
: Reference(o)
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
bool CSphere::IsStreamedFor(const Reference< CPlayer > & player) const
{
if (VALID_ENTITY(m_ID) && player)
{
return _Func->IsSphereStreamedForPlayer(m_ID, player);
}
else if (!player)
{
BadArg("streamed_for", "see whether is streamed for player", _SCI32(player));
}
else
{
BadRef("streamed_for", "see whether is streamed for player");
}
return false;
}
// ------------------------------------------------------------------------------------------------
SQInt32 CSphere::GetWorld() const
{
if (VALID_ENTITY(m_ID))
{
return _Func->GetSphereWorld(m_ID);
}
else
{
BadRef("@world", "get world");
}
return SQMOD_UNKNOWN;
}
// ------------------------------------------------------------------------------------------------
void CSphere::SetWorld(SQInt32 world) const
{
if (VALID_ENTITY(m_ID))
{
_Func->SetSphereWorld(m_ID, world);
}
else
{
BadRef("@world", "set world");
}
}
// ------------------------------------------------------------------------------------------------
const Color3 & CSphere::GetColor() const
{
// Clear any previous color
s_Color3.Clear();
// Attempt to retrieve the color
if (VALID_ENTITY(m_ID))
{
_Func->GetSphereColor(m_ID, &s_ColorR, &s_ColorG, &s_ColorB);
s_Color3.Set(s_ColorR, s_ColorG, s_ColorB);
}
else
{
BadRef("@color", "get color");
}
// Return the color that could be retrieved
return s_Color3;
}
// ------------------------------------------------------------------------------------------------
void CSphere::SetColor(const Color3 & col) const
{
if (VALID_ENTITY(m_ID))
{
_Func->SetSphereColor(m_ID, col.r, col.g, col.b);
}
else
{
BadRef("@color", "set color");
}
}
// ------------------------------------------------------------------------------------------------
void CSphere::SetColorEx(Uint8 r, Uint8 g, Uint8 b) const
{
if (VALID_ENTITY(m_ID))
{
_Func->SetSphereColor(m_ID, r, g, b);
}
else
{
BadRef("set_color", "set color");
}
}
// ------------------------------------------------------------------------------------------------
const Vector3 & CSphere::GetPosition() const
{
// Clear any previous position
s_Vector3.Clear();
// Attempt to retrieve the position
if (VALID_ENTITY(m_ID))
{
_Func->GetSpherePos(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z);
}
else
{
BadRef("@position", "get position");
}
// Return the position that could be retrieved
return s_Vector3;
}
// ------------------------------------------------------------------------------------------------
void CSphere::SetPosition(const Vector3 & pos) const
{
if (VALID_ENTITY(m_ID))
{
_Func->SetSpherePos(m_ID, pos.x, pos.y, pos.z);
}
else
{
BadRef("@position", "set position");
}
}
// ------------------------------------------------------------------------------------------------
void CSphere::SetPositionEx(SQFloat x, SQFloat y, SQFloat z) const
{
if (VALID_ENTITY(m_ID))
{
_Func->SetSpherePos(m_ID, x, y, z);
}
else
{
BadRef("set_position", "set position");
}
}
// ------------------------------------------------------------------------------------------------
SQFloat CSphere::GetRadius() const
{
if (VALID_ENTITY(m_ID))
{
return _Func->GetSphereRadius(m_ID);
}
else
{
BadRef("@radius", "get radius");
}
return 0.0;
}
// ------------------------------------------------------------------------------------------------
void CSphere::SetRadius(SQFloat radius) const
{
if (VALID_ENTITY(m_ID))
{
_Func->SetSphereRadius(m_ID, radius);
}
else
{
BadRef("@radius", "set radius");
}
}
// ------------------------------------------------------------------------------------------------
Reference< CPlayer > CSphere::GetOwner() const
{
if (VALID_ENTITY(m_ID))
{
return Reference< CPlayer >(_Func->GetSphereOwner(m_ID));
}
else
{
BadRef("@owner", "get owner");
}
return Reference< CPlayer >();
}
// ------------------------------------------------------------------------------------------------
SQInt32 CSphere::GetOwnerID() const
{
if (VALID_ENTITY(m_ID))
{
return _Func->GetSphereOwner(m_ID);
}
else
{
BadRef("@owner_id", "get owner id");
}
return SQMOD_UNKNOWN;
}
// ------------------------------------------------------------------------------------------------
Reference< CSphere > CreateBaseSphere_PEF(SQInt32 player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b,
SQFloat radius)
{
return _Core->NewSphere(player, world, x, y, z, r, g, b, radius,
SQMOD_CREATE_DEFAULT, NullData());
}
Reference< CSphere > CreateBaseSphere_PEF(SQInt32 player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b,
SQFloat radius,
SQInt32 header, SqObj & payload)
{
return _Core->NewSphere(player, world, x, y, z, r, g, b, radius,
header, payload);
}
// ------------------------------------------------------------------------------------------------
Reference< CSphere > CreateBaseSphere_PCF(SQInt32 player, SQInt32 world,
const Vector3 & pos, const Color3 & color, SQFloat radius)
{
return _Core->NewSphere(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, radius,
SQMOD_CREATE_DEFAULT, NullData());
}
Reference< CSphere > CreateBaseSphere_PCF(SQInt32 player, SQInt32 world,
const Vector3 & pos, const Color3 & color, SQFloat radius,
SQInt32 header, SqObj & payload)
{
return _Core->NewSphere(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, radius,
header, payload);
}
// ------------------------------------------------------------------------------------------------
Reference< CSphere > CreateBaseSphere_EF(const Reference< CPlayer > & player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b,
SQFloat radius)
{
return _Core->NewSphere(player, world, x, y, z, r, g, b, radius,
SQMOD_CREATE_DEFAULT, NullData());
}
Reference< CSphere > CreateBaseSphere_EF(const Reference< CPlayer > & player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b,
SQFloat radius,
SQInt32 header, SqObj & payload)
{
return _Core->NewSphere(player, world, x, y, z, r, g, b, radius,
header, payload);
}
// ------------------------------------------------------------------------------------------------
Reference< CSphere > CreateBaseSphere_CF(const Reference< CPlayer > & player, SQInt32 world,
const Vector3 & pos, const Color3 & color, SQFloat radius)
{
return _Core->NewSphere(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, radius,
SQMOD_CREATE_DEFAULT, NullData());
}
Reference< CSphere > CreateBaseSphere_CF(const Reference< CPlayer > & player, SQInt32 world,
const Vector3 & pos, const Color3 & color, SQFloat radius,
SQInt32 header, SqObj & payload)
{
return _Core->NewSphere(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, radius,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CSphere CreateSphere_PEF(SQInt32 player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b,
SQFloat radius)
{
return _Core->NewSphere(player, world, x, y, z, r, g, b, radius,
SQMOD_CREATE_DEFAULT, NullData());
}
CSphere CreateSphere_PEF(SQInt32 player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b,
SQFloat radius,
SQInt32 header, SqObj & payload)
{
return _Core->NewSphere(player, world, x, y, z, r, g, b, radius,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CSphere CreateSphere_PCF(SQInt32 player, SQInt32 world,
const Vector3 & pos, const Color3 & color, SQFloat radius)
{
return _Core->NewSphere(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, radius,
SQMOD_CREATE_DEFAULT, NullData());
}
CSphere CreateSphere_PCF(SQInt32 player, SQInt32 world,
const Vector3 & pos, const Color3 & color, SQFloat radius,
SQInt32 header, SqObj & payload)
{
return _Core->NewSphere(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, radius,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CSphere CreateSphere_EF(const Reference< CPlayer > & player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b,
SQFloat radius)
{
return _Core->NewSphere(player, world, x, y, z, r, g, b, radius,
SQMOD_CREATE_DEFAULT, NullData());
}
CSphere CreateSphere_EF(const Reference< CPlayer > & player, SQInt32 world,
SQFloat x, SQFloat y, SQFloat z,
Uint8 r, Uint8 g, Uint8 b,
SQFloat radius,
SQInt32 header, SqObj & payload)
{
return _Core->NewSphere(player, world, x, y, z, r, g, b, radius,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CSphere CreateSphere_CF(const Reference< CPlayer > & player, SQInt32 world,
const Vector3 & pos, const Color3 & color, SQFloat radius)
{
return _Core->NewSphere(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, radius,
SQMOD_CREATE_DEFAULT, NullData());
}
CSphere CreateSphere_CF(const Reference< CPlayer > & player, SQInt32 world,
const Vector3 & pos, const Color3 & color, SQFloat radius,
SQInt32 header, SqObj & payload)
{
return _Core->NewSphere(player, world, pos.x, pos.y, pos.z, color.r, color.g, color.b, radius,
header, payload);
}
// ================================================================================================
bool Register_CSphere(HSQUIRRELVM vm)
{
// Attempt to register the base reference type before the actual implementation
if (!Register_Reference< CSphere >(vm, _SC("BaseSphere")))
{
LogFtl("Unable to register the base class <BaseSphere> for <CSphere> type");
// Registration failed
return false;
}
// Typedef the base reference type for simplicity
typedef Reference< CSphere > RefType;
// Output debugging information
LogDbg("Beginning registration of <CSphere> type");
// Attempt to register the actual reference that implements all of the entity functionality
Sqrat::RootTable(vm).Bind(_SC("CSphere"), Sqrat::DerivedClass< CSphere, RefType >(vm, _SC("CSphere"))
/* Constructors */
.Ctor()
.Ctor< SQInt32 >()
/* Properties */
.Prop(_SC("world"), &CSphere::GetWorld, &CSphere::SetWorld)
.Prop(_SC("color"), &CSphere::GetColor, &CSphere::SetColor)
.Prop(_SC("position"), &CSphere::GetPosition, &CSphere::SetPosition)
.Prop(_SC("radius"), &CSphere::GetRadius, &CSphere::SetRadius)
.Prop(_SC("owner"), &CSphere::GetOwner)
.Prop(_SC("owner_id"), &CSphere::GetOwnerID)
/* Functions */
.Func(_SC("streamed_for"), &CSphere::IsStreamedFor)
.Func(_SC("set_color"), &CSphere::SetColorEx)
.Func(_SC("set_position"), &CSphere::SetPositionEx)
);
// Output debugging information
LogDbg("Registration of <CSphere> type was successful");
// Output debugging information
LogDbg("Beginning registration of <Sphere> functions");
// Register global functions related to this entity type
Sqrat::RootTable(vm)
/* Create BaseSphere [P]rimitive [E]xtended [F]Full */
.Overload< RefType (*)(SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, SQFloat) >
(_SC("CreateBaseSphere_PEF"), &CreateBaseSphere_PEF)
.Overload< RefType (*)(SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, SQFloat, SQInt32, SqObj &) >
(_SC("CreateBaseSphere_PEF"), &CreateBaseSphere_PEF)
/* Create BaseSphere [P]rimitive [C]ompact [F]ull */
.Overload< RefType (*)(SQInt32, SQInt32, const Vector3 &, const Color3 &, SQFloat) >
(_SC("CreateBaseSphere_PCF"), &CreateBaseSphere_PCF)
.Overload< RefType (*)(SQInt32, SQInt32, const Vector3 &, const Color3 &, SQFloat, SQInt32, SqObj &) >
(_SC("CreateBaseSphere_PCF"), &CreateBaseSphere_PCF)
/* Create BaseSphere [E]xtended [F]Full */
.Overload< RefType (*)(const Reference< CPlayer > &, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, SQFloat) >
(_SC("CreateBaseSphere_EF"), &CreateBaseSphere_EF)
.Overload< RefType (*)(const Reference< CPlayer > &, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, SQFloat, SQInt32, SqObj &) >
(_SC("CreateBaseSphere_EF"), &CreateBaseSphere_EF)
/* Create BaseSphere [C]ompact [F]ull */
.Overload< RefType (*)(const Reference< CPlayer > &, SQInt32, const Vector3 &, const Color3 &, SQFloat) >
(_SC("CreateBaseSphere_CF"), &CreateBaseSphere_CF)
.Overload< RefType (*)(const Reference< CPlayer > &, SQInt32, const Vector3 &, const Color3 &, SQFloat, SQInt32, SqObj &) >
(_SC("CreateBaseSphere_CF"), &CreateBaseSphere_CF)
/* Create CSphere [P]rimitive [E]xtended [F]Full */
.Overload< CSphere (*)(SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, SQFloat) >
(_SC("CreateSphere_PEF"), &CreateSphere_PEF)
.Overload< CSphere (*)(SQInt32, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, SQFloat, SQInt32, SqObj &) >
(_SC("CreateSphere_PEF"), &CreateSphere_PEF)
/* Create CSphere [P]rimitive [C]ompact [F]ull */
.Overload< CSphere (*)(SQInt32, SQInt32, const Vector3 &, const Color3 &, SQFloat) >
(_SC("CreateSphere_PCF"), &CreateSphere_PCF)
.Overload< CSphere (*)(SQInt32, SQInt32, const Vector3 &, const Color3 &, SQFloat, SQInt32, SqObj &) >
(_SC("CreateSphere_PCF"), &CreateSphere_PCF)
/* Create CSphere [E]xtended [F]Full */
.Overload< CSphere (*)(const Reference< CPlayer > &, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, SQFloat) >
(_SC("CreateSphere_EF"), &CreateSphere_EF)
.Overload< CSphere (*)(const Reference< CPlayer > &, SQInt32, SQFloat, SQFloat, SQFloat, Uint8, Uint8, Uint8, SQFloat, SQInt32, SqObj &) >
(_SC("CreateSphere_EF"), &CreateSphere_EF)
/* Create CSphere [C]ompact [F]ull */
.Overload< CSphere (*)(const Reference< CPlayer > &, SQInt32, const Vector3 &, const Color3 &, SQFloat) >
(_SC("CreateSphere_CF"), &CreateSphere_CF)
.Overload< CSphere (*)(const Reference< CPlayer > &, SQInt32, const Vector3 &, const Color3 &, SQFloat, SQInt32, SqObj &) >
(_SC("CreateSphere_CF"), &CreateSphere_CF);
// Output debugging information
LogDbg("Registration of <Sphere> functions was successful");
// Registration succeeded
return true;
}
} // Namespace:: SqMod

View File

@ -1,102 +0,0 @@
#ifndef _ENTITY_SPHERE_HPP_
#define _ENTITY_SPHERE_HPP_
// ------------------------------------------------------------------------------------------------
#include "Entity.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Class responsible for managing the referenced sphere instance.
*/
class CSphere : public Reference< CSphere >
{
// --------------------------------------------------------------------------------------------
static Color3 s_Color3;
static Vector3 s_Vector3;
// --------------------------------------------------------------------------------------------
static SQUint32 s_ColorR, s_ColorG, s_ColorB;
public:
/* --------------------------------------------------------------------------------------------
* Import the constructors, destructors and assignment operators from the base class.
*/
using RefType::Reference;
/* --------------------------------------------------------------------------------------------
* Construct a reference from a base reference.
*/
CSphere(const Reference< CSphere > & o);
/* --------------------------------------------------------------------------------------------
* See if the referenced sphere instance is streamed for the specified player.
*/
bool IsStreamedFor(const Reference< CPlayer > & player) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the world in which the referenced sphere instance exists.
*/
SQInt32 GetWorld() const;
/* --------------------------------------------------------------------------------------------
* Change the world in which the referenced sphere instance exists.
*/
void SetWorld(SQInt32 world) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the color of the referenced sphere instance.
*/
const Color3 & GetColor() const;
/* --------------------------------------------------------------------------------------------
* Change the color of the referenced sphere instance.
*/
void SetColor(const Color3 & col) const;
/* --------------------------------------------------------------------------------------------
* Change the color of the referenced sphere instance.
*/
void SetColorEx(Uint8 r, Uint8 g, Uint8 b) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position of the referenced sphere instance.
*/
const Vector3 & GetPosition() const;
/* --------------------------------------------------------------------------------------------
* Change the position of the referenced sphere instance.
*/
void SetPosition(const Vector3 & pos) const;
/* --------------------------------------------------------------------------------------------
* Change the position of the referenced sphere instance.
*/
void SetPositionEx(SQFloat x, SQFloat y, SQFloat z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the radius of the referenced sphere instance.
*/
SQFloat GetRadius() const;
/* --------------------------------------------------------------------------------------------
* Change the radius of the referenced sphere instance.
*/
void SetRadius(SQFloat radius) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the owner of the referenced sphere instance.
*/
Reference< CPlayer > GetOwner() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the owner identifier of the referenced sphere instance.
*/
SQInt32 GetOwnerID() const;
};
} // Namespace:: SqMod
#endif // _ENTITY_SPHERE_HPP_

File diff suppressed because it is too large Load Diff

View File

@ -2,142 +2,150 @@
#define _ENTITY_SPRITE_HPP_
// ------------------------------------------------------------------------------------------------
#include "Entity.hpp"
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Class responsible for managing the referenced sprite instance.
* Manages Sprite instances.
*/
class CSprite : public Reference< CSprite >
class CSprite
{
// --------------------------------------------------------------------------------------------
friend class Core;
private:
/* --------------------------------------------------------------------------------------------
* Cached identifiers for fast integer to string conversion.
*/
static SQChar s_StrID[SQMOD_SPRITE_POOL][8];
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
*/
Int32 m_ID;
/* --------------------------------------------------------------------------------------------
* User tag and data associated with this instance.
*/
String m_Tag;
Object m_Data;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CSprite(Int32 id);
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
CSprite(const CSprite &);
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
CSprite & operator = (const CSprite &);
public:
/* --------------------------------------------------------------------------------------------
* Import the constructors, destructors and assignment operators from the base class.
*/
using RefType::Reference;
// --------------------------------------------------------------------------------------------
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* Construct a reference from a base reference.
* Destructor.
*/
CSprite(const Reference< CSprite > & o);
~CSprite();
/* --------------------------------------------------------------------------------------------
* Show the referenced sprite instance to all players on the server.
* See whether this instance manages a valid entity.
*/
bool Validate() const
{
if (VALID_ENTITY(m_ID))
return true;
SqThrow("Invalid sprite reference [%s]", m_Tag.c_str());
return false;
}
/* --------------------------------------------------------------------------------------------
* 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.
*/
CSStr ToString() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the identifier of the entity managed by this instance.
*/
Int32 GetID() const { return m_ID; }
/* --------------------------------------------------------------------------------------------
* Retrieve the maximum possible identifier to an entity of this type.
*/
Int32 GetMaxID() const { return SQMOD_SPRITE_POOL; }
/* --------------------------------------------------------------------------------------------
* Check whether this instance manages a valid entity.
*/
bool IsActive() const { return VALID_ENTITY(m_ID); }
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user tag.
*/
CSStr 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);
// --------------------------------------------------------------------------------------------
bool Destroy(Int32 header, Object & payload);
bool Destroy() { return Destroy(0, NullObject()); }
bool Destroy(Int32 header) { return Destroy(header, NullObject()); }
// --------------------------------------------------------------------------------------------
bool BindEvent(Int32 evid, Object & env, Function & func) const;
// --------------------------------------------------------------------------------------------
void ShowAll() const;
/* --------------------------------------------------------------------------------------------
* Show the referenced sprite instance to the specified player instance.
*/
void ShowFor(const Reference< CPlayer > & player) const;
/* --------------------------------------------------------------------------------------------
* Show the referenced sprite instance to all players in the specified range.
*/
void ShowRange(SQInt32 first, SQInt32 last) const;
/* --------------------------------------------------------------------------------------------
* Hide the referenced sprite instance from all players on the server.
*/
void ShowFor(CPlayer & player) const;
void ShowRange(Int32 first, Int32 last) const;
void HideAll() const;
/* --------------------------------------------------------------------------------------------
* Hide the referenced sprite instance from the specified player instance.
*/
void HideFor(const Reference< CPlayer > & player) const;
/* --------------------------------------------------------------------------------------------
* Hide the referenced sprite instance from all players in the specified range.
*/
void HideRange(SQInt32 first, SQInt32 last) const;
/* --------------------------------------------------------------------------------------------
* Set the position of the referenced sprite instance for all players on the server.
*/
void HideFor(CPlayer & player) const;
void HideRange(Int32 first, Int32 last) const;
void SetPositionAll(const Vector2i & pos) const;
/* --------------------------------------------------------------------------------------------
* Set the position of the referenced sprite instance for all players on the server.
*/
void SetPositionAllEx(SQInt32 x, SQInt32 y) const;
/* --------------------------------------------------------------------------------------------
* Set the position of the referenced sprite instance for the specified player instance.
*/
void SetPositionFor(const Reference< CPlayer > & player, const Vector2i & pos) const;
/* --------------------------------------------------------------------------------------------
* Set the position of the referenced sprite instance for the specified player instance.
*/
void SetPositionForEx(const Reference< CPlayer > & player, SQInt32 x, SQInt32 y) const;
/* --------------------------------------------------------------------------------------------
* Set the position of the referenced sprite instance for all players in the specified range.
*/
void SetPositionRange(SQInt32 first, SQInt32 last, const Vector2i & pos) const;
/* --------------------------------------------------------------------------------------------
* Set the center of the referenced sprite instance for all players on the server.
*/
void SetPositionAllEx(Int32 x, Int32 y) const;
void SetPositionFor(CPlayer & player, const Vector2i & pos) const;
void SetPositionForEx(CPlayer & player, Int32 x, Int32 y) const;
void SetPositionRange(Int32 first, Int32 last, const Vector2i & pos) const;
void SetCenterAll(const Vector2i & pos) const;
/* --------------------------------------------------------------------------------------------
* Set the center of the referenced sprite instance for all players on the server.
*/
void SetCenterAllEx(SQInt32 x, SQInt32 y) const;
/* --------------------------------------------------------------------------------------------
* Set the center of the referenced sprite instance for the specified player instance.
*/
void SetCenterFor(const Reference< CPlayer > & player, const Vector2i & pos) const;
/* --------------------------------------------------------------------------------------------
* Set the center of the referenced sprite instance for the specified player instance.
*/
void SetCenterForEx(const Reference< CPlayer > & player, SQInt32 x, SQInt32 y) const;
/* --------------------------------------------------------------------------------------------
* Set the center of the referenced sprite instance for all players in the specified range.
*/
void SetCenterRange(SQInt32 first, SQInt32 last, const Vector2i & pos) const;
/* --------------------------------------------------------------------------------------------
* Set the rotation of the referenced sprite instance for all players on the server.
*/
void SetCenterAllEx(Int32 x, Int32 y) const;
void SetCenterFor(CPlayer & player, const Vector2i & pos) const;
void SetCenterForEx(CPlayer & player, Int32 x, Int32 y) const;
void SetCenterRange(Int32 first, Int32 last, const Vector2i & pos) const;
void SetRotationAll(SQFloat rot) const;
/* --------------------------------------------------------------------------------------------
* Set the rotation of the referenced sprite instance for the specified player instance.
*/
void SetRotationFor(const Reference< CPlayer > & player, SQFloat rot) const;
/* --------------------------------------------------------------------------------------------
* Set the rotation of the referenced sprite instance for all players in the specified range.
*/
void SetRotationRange(SQInt32 first, SQInt32 last, SQFloat rot) const;
/* --------------------------------------------------------------------------------------------
* Set the rotation of the referenced sprite instance for all players on the server.
*/
void SetRotationFor(CPlayer & player, SQFloat rot) const;
void SetRotationRange(Int32 first, Int32 last, SQFloat rot) const;
void SetAlphaAll(Uint8 alpha) const;
/* --------------------------------------------------------------------------------------------
* Set the rotation of the referenced sprite instance for the specified player instance.
*/
void SetAlphaFor(const Reference< CPlayer > & player, Uint8 alpha) const;
/* --------------------------------------------------------------------------------------------
* Set the rotation of the referenced sprite instance for all players in the specified range.
*/
void SetAlphaRange(SQInt32 first, SQInt32 last, Uint8 alpha) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the file path of the texture used by the referenced sprite instance.
*/
const SQChar * GetFilePath() const;
void SetAlphaFor(CPlayer & player, Uint8 alpha) const;
void SetAlphaRange(Int32 first, Int32 last, Uint8 alpha) const;
CSStr GetFilePath() const;
};
} // Namespace:: SqMod

View File

@ -1,551 +1,363 @@
// ------------------------------------------------------------------------------------------------
#include "Entity/Textdraw.hpp"
#include "Entity/Player.hpp"
#include "Base/Vector2i.hpp"
#include "Core.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
CTextdraw::CTextdraw(const Reference< CTextdraw > & o)
: Reference(o)
SQChar CTextdraw::s_StrID[SQMOD_TEXTDRAW_POOL][8];
// ------------------------------------------------------------------------------------------------
const Int32 CTextdraw::Max = SQMOD_TEXTDRAW_POOL;
// ------------------------------------------------------------------------------------------------
CTextdraw::CTextdraw(Int32 id)
: m_ID(VALID_ENTITYGETEX(id, SQMOD_TEXTDRAW_POOL))
, m_Tag(VALID_ENTITY(m_ID) ? s_StrID[m_ID] : _SC("-1"))
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::ShowAll() const
CTextdraw::~CTextdraw()
{
if (VALID_ENTITY(m_ID))
{
_Func->ShowTextdraw(m_ID, SQMOD_UNKNOWN);
}
/* ... */
}
// ------------------------------------------------------------------------------------------------
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
{
BadRef("show_all", "show to all");
}
return -1;
}
CSStr CTextdraw::ToString() const
{
return VALID_ENTITYEX(m_ID, SQMOD_TEXTDRAW_POOL) ? s_StrID[m_ID] : _SC("-1");
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::ShowFor(const Reference< CPlayer > & player) const
CSStr CTextdraw::GetTag() const
{
if (VALID_ENTITY(m_ID) && player)
{
return _Func->ShowTextdraw(m_ID, player);
}
else if (!player)
{
BadArg("show_for", "show to player", _SCI32(player));
}
else
{
BadRef("show_for", "show to player");
}
return m_Tag.c_str();
}
void CTextdraw::SetTag(CSStr tag)
{
m_Tag.assign(tag);
}
Object & CTextdraw::GetData()
{
if (Validate())
return m_Data;
return NullObject();
}
void CTextdraw::SetData(Object & data)
{
if (Validate())
m_Data = data;
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::ShowRange(SQInt32 first, SQInt32 last) const
bool CTextdraw::Destroy(Int32 header, Object & payload)
{
if (VALID_ENTITY(m_ID) && (last >= first))
{
for (; first <= last; ++first)
{
if (Reference< CPlayer >::Verify(first))
{
_Func->ShowTextdraw(m_ID, first);
}
}
}
else if (first < last)
{
BadArg("show_range", "show to range", "using an out of range start", first, last);
}
else
{
BadRef("show_range", "show to range");
}
return _Core->DelTextdraw(m_ID, header, payload);
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::HideAll() const
bool CTextdraw::BindEvent(Int32 evid, Object & env, Function & func) const
{
if (VALID_ENTITY(m_ID))
{
_Func->HideTextdraw(m_ID, SQMOD_UNKNOWN);
}
else
{
BadRef("hide_all", "hide from all");
}
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::HideFor(const Reference< CPlayer > & player) const
{
if (VALID_ENTITY(m_ID) && player)
{
return _Func->HideTextdraw(m_ID, player);
}
else if (!player)
{
BadArg("hide_for", "hide from player", _SCI32(player));
}
else
{
BadRef("hide_for", "hide from player");
}
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::HideRange(SQInt32 first, SQInt32 last) const
{
if (VALID_ENTITY(m_ID) && (last >= first))
{
for (; first <= last; ++first)
{
if (Reference< CPlayer >::Verify(first))
{
_Func->HideTextdraw(m_ID, first);
}
}
}
else if (first < last)
{
BadArg("hide_range", "hide from range", "using an out of range start", first, last);
}
else
{
BadRef("hide_range", "hide from range");
}
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetPositionAll(const Vector2i & pos) const
{
if (VALID_ENTITY(m_ID))
{
_Func->MoveTextdraw(m_ID, SQMOD_UNKNOWN, pos.x, pos.y);
}
else
{
BadRef("set_position_all", "set position for all");
}
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetPositionAllEx(SQInt32 x, SQInt32 y) const
{
if (VALID_ENTITY(m_ID))
{
_Func->MoveTextdraw(m_ID, SQMOD_UNKNOWN, x, y);
}
else
{
BadRef("set_position_all", "set position for all");
}
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetPositionFor(const Reference< CPlayer > & player, const Vector2i & pos) const
{
if (VALID_ENTITY(m_ID) && player)
{
_Func->MoveTextdraw(m_ID, player, pos.x, pos.y);
}
else if (!player)
{
BadArg("set_position_for", "set position for player", _SCI32(player));
}
else
{
BadRef("set_position_for", "set position for player");
}
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetPositionForEx(const Reference< CPlayer > & player, SQInt32 x, SQInt32 y) const
{
if (VALID_ENTITY(m_ID) && player)
{
_Func->MoveTextdraw(m_ID, player, x, y);
}
else if (!player)
{
BadArg("set_position_for", "set position for player", _SCI32(player));
}
else
{
BadRef("set_position_for", "set position for player");
}
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetPositionRange(SQInt32 first, SQInt32 last, const Vector2i & pos) const
{
if (VALID_ENTITY(m_ID) && (last >= first))
{
for (; first <= last; ++first)
{
if (Reference< CPlayer >::Verify(first))
{
_Func->MoveTextdraw(m_ID, first, pos.x, pos.y);
}
}
}
else if (first < last)
{
BadArg("set_position_range", "set position for range", "using an out of range start", first, last);
}
else
{
BadRef("set_position_range", "set position for range");
}
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetColorAll(const Color4 & col) const
{
if (VALID_ENTITY(m_ID))
{
_Func->SetTextdrawColour(m_ID, SQMOD_UNKNOWN, col.GetRGBA());
}
else
{
BadRef("set_color_all", "set color for all");
}
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetColorAllEx(Uint8 r, Uint8 g, Uint8 b, Uint8 a) const
{
if (VALID_ENTITY(m_ID))
{
_Func->SetTextdrawColour(m_ID, SQMOD_UNKNOWN, PACK_RGBA(r, g, b, a));
}
else
{
BadRef("set_color_all", "set color for all");
}
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetColorFor(const Reference< CPlayer > & player, const Color4 & col) const
{
if (VALID_ENTITY(m_ID) && player)
{
_Func->SetTextdrawColour(m_ID, player, col.GetRGBA());
}
else if (!player)
{
BadArg("set_color_for", "set color for player", _SCI32(player));
}
else
{
BadRef("set_color_for", "set color for player");
}
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetColorForEx(const Reference< CPlayer > & player, Uint8 r, Uint8 g, Uint8 b, Uint8 a) const
{
if (VALID_ENTITY(m_ID) && player)
{
_Func->SetTextdrawColour(m_ID, player, PACK_RGBA(r, g, b, a));
}
else if (!player)
{
BadArg("set_color_for", "set color for player", _SCI32(player));
}
else
{
BadRef("set_color_for", "set color for player");
}
}
// ------------------------------------------------------------------------------------------------
void CTextdraw::SetColorRange(SQInt32 first, SQInt32 last, const Color4 & col) const
{
if (VALID_ENTITY(m_ID) && (last >= first))
{
for (const SQUint32 color = col.GetRGBA(); first <= last; ++first)
{
if (Reference< CPlayer >::Verify(first))
{
_Func->SetTextdrawColour(m_ID, first, color);
}
}
}
else if (first < last)
{
BadArg("set_color_range", "set color for range", "using an out of range start", first, last);
}
else
{
BadRef("set_color_range", "set color for range");
}
}
// ------------------------------------------------------------------------------------------------
const SQChar * CTextdraw::GetText() const
{
if (VALID_ENTITY(m_ID))
{
RefType::Get(m_ID).Text.c_str();
}
else
{
BadRef("@text", "get text");
}
return _SC("");
}
// ------------------------------------------------------------------------------------------------
Reference< CTextdraw > CreateBaseTextdraw_ES(const SQChar * text,
SQInt32 xp, SQInt32 yp,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
bool rel)
{
return _Core->NewTextdraw(SQMOD_UNKNOWN, text, xp, yp, PACK_ARGB(a, r, g, b), rel,
SQMOD_CREATE_DEFAULT, NullData());
}
Reference< CTextdraw > CreateBaseTextdraw_ES(const SQChar * text,
SQInt32 xp, SQInt32 yp,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
bool rel,
SQInt32 header, SqObj & payload)
{
return _Core->NewTextdraw(SQMOD_UNKNOWN, text, xp, yp, PACK_ARGB(a, r, g, b), rel,
header, payload);
}
// ------------------------------------------------------------------------------------------------
Reference< CTextdraw > CreateBaseTextdraw_EF(SQInt32 index, const SQChar * text,
SQInt32 xp, SQInt32 yp,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
bool rel)
{
return _Core->NewTextdraw(index,text, xp, yp, PACK_ARGB(a, r, g, b), rel,
SQMOD_CREATE_DEFAULT, NullData());
}
Reference< CTextdraw > CreateBaseTextdraw_EF(SQInt32 index, const SQChar * text,
SQInt32 xp, SQInt32 yp,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
bool rel,
SQInt32 header, SqObj & payload)
{
return _Core->NewTextdraw(index, text, xp, yp, PACK_ARGB(a, r, g, b), rel,
header, payload);
}
// ------------------------------------------------------------------------------------------------
Reference< CTextdraw > CreateBaseTextdraw_CS(const SQChar * 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, NullData());
}
Reference< CTextdraw > CreateBaseTextdraw_CS(const SQChar * text,
const Vector2i & pos, const Color4 & color, bool rel,
SQInt32 header, SqObj & payload)
{
return _Core->NewTextdraw(SQMOD_UNKNOWN, text, pos.x, pos.y, color.GetARGB(), rel,
header, payload);
}
// ------------------------------------------------------------------------------------------------
Reference< CTextdraw > CreateBaseTextdraw_CF(SQInt32 index, const SQChar * text,
const Vector2i & pos, const Color4 & color, bool rel)
{
return _Core->NewTextdraw(index, text, pos.x, pos.y, color.GetARGB(), rel,
SQMOD_CREATE_DEFAULT, NullData());
}
Reference< CTextdraw > CreateBaseTextdraw_CF(SQInt32 index, const SQChar * text,
const Vector2i & pos, const Color4 & color, bool rel,
SQInt32 header, SqObj & payload)
{
return _Core->NewTextdraw(index, text, pos.x, pos.y, color.GetARGB(), rel,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CTextdraw CreateTextdraw_ES(const SQChar * text,
SQInt32 xp, SQInt32 yp,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
bool rel)
{
return _Core->NewTextdraw(SQMOD_UNKNOWN, text, xp, yp, PACK_ARGB(a, r, g, b), rel,
SQMOD_CREATE_DEFAULT, NullData());
}
CTextdraw CreateTextdraw_ES(const SQChar * text,
SQInt32 xp, SQInt32 yp,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
bool rel,
SQInt32 header, SqObj & payload)
{
return _Core->NewTextdraw(SQMOD_UNKNOWN, text, xp, yp, PACK_ARGB(a, r, g, b), rel,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CTextdraw CreateTextdraw_EF(SQInt32 index, const SQChar * text,
SQInt32 xp, SQInt32 yp,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
bool rel)
{
return _Core->NewTextdraw(index,text, xp, yp, PACK_ARGB(a, r, g, b), rel,
SQMOD_CREATE_DEFAULT, NullData());
}
CTextdraw CreateTextdraw_EF(SQInt32 index, const SQChar * text,
SQInt32 xp, SQInt32 yp,
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
bool rel,
SQInt32 header, SqObj & payload)
{
return _Core->NewTextdraw(index, text, xp, yp, PACK_ARGB(a, r, g, b), rel,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CTextdraw CreateTextdraw_CS(const SQChar * 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, NullData());
}
CTextdraw CreateTextdraw_CS(const SQChar * text,
const Vector2i & pos, const Color4 & color, bool rel,
SQInt32 header, SqObj & payload)
{
return _Core->NewTextdraw(SQMOD_UNKNOWN, text, pos.x, pos.y, color.GetARGB(), rel,
header, payload);
}
// ------------------------------------------------------------------------------------------------
CTextdraw CreateTextdraw_CF(SQInt32 index, const SQChar * text,
const Vector2i & pos, const Color4 & color, bool rel)
{
return _Core->NewTextdraw(index, text, pos.x, pos.y, color.GetARGB(), rel,
SQMOD_CREATE_DEFAULT, NullData());
}
CTextdraw CreateTextdraw_CF(SQInt32 index, const SQChar * text,
const Vector2i & pos, const Color4 & color, bool rel,
SQInt32 header, SqObj & payload)
{
return _Core->NewTextdraw(index, text, pos.x, pos.y, color.GetARGB(), rel,
header, payload);
}
// ================================================================================================
bool Register_CTextdraw(HSQUIRRELVM vm)
{
// Attempt to register the base reference type before the actual implementation
if (!Register_Reference< CTextdraw >(vm, _SC("BaseTextdraw")))
{
LogFtl("Unable to register the base class <BaseTextdraw> for <CTextdraw> type");
// Registration failed
if (!Validate())
return false;
}
// Typedef the base reference type for simplicity
typedef Reference< CTextdraw > RefType;
// Output debugging information
LogDbg("Beginning registration of <CTextdraw> type");
// Attempt to register the actual reference that implements all of the entity functionality
Sqrat::RootTable(vm).Bind(_SC("CTextdraw"), Sqrat::DerivedClass< CTextdraw, RefType >(vm, _SC("CTextdraw"))
/* Constructors */
.Ctor()
.Ctor< SQInt32 >()
/* Properties */
.Prop(_SC("text"), &CTextdraw::GetText)
/* Functions */
.Func(_SC("show_all"), &CTextdraw::ShowAll)
.Func(_SC("show_to"), &CTextdraw::ShowFor)
.Func(_SC("show_for"), &CTextdraw::ShowFor)
.Func(_SC("show_range"), &CTextdraw::ShowRange)
.Func(_SC("hide_all"), &CTextdraw::HideAll)
.Func(_SC("hide_for"), &CTextdraw::HideFor)
.Func(_SC("hide_from"), &CTextdraw::HideFor)
.Func(_SC("hide_range"), &CTextdraw::HideRange)
/* Overloads */
.Overload< void (CTextdraw::*)(const Vector2i &) const >
(_SC("set_position_all"), &CTextdraw::SetPositionAll)
.Overload< void (CTextdraw::*)(SQInt32, SQInt32) const >
(_SC("set_position_all"), &CTextdraw::SetPositionAllEx)
.Overload< void (CTextdraw::*)(const Reference< CPlayer > &, const Vector2i &) const >
(_SC("set_position_for"), &CTextdraw::SetPositionFor)
.Overload< void (CTextdraw::*)(const Reference< CPlayer > &, SQInt32, SQInt32) const >
(_SC("set_position_for"), &CTextdraw::SetPositionForEx)
.Overload< void (CTextdraw::*)(SQInt32, SQInt32, const Vector2i &) const >
(_SC("set_position_range"), &CTextdraw::SetPositionRange)
.Overload< void (CTextdraw::*)(const Color4 &) const >
(_SC("set_color_all"), &CTextdraw::SetColorAll)
.Overload< void (CTextdraw::*)(Uint8, Uint8, Uint8, Uint8) const >
(_SC("set_color_all"), &CTextdraw::SetColorAllEx)
.Overload< void (CTextdraw::*)(const Reference< CPlayer > &, const Color4 &) const >
(_SC("set_color_for"), &CTextdraw::SetColorFor)
.Overload< void (CTextdraw::*)(const Reference< CPlayer > &, Uint8, Uint8, Uint8, Uint8) const >
(_SC("set_color_for"), &CTextdraw::SetColorForEx)
.Overload< void (CTextdraw::*)(SQInt32, SQInt32, const Color4 &) const >
(_SC("set_color_range"), &CTextdraw::SetColorRange)
);
// Output debugging information
LogDbg("Registration of <CTextdraw> type was successful");
// Output debugging information
LogDbg("Beginning registration of <Textdraw> functions");
// Register global functions related to this entity type
Sqrat::RootTable(vm)
/* Create BaseTextdraw [E]xtended [S]ubstitute */
.Overload< RefType (*)(const SQChar *, SQInt32, SQInt32, Uint8, Uint8, Uint8, Uint8, bool) >
(_SC("CreateBaseTextdraw_ES"), &CreateBaseTextdraw_ES)
.Overload< RefType (*)(const SQChar *, SQInt32, SQInt32, Uint8, Uint8, Uint8, Uint8, bool, SQInt32, SqObj &) >
(_SC("CreateBaseTextdraw_ES"), &CreateBaseTextdraw_ES)
/* Create BaseTextdraw [E]xtended [F]Full */
.Overload< RefType (*)(SQInt32, const SQChar *, SQInt32, SQInt32, Uint8, Uint8, Uint8, Uint8, bool) >
(_SC("CreateBaseTextdraw_EF"), &CreateBaseTextdraw_EF)
.Overload< RefType (*)(SQInt32, const SQChar *, SQInt32, SQInt32, Uint8, Uint8, Uint8, Uint8, bool, SQInt32, SqObj &) >
(_SC("CreateBaseTextdraw_EF"), &CreateBaseTextdraw_EF)
/* Create BaseTextdraw [C]ompact [S]ubstitute */
.Overload< RefType (*)(const SQChar *, const Vector2i &, const Color4 &, bool) >
(_SC("CreateBaseTextdraw_CS"), &CreateBaseTextdraw_CS)
.Overload< RefType (*)(const SQChar *, const Vector2i &, const Color4 &, bool, SQInt32, SqObj &) >
(_SC("CreateBaseTextdraw_CS"), &CreateBaseTextdraw_CS)
/* Create BaseTextdraw [C]ompact [F]ull */
.Overload< RefType (*)(SQInt32, const SQChar *, const Vector2i &, const Color4 &, bool) >
(_SC("CreateBaseTextdraw_CF"), &CreateBaseTextdraw_CF)
.Overload< RefType (*)(SQInt32, const SQChar *, const Vector2i &, const Color4 &, bool, SQInt32, SqObj &) >
(_SC("CreateBaseTextdraw_CF"), &CreateBaseTextdraw_CF)
/* Create CTextdraw [E]xtended [S]ubstitute */
.Overload< CTextdraw (*)(const SQChar *, SQInt32, SQInt32, Uint8, Uint8, Uint8, Uint8, bool) >
(_SC("CreateTextdraw_ES"), &CreateTextdraw_ES)
.Overload< CTextdraw (*)(const SQChar *, SQInt32, SQInt32, Uint8, Uint8, Uint8, Uint8, bool, SQInt32, SqObj &) >
(_SC("CreateTextdraw_ES"), &CreateTextdraw_ES)
/* Create CTextdraw [E]xtended [F]Full */
.Overload< CTextdraw (*)(SQInt32, const SQChar *, SQInt32, SQInt32, Uint8, Uint8, Uint8, Uint8, bool) >
(_SC("CreateTextdraw_EF"), &CreateTextdraw_EF)
.Overload< CTextdraw (*)(SQInt32, const SQChar *, SQInt32, SQInt32, Uint8, Uint8, Uint8, Uint8, bool, SQInt32, SqObj &) >
(_SC("CreateTextdraw_EF"), &CreateTextdraw_EF)
/* Create CTextdraw [C]ompact [S]ubstitute */
.Overload< CTextdraw (*)(const SQChar *, const Vector2i &, const Color4 &, bool) >
(_SC("CreateTextdraw_CS"), &CreateTextdraw_CS)
.Overload< CTextdraw (*)(const SQChar *, const Vector2i &, const Color4 &, bool, SQInt32, SqObj &) >
(_SC("CreateTextdraw_CS"), &CreateTextdraw_CS)
/* Create CTextdraw [C]ompact [F]ull */
.Overload< CTextdraw (*)(SQInt32, const SQChar *, const Vector2i &, const Color4 &, bool) >
(_SC("CreateTextdraw_CF"), &CreateTextdraw_CF)
.Overload< CTextdraw (*)(SQInt32, const SQChar *, const Vector2i &, const Color4 &, bool, SQInt32, SqObj &) >
(_SC("CreateTextdraw_CF"), &CreateTextdraw_CF);
// Output debugging information
LogDbg("Registration of <Textdraw> functions was successful");
// Registration succeeded
Function & event = _Core->GetTextdrawEvent(m_ID, evid);
if (func.IsNull())
event.Release();
else
event = Function(env.GetVM(), env, func.GetFunc());
return true;
}
} // Namespace:: SqMod
// ------------------------------------------------------------------------------------------------
void CTextdraw::ShowAll() const
{
if (Validate())
_Func->ShowTextdraw(m_ID, -1);
}
void CTextdraw::ShowFor(CPlayer & player) const
{
if (!player.IsActive())
SqThrow("Invalid player argument: null");
else if (Validate())
_Func->ShowTextdraw(m_ID, player.GetID());
}
void CTextdraw::ShowRange(Int32 first, Int32 last) const
{
if (first > last)
SqThrow("Invalid player range: %d > %d", first, last);
else if (Validate())
for (; first <= last; ++first)
{
if (_Func->IsPlayerConnected(first))
_Func->ShowTextdraw(m_ID, first);
}
}
void CTextdraw::HideAll() const
{
if (Validate())
_Func->HideTextdraw(m_ID, -1);
}
void CTextdraw::HideFor(CPlayer & player) const
{
if (!player.IsActive())
SqThrow("Invalid player argument: null");
else if (Validate())
_Func->HideTextdraw(m_ID, player.GetID());
}
void CTextdraw::HideRange(Int32 first, Int32 last) const
{
if (first > last)
SqThrow("Invalid player range: %d > %d", first, last);
else if (Validate())
for (; first <= last; ++first)
{
if (_Func->IsPlayerConnected(first))
_Func->HideTextdraw(m_ID, first);
}
}
void CTextdraw::SetPositionAll(const Vector2i & pos) const
{
if (Validate())
_Func->MoveTextdraw(m_ID, -1, pos.x, pos.y);
}
void CTextdraw::SetPositionAllEx(Int32 x, Int32 y) const
{
if (Validate())
_Func->MoveTextdraw(m_ID, -1, x, y);
}
void CTextdraw::SetPositionFor(CPlayer & player, const Vector2i & pos) const
{
if (!player.IsActive())
SqThrow("Invalid player argument: null");
else if (Validate())
_Func->MoveTextdraw(m_ID, player.GetID(), pos.x, pos.y);
}
void CTextdraw::SetPositionForEx(CPlayer & player, Int32 x, Int32 y) const
{
if (!player.IsActive())
SqThrow("Invalid player argument: null");
else if (Validate())
_Func->MoveTextdraw(m_ID, player.GetID(), x, y);
}
void CTextdraw::SetPositionRange(Int32 first, Int32 last, const Vector2i & pos) const
{
if (first > last)
SqThrow("Invalid player range: %d > %d", first, last);
else if (Validate())
for (; first <= last; ++first)
{
if (_Func->IsPlayerConnected(first))
_Func->MoveTextdraw(m_ID, first, pos.x, pos.y);
}
}
void CTextdraw::SetColorAll(const Color4 & col) const
{
if (Validate())
_Func->SetTextdrawColour(m_ID, -1, col.GetRGBA());
}
void CTextdraw::SetColorAllEx(Uint8 r, Uint8 g, Uint8 b, Uint8 a) const
{
if (Validate())
_Func->SetTextdrawColour(m_ID, -1, SQMOD_PACK_RGBA(r, g, b, a));
}
void CTextdraw::SetColorFor(CPlayer & player, const Color4 & col) const
{
if (!player.IsActive())
SqThrow("Invalid player argument: null");
else if (Validate())
_Func->SetTextdrawColour(m_ID, player.GetID(), col.GetRGBA());
}
void CTextdraw::SetColorForEx(CPlayer & player, Uint8 r, Uint8 g, Uint8 b, Uint8 a) const
{
if (!player.IsActive())
SqThrow("Invalid player argument: null");
else if (Validate())
_Func->SetTextdrawColour(m_ID, player.GetID(), SQMOD_PACK_RGBA(r, g, b, a));
}
void CTextdraw::SetColorRange(Int32 first, Int32 last, const Color4 & col) const
{
if (first > last)
SqThrow("Invalid player range: %d > %d", first, last);
else if (Validate())
for (const Uint32 color = col.GetRGBA(); first <= last; ++first)
{
if (_Func->IsPlayerConnected(first))
_Func->SetTextdrawColour(m_ID, first, color);
}
}
CSStr CTextdraw::GetText() const
{
if (Validate())
_Core->GetTextdraw(m_ID).mText.c_str();
return g_EmptyStr;
}
// ------------------------------------------------------------------------------------------------
static Object & CreateTextdrawEx(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 & CreateTextdrawEx(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 & CreateTextdrawEx(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 & CreateTextdrawEx(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 & CreateTextdraw(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 & CreateTextdraw(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 & CreateTextdraw(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 & CreateTextdraw(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);
}
// ================================================================================================
void Register_CTextdraw(HSQUIRRELVM vm)
{
RootTable(vm).Bind(_SC("SqTextdraw"),
Class< CTextdraw, NoConstructor< CTextdraw > >(vm, _SC("SqTextdraw"))
/* Metamethods */
.Func(_SC("_cmp"), &CTextdraw::Cmp)
.Func(_SC("_tostring"), &CTextdraw::ToString)
/* Core Properties */
.Prop(_SC("ID"), &CTextdraw::GetID)
.Prop(_SC("Tag"), &CTextdraw::GetTag, &CTextdraw::SetTag)
.Prop(_SC("Data"), &CTextdraw::GetData, &CTextdraw::SetData)
.Prop(_SC("MaxID"), &CTextdraw::GetMaxID)
.Prop(_SC("Active"), &CTextdraw::IsActive)
/* Core Functions */
.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)
/* Functions */
.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)
/* 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)
);
RootTable(vm)
.Overload< Object & (*)(CSStr, Int32, Int32, Uint8, Uint8, Uint8, Uint8, bool) >
(_SC("CreateTextdrawEx"), &CreateTextdrawEx)
.Overload< Object & (*)(CSStr, Int32, Int32, Uint8, Uint8, Uint8, Uint8, bool, Int32, Object &) >
(_SC("CreateTextdrawEx"), &CreateTextdrawEx)
.Overload< Object & (*)(Int32, CSStr, Int32, Int32, Uint8, Uint8, Uint8, Uint8, bool) >
(_SC("CreateTextdrawEx"), &CreateTextdrawEx)
.Overload< Object & (*)(Int32, CSStr, Int32, Int32, Uint8, Uint8, Uint8, Uint8, bool, Int32, Object &) >
(_SC("CreateTextdrawEx"), &CreateTextdrawEx)
.Overload< Object & (*)(CSStr, const Vector2i &, const Color4 &, bool) >
(_SC("CreateTextdraw"), &CreateTextdraw)
.Overload< Object & (*)(CSStr, const Vector2i &, const Color4 &, bool, Int32, Object &) >
(_SC("CreateTextdraw"), &CreateTextdraw)
.Overload< Object & (*)(Int32, CSStr, const Vector2i &, const Color4 &, bool) >
(_SC("CreateTextdraw"), &CreateTextdraw)
.Overload< Object & (*)(Int32, CSStr, const Vector2i &, const Color4 &, bool, Int32, Object &) >
(_SC("CreateTextdraw"), &CreateTextdraw);
}
} // Namespace:: SqMod

View File

@ -2,112 +2,144 @@
#define _ENTITY_TEXTDRAW_HPP_
// ------------------------------------------------------------------------------------------------
#include "Entity.hpp"
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Class responsible for managing the referenced textdraw instance.
* Manages Textdraw instances.
*/
class CTextdraw : public Reference< CTextdraw >
class CTextdraw
{
// --------------------------------------------------------------------------------------------
friend class Core;
private:
/* --------------------------------------------------------------------------------------------
* Cached identifiers for fast integer to string conversion.
*/
static SQChar s_StrID[SQMOD_TEXTDRAW_POOL][8];
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
*/
Int32 m_ID;
/* --------------------------------------------------------------------------------------------
* User tag and data associated with this instance.
*/
String m_Tag;
Object m_Data;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CTextdraw(Int32 id);
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
CTextdraw(const CTextdraw &);
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
CTextdraw & operator = (const CTextdraw &);
public:
/* --------------------------------------------------------------------------------------------
* Import the constructors, destructors and assignment operators from the base class.
*/
using RefType::Reference;
// --------------------------------------------------------------------------------------------
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* Construct a reference from a base reference.
* Destructor.
*/
CTextdraw(const Reference< CTextdraw > & o);
~CTextdraw();
/* --------------------------------------------------------------------------------------------
* Show the referenced textdraw instance to all players on the server.
* See whether this instance manages a valid entity.
*/
bool Validate() const
{
if (VALID_ENTITY(m_ID))
return true;
SqThrow("Invalid textdraw reference [%s]", m_Tag.c_str());
return false;
}
/* --------------------------------------------------------------------------------------------
* 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.
*/
CSStr ToString() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the identifier of the entity managed by this instance.
*/
Int32 GetID() const { return m_ID; }
/* --------------------------------------------------------------------------------------------
* Retrieve the maximum possible identifier to an entity of this type.
*/
Int32 GetMaxID() const { return SQMOD_TEXTDRAW_POOL; }
/* --------------------------------------------------------------------------------------------
* Check whether this instance manages a valid entity.
*/
bool IsActive() const { return VALID_ENTITY(m_ID); }
/* --------------------------------------------------------------------------------------------
* Retrieve the associated user tag.
*/
CSStr 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);
// --------------------------------------------------------------------------------------------
bool Destroy(Int32 header, Object & payload);
bool Destroy() { return Destroy(0, NullObject()); }
bool Destroy(Int32 header) { return Destroy(header, NullObject()); }
// --------------------------------------------------------------------------------------------
bool BindEvent(Int32 evid, Object & env, Function & func) const;
// --------------------------------------------------------------------------------------------
void ShowAll() const;
/* --------------------------------------------------------------------------------------------
* Show the referenced textdraw instance to the specified player instance.
*/
void ShowFor(const Reference< CPlayer > & player) const;
/* --------------------------------------------------------------------------------------------
* Show the referenced textdraw instance to all players in the specified range.
*/
void ShowRange(SQInt32 first, SQInt32 last) const;
/* --------------------------------------------------------------------------------------------
* Hide the referenced textdraw instance from all players on the server.
*/
void ShowFor(CPlayer & player) const;
void ShowRange(Int32 first, Int32 last) const;
void HideAll() const;
/* --------------------------------------------------------------------------------------------
* Hide the referenced textdraw instance from the specified player instance.
*/
void HideFor(const Reference< CPlayer > & player) const;
/* --------------------------------------------------------------------------------------------
* Hide the referenced textdraw instance from all players in the specified range.
*/
void HideRange(SQInt32 first, SQInt32 last) const;
/* --------------------------------------------------------------------------------------------
* Set the position of the referenced textdraw instance for all players on the server.
*/
void HideFor(CPlayer & player) const;
void HideRange(Int32 first, Int32 last) const;
void SetPositionAll(const Vector2i & pos) const;
/* --------------------------------------------------------------------------------------------
* Set the position of the referenced textdraw instance for all players on the server.
*/
void SetPositionAllEx(SQInt32 x, SQInt32 y) const;
/* --------------------------------------------------------------------------------------------
* Set the position of the referenced textdraw instance for the specified player instance.
*/
void SetPositionFor(const Reference< CPlayer > & player, const Vector2i & pos) const;
/* --------------------------------------------------------------------------------------------
* Set the position of the referenced textdraw instance for the specified player instance.
*/
void SetPositionForEx(const Reference< CPlayer > & player, SQInt32 x, SQInt32 y) const;
/* --------------------------------------------------------------------------------------------
* Set the position of the referenced textdraw instance for all players in the specified range.
*/
void SetPositionRange(SQInt32 first, SQInt32 last, const Vector2i & pos) const;
/* --------------------------------------------------------------------------------------------
* Set the center of the referenced textdraw instance for all players on the server.
*/
void SetPositionAllEx(Int32 x, Int32 y) const;
void SetPositionFor(CPlayer & player, const Vector2i & pos) const;
void SetPositionForEx(CPlayer & player, Int32 x, Int32 y) const;
void SetPositionRange(Int32 first, Int32 last, const Vector2i & pos) const;
void SetColorAll(const Color4 & col) const;
/* --------------------------------------------------------------------------------------------
* Set the color of the referenced textdraw instance for all players on the server.
*/
void SetColorAllEx(Uint8 r, Uint8 g, Uint8 b, Uint8 a) const;
/* --------------------------------------------------------------------------------------------
* Set the color of the referenced textdraw instance for the specified player instance.
*/
void SetColorFor(const Reference< CPlayer > & player, const Color4 & col) const;
/* --------------------------------------------------------------------------------------------
* Set the color of the referenced textdraw instance for the specified player instance.
*/
void SetColorForEx(const Reference< CPlayer > & player, Uint8 r, Uint8 g, Uint8 b, Uint8 a) const;
/* --------------------------------------------------------------------------------------------
* Set the color of the referenced textdraw instance for all players in the specified range.
*/
void SetColorRange(SQInt32 first, SQInt32 last, const Color4 & col) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the text string used by the referenced textdraw instance.
*/
const SQChar * GetText() const;
void SetColorFor(CPlayer & player, const Color4 & col) const;
void SetColorForEx(CPlayer & player, Uint8 r, Uint8 g, Uint8 b, Uint8 a) const;
void SetColorRange(Int32 first, Int32 last, const Color4 & col) const;
CSStr GetText() const;
};
} // Namespace:: SqMod

File diff suppressed because it is too large Load Diff

View File

@ -2,472 +2,246 @@
#define _ENTITY_VEHICLE_HPP_
// ------------------------------------------------------------------------------------------------
#include "Entity.hpp"
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Class responsible for managing the referenced vehicle instance.
* Manages Vehicle instances.
*/
class CVehicle : public Reference< CVehicle >
class CVehicle
{
// --------------------------------------------------------------------------------------------
static CAutomobile s_Automobile;
friend class Core;
private:
// --------------------------------------------------------------------------------------------
static Vector3 s_Vector3;
static Vector4 s_Vector4;
static Quaternion s_Quaternion;
/* --------------------------------------------------------------------------------------------
* Cached identifiers for fast integer to string conversion.
*/
static SQChar s_StrID[SQMOD_VEHICLE_POOL][8];
/* --------------------------------------------------------------------------------------------
* Identifier of the managed entity.
*/
Int32 m_ID;
/* --------------------------------------------------------------------------------------------
* User tag and data associated with this instance.
*/
String m_Tag;
Object m_Data;
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CVehicle(Int32 id);
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
CVehicle(const CVehicle &);
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
CVehicle & operator = (const CVehicle &);
public:
/* --------------------------------------------------------------------------------------------
* Import the constructors, destructors and assignment operators from the base class.
*/
using RefType::Reference;
// --------------------------------------------------------------------------------------------
static const Int32 Max;
/* --------------------------------------------------------------------------------------------
* Construct a reference from a base reference.
* Destructor.
*/
CVehicle(const Reference< CVehicle > & o);
~CVehicle();
/* --------------------------------------------------------------------------------------------
* See if the referenced vehicle instance is streamed for the specified player.
* See whether this instance manages a valid entity.
*/
bool IsStreamedFor(const Reference< CPlayer > & player) const;
bool Validate() const
{
if (VALID_ENTITY(m_ID))
return true;
SqThrow("Invalid vehicle reference [%s]", m_Tag.c_str());
return false;
}
/* --------------------------------------------------------------------------------------------
* Retrieve the synchronization source of the referenced vehicle instance.
* Used by the script engine to compare two instances of this type.
*/
SQInt32 GetSyncSource() const;
Int32 Cmp(const CVehicle & o) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the synchronization type of the referenced vehicle instance.
* Used by the script engine to convert an instance of this type to a string.
*/
SQInt32 GetSyncType() const;
CSStr ToString() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the world in which the referenced vehicle instance exists.
* Retrieve the identifier of the entity managed by this instance.
*/
SQInt32 GetWorld() const;
Int32 GetID() const { return m_ID; }
/* --------------------------------------------------------------------------------------------
* Change the world in which the referenced vehicle instance exists.
* Retrieve the maximum possible identifier to an entity of this type.
*/
void SetWorld(SQInt32 world) const;
Int32 GetMaxID() const { return SQMOD_VEHICLE_POOL; }
/* --------------------------------------------------------------------------------------------
* Retrieve the vehicle model of the referenced vehicle instance.
* Check whether this instance manages a valid entity.
*/
const CAutomobile & GetModel() const;
bool IsActive() const { return VALID_ENTITY(m_ID); }
/* --------------------------------------------------------------------------------------------
* Retrieve the vehicle model id of the referenced vehicle instance.
* Retrieve the associated user tag.
*/
SQInt32 GetModelID() const;
CSStr GetTag() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the slot occupant from the referenced vehicle instance.
* Modify the associated user tag.
*/
Reference< CPlayer > GetOccupant(SQInt32 slot) const;
void SetTag(CSStr tag);
/* --------------------------------------------------------------------------------------------
* Retrieve the slot occupant identifier from the referenced vehicle instance.
* Retrieve the associated user data.
*/
SQInt32 GetOccupantID(SQInt32 slot) const;
Object & GetData();
/* --------------------------------------------------------------------------------------------
* Respawn the referenced vehicle instance.
* Modify the associated user data.
*/
void SetData(Object & data);
// --------------------------------------------------------------------------------------------
bool Destroy(Int32 header, Object & payload);
bool Destroy() { return Destroy(0, NullObject()); }
bool Destroy(Int32 header) { return Destroy(header, NullObject()); }
// --------------------------------------------------------------------------------------------
bool BindEvent(Int32 evid, Object & env, Function & func) const;
// --------------------------------------------------------------------------------------------
bool IsStreamedFor(CPlayer & player) const;
Int32 GetSyncSource() const;
Int32 GetSyncType() const;
Int32 GetWorld() const;
void SetWorld(Int32 world) const;
Int32 GetModel() const;
Object & GetOccupant(Int32 slot) const;
Int32 GetOccupantID(Int32 slot) const;
void Respawn() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the immunity flags of the referenced vehicle instance.
*/
SQInt32 GetImmunity() const;
/* --------------------------------------------------------------------------------------------
* Change the immunity flags of the referenced vehicle instance.
*/
void SetImmunity(SQInt32 flags) const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced vehicle instance is wrecked.
*/
Int32 GetImmunity() const;
void SetImmunity(Int32 flags) const;
bool IsWrecked() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the position of the referenced vehicle instance.
*/
const Vector3 & GetPosition() const;
/* --------------------------------------------------------------------------------------------
* Change the position of the referenced vehicle instance.
*/
void SetPosition(const Vector3 & pos) const;
/* --------------------------------------------------------------------------------------------
* Change the position of the referenced vehicle instance.
*/
void SetPositionEx(const Vector3 & pos, bool empty) const;
/* --------------------------------------------------------------------------------------------
* Change the position of the referenced vehicle instance.
*/
void SetPositionEx(SQFloat x, SQFloat y, SQFloat z) const;
/* --------------------------------------------------------------------------------------------
* Change the position of the referenced vehicle instance.
*/
void SetPositionEx(SQFloat x, SQFloat y, SQFloat z, bool empty) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the rotation of the referenced vehicle instance.
*/
void SetPositionEx(Float32 x, Float32 y, Float32 z) const;
void SetPositionEx(Float32 x, Float32 y, Float32 z, bool empty) const;
const Quaternion & GetRotation() const;
/* --------------------------------------------------------------------------------------------
* Change the rotation of the referenced vehicle instance.
*/
void SetRotation(const Quaternion & rot) const;
/* --------------------------------------------------------------------------------------------
* Change the rotation of the referenced vehicle instance.
*/
void SetRotationEx(SQFloat x, SQFloat y, SQFloat z, SQFloat w) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the euler rotation of the referenced vehicle instance.
*/
void SetRotationEx(Float32 x, Float32 y, Float32 z, Float32 w) const;
const Vector3 & GetRotationEuler() const;
/* --------------------------------------------------------------------------------------------
* Change the euler rotation of the referenced vehicle instance.
*/
void SetRotationEuler(const Vector3 & rot) const;
/* --------------------------------------------------------------------------------------------
* Change the euler rotation of the referenced vehicle instance.
*/
void SetRotationEulerEx(SQFloat x, SQFloat y, SQFloat z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the speed of the referenced vehicle instance.
*/
void SetRotationEulerEx(Float32 x, Float32 y, Float32 z) const;
const Vector3 & GetSpeed() const;
/* --------------------------------------------------------------------------------------------
* Change the speed of the referenced vehicle instance.
*/
void SetSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Change the speed of the referenced vehicle instance.
*/
void SetSpeedEx(SQFloat x, SQFloat y, SQFloat z) const;
/* --------------------------------------------------------------------------------------------
* Change the speed of the referenced vehicle instance.
*/
void SetSpeedEx(Float32 x, Float32 y, Float32 z) const;
void AddSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Change the speed of the referenced vehicle instance.
*/
void AddSpeedEx(SQFloat x, SQFloat y, SQFloat z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the relative speed of the referenced vehicle instance.
*/
void AddSpeedEx(Float32 x, Float32 y, Float32 z) const;
const Vector3 & GetRelSpeed() const;
/* --------------------------------------------------------------------------------------------
* Change the relative speed of the referenced vehicle instance.
*/
void SetRelSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Change the relative speed of the referenced vehicle instance.
*/
void SetRelSpeedEx(SQFloat x, SQFloat y, SQFloat z) const;
/* --------------------------------------------------------------------------------------------
* Change the relative speed of the referenced vehicle instance.
*/
void SetRelSpeedEx(Float32 x, Float32 y, Float32 z) const;
void AddRelSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Change the relative speed of the referenced vehicle instance.
*/
void AddRelSpeedEx(SQFloat x, SQFloat y, SQFloat z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the turn speed of the referenced vehicle instance.
*/
void AddRelSpeedEx(Float32 x, Float32 y, Float32 z) const;
const Vector3 & GetTurnSpeed() const;
/* --------------------------------------------------------------------------------------------
* Change the turn speed of the referenced vehicle instance.
*/
void SetTurnSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Change the turn speed of the referenced vehicle instance.
*/
void SetTurnSpeedEx(SQFloat x, SQFloat y, SQFloat z) const;
/* --------------------------------------------------------------------------------------------
* Change the turn speed of the referenced vehicle instance.
*/
void SetTurnSpeedEx(Float32 x, Float32 y, Float32 z) const;
void AddTurnSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Change the turn speed of the referenced vehicle instance.
*/
void AddTurnSpeedEx(SQFloat x, SQFloat y, SQFloat z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the relative turn speed of the referenced vehicle instance.
*/
void AddTurnSpeedEx(Float32 x, Float32 y, Float32 z) const;
const Vector3 & GetRelTurnSpeed() const;
/* --------------------------------------------------------------------------------------------
* Change the relative turn speed of the referenced vehicle instance.
*/
void SetRelTurnSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Change the relative turn speed of the referenced vehicle instance.
*/
void SetRelTurnSpeedEx(SQFloat x, SQFloat y, SQFloat z) const;
/* --------------------------------------------------------------------------------------------
* Change the relative turn speed of the referenced vehicle instance.
*/
void SetRelTurnSpeedEx(Float32 x, Float32 y, Float32 z) const;
void AddRelTurnSpeed(const Vector3 & vel) const;
/* --------------------------------------------------------------------------------------------
* Change the relative turn speed of the referenced vehicle instance.
*/
void AddRelTurnSpeedEx(SQFloat x, SQFloat y, SQFloat z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the spawn position of the referenced vehicle instance.
*/
void AddRelTurnSpeedEx(Float32 x, Float32 y, Float32 z) const;
const Vector4 & GetSpawnPosition() const;
/* --------------------------------------------------------------------------------------------
* Change the spawn position of the referenced vehicle instance.
*/
void SetSpawnPosition(const Vector4 & pos) const;
/* --------------------------------------------------------------------------------------------
* Change the spawn position of the referenced vehicle instance.
*/
void SetSpawnPositionEx(SQFloat x, SQFloat y, SQFloat z, SQFloat w) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the spawn rotation of the referenced vehicle instance.
*/
void SetSpawnPositionEx(Float32 x, Float32 y, Float32 z, Float32 w) const;
const Quaternion & GetSpawnRotation() const;
/* --------------------------------------------------------------------------------------------
* Change the spawn rotation of the referenced vehicle instance.
*/
void SetSpawnRotation(const Quaternion & rot) const;
/* --------------------------------------------------------------------------------------------
* Change the spawn rotation of the referenced vehicle instance.
*/
void SetSpawnRotationEx(SQFloat x, SQFloat y, SQFloat z, SQFloat w) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the euler spawn rotation of the referenced vehicle instance.
*/
void SetSpawnRotationEx(Float32 x, Float32 y, Float32 z, Float32 w) const;
const Vector3 & GetSpawnRotationEuler() const;
/* --------------------------------------------------------------------------------------------
* Change the euler spawn rotation of the referenced vehicle instance.
*/
void SetSpawnRotationEuler(const Vector3 & rot) const;
/* --------------------------------------------------------------------------------------------
* Change the euler spawn rotation of the referenced vehicle instance.
*/
void SetSpawnRotationEulerEx(SQFloat x, SQFloat y, SQFloat z) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the respawn timer of the referenced vehicle instance.
*/
SQUint32 GetRespawnTimer() const;
/* --------------------------------------------------------------------------------------------
* Change the respawn timer of the referenced vehicle instance.
*/
void SetRespawnTimer(SQUint32 timer) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the health of the referenced vehicle instance.
*/
SQFloat GetHealth() const;
/* --------------------------------------------------------------------------------------------
* Change the health of the referenced vehicle instance.
*/
void SetHealth(SQFloat amount) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the primary color of the referenced vehicle instance.
*/
SQInt32 GetPrimaryColor() const;
/* --------------------------------------------------------------------------------------------
* Change the primary color of the referenced vehicle instance.
*/
void SetPrimaryColor(SQInt32 col) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the secondary color of the referenced vehicle instance.
*/
SQInt32 GetSecondaryColor() const;
/* --------------------------------------------------------------------------------------------
* Change the secondary color of the referenced vehicle instance.
*/
void SetSecondaryColor(SQInt32 col) const;
/* --------------------------------------------------------------------------------------------
* Change the primary and secondary colors of the referenced vehicle instance.
*/
void SetColors(SQInt32 primary, SQInt32 secondary) const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced vehicle instance is locked.
*/
void SetSpawnRotationEulerEx(Float32 x, Float32 y, Float32 z) const;
Uint32 GetRespawnTimer() const;
void SetRespawnTimer(Uint32 timer) const;
Float32 GetHealth() const;
void SetHealth(Float32 amount) const;
Int32 GetPrimaryColor() const;
void SetPrimaryColor(Int32 col) const;
Int32 GetSecondaryColor() const;
void SetSecondaryColor(Int32 col) const;
void SetColors(Int32 primary, Int32 secondary) const;
bool GetLocked() const;
/* --------------------------------------------------------------------------------------------
* Set whether the referenced vehicle instance is locked.
*/
void SetLocked(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the part status of the referenced vehicle instance.
*/
SQInt32 GetPartStatus(SQInt32 part) const;
/* --------------------------------------------------------------------------------------------
* Change the part status of the referenced vehicle instance.
*/
void SetPartStatus(SQInt32 part, SQInt32 status) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the tyre status of the referenced vehicle instance.
*/
SQInt32 GetTyreStatus(SQInt32 tyre) const;
/* --------------------------------------------------------------------------------------------
* Change the tyre status of the referenced vehicle instance.
*/
void SetTyreStatus(SQInt32 tyre, SQInt32 status) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the damage data of the referenced vehicle instance.
*/
SQUint32 GetDamageData() const;
/* --------------------------------------------------------------------------------------------
* Change the damage data of the referenced vehicle instance.
*/
void SetDamageData(SQUint32 data) const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced vehicle instance has alarm.
*/
Int32 GetPartStatus(Int32 part) const;
void SetPartStatus(Int32 part, Int32 status) const;
Int32 GetTyreStatus(Int32 tyre) const;
void SetTyreStatus(Int32 tyre, Int32 status) const;
Uint32 GetDamageData() const;
void SetDamageData(Uint32 data) const;
bool GetAlarm() const;
/* --------------------------------------------------------------------------------------------
* Set whether the referenced vehicle instance has alarm.
*/
void SetAlarm(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced vehicle instance has lights.
*/
bool GetLights() const;
/* --------------------------------------------------------------------------------------------
* Set whether the referenced vehicle instance has lights.
*/
void SetLights(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the radio of the referenced vehicle instance.
*/
SQInt32 GetRadio() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the radio of the referenced vehicle instance.
*/
void SetRadio(SQInt32 radio) const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced vehicle instance has radio locked.
*/
Int32 GetRadio() const;
void SetRadio(Int32 radio) const;
bool GetRadioLocked() const;
/* --------------------------------------------------------------------------------------------
* Set whether the referenced vehicle instance has radio locked.
*/
void SetRadioLocked(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* See whether the referenced vehicle instance is in ghost state.
*/
bool GetGhostState() const;
/* --------------------------------------------------------------------------------------------
* Set whether the referenced vehicle instance is in ghost state.
*/
void SetGhostState(bool toggle) const;
/* --------------------------------------------------------------------------------------------
* Reset all the handling rules for the referenced vehicle instance.
*/
void ResetHandling() const;
void ResetHandling(Int32 rule) const;
bool ExistsHandling(Int32 rule) const;
Float32 GetHandlingData(Int32 rule) const;
void SetHandlingData(Int32 rule, Float32 data) const;
void Embark(CPlayer & player) const;
void Embark(CPlayer & player, Int32 slot, bool allocate, bool warp) const;
/* --------------------------------------------------------------------------------------------
* Reset the specified handling rule for the referenced vehicle instance.
*/
void ResetHandling(SQInt32 rule) const;
// --------------------------------------------------------------------------------------------
Float32 GetPosX() const;
Float32 GetPosY() const;
Float32 GetPosZ() const;
void SetPosX(Float32 x) const;
void SetPosY(Float32 y) const;
void SetPosZ(Float32 z) const;
/* --------------------------------------------------------------------------------------------
* See whether the specified handling ruleexists in the referenced vehicle instance.
*/
bool ExistsHandling(SQInt32 rule) const;
// --------------------------------------------------------------------------------------------
Float32 GetRotX() const;
Float32 GetRotY() const;
Float32 GetRotZ() const;
Float32 GetRotW() const;
void SetRotX(Float32 x) const;
void SetRotY(Float32 y) const;
void SetRotZ(Float32 z) const;
void SetRotW(Float32 w) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the handling data of the referenced vehicle instance.
*/
SQFloat GetHandlingData(SQInt32 rule) const;
/* --------------------------------------------------------------------------------------------
* Change the handling data of the referenced vehicle instance.
*/
void SetHandlingData(SQInt32 rule, SQFloat data) const;
/* --------------------------------------------------------------------------------------------
* Embark the specified player instance into the referenced vehicle instance.
*/
void Embark(const Reference< CPlayer > & player) const;
/* --------------------------------------------------------------------------------------------
* Embark the specified player instance into the referenced vehicle instance.
*/
void Embark(const Reference< CPlayer > & player, SQInt32 slot, bool allocate, bool warp) const;
// --------------------------------------------------------------------------------------------
Float32 GetERotX() const;
Float32 GetERotY() const;
Float32 GetERotZ() const;
void SetERotX(Float32 x) const;
void SetERotY(Float32 y) const;
void SetERotZ(Float32 z) const;
};
} // Namespace:: SqMod
#endif // _ENTITY_VEHICLE_HPP_
#endif // _ENTITY_VEHICLE_HPP_