2015-11-11 07:57:03 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-09-30 02:56:11 +02:00
|
|
|
#include "Entity/Blip.hpp"
|
2015-11-01 00:31:28 +01:00
|
|
|
#include "Core.hpp"
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
2015-11-01 00:31:28 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
const Int32 CBlip::Max = SQMOD_BLIP_POOL;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
SQInteger CBlip::Typename(HSQUIRRELVM vm)
|
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
static const SQChar name[] = _SC("SqBlip");
|
2016-03-10 04:57:13 +01:00
|
|
|
sq_pushstring(vm, name, sizeof(name));
|
|
|
|
return 1;
|
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
CBlip::CBlip(Int32 id)
|
|
|
|
: m_ID(VALID_ENTITYGETEX(id, SQMOD_BLIP_POOL))
|
2016-03-10 04:57:13 +01:00
|
|
|
, m_Tag(ToStrF("%d", id))
|
2015-11-01 00:31:28 +01:00
|
|
|
{
|
|
|
|
/* ... */
|
|
|
|
}
|
|
|
|
|
2015-09-30 02:56:11 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
CBlip::~CBlip()
|
2015-10-29 21:07:15 +01:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
/* ... */
|
2015-10-29 21:07:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 CBlip::Cmp(const CBlip & o) const
|
2015-10-29 21:07:15 +01:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
if (m_ID == o.m_ID)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return 0;
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
else if (m_ID > o.m_ID)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return 1;
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2015-10-29 21:07:15 +01:00
|
|
|
else
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return -1;
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
2015-11-11 07:57:03 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const String & CBlip::ToString() const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return m_Tag;
|
2015-10-29 21:07:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
const String & CBlip::GetTag() const
|
2015-10-29 21:07:15 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return m_Tag;
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
2015-10-29 21:07:15 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CBlip::SetTag(CSStr tag)
|
|
|
|
{
|
|
|
|
m_Tag.assign(tag);
|
2015-10-29 21:07:15 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Object & CBlip::GetData()
|
2015-10-29 21:07:15 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return m_Data;
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
2015-10-29 21:07:15 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CBlip::SetData(Object & data)
|
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Apply the specified value
|
|
|
|
m_Data = data;
|
2015-10-29 21:07:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
bool CBlip::Destroy(Int32 header, Object & payload)
|
2015-10-29 21:07:15 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().DelBlip(m_ID, header, payload);
|
2015-10-29 21:07:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
void CBlip::BindEvent(Int32 evid, Object & env, Function & func) const
|
2015-10-29 21:07:15 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Obtain the function instance called for this event
|
2016-05-22 05:20:38 +02:00
|
|
|
Function & event = Core::Get().GetBlipEvent(m_ID, evid);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Is the specified callback function null?
|
2016-02-20 23:25:00 +01:00
|
|
|
if (func.IsNull())
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-05-24 20:36:49 +02:00
|
|
|
event.ReleaseGently(); // Then release the current callback
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-05-24 06:29:14 +02:00
|
|
|
// Does this function need a custom environment?
|
|
|
|
else if (env.IsNull())
|
|
|
|
{
|
|
|
|
event = func;
|
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Assign the specified environment and function
|
2015-10-29 21:07:15 +01:00
|
|
|
else
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
event = Function(env.GetVM(), env, func.GetFunc());
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2015-10-29 21:07:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 CBlip::GetWorld() const
|
2015-10-29 21:07:15 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetBlip(m_ID).mWorld;
|
2015-10-29 21:07:15 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 CBlip::GetScale() const
|
2015-10-29 21:07:15 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetBlip(m_ID).mScale;
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
2015-10-29 21:07:15 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
const Vector3 & CBlip::GetPosition() const
|
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetBlip(m_ID).mPosition;
|
2015-10-29 21:07:15 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
const Color4 & CBlip::GetColor() const
|
2015-11-01 00:31:28 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetBlip(m_ID).mColor;
|
2015-11-01 00:31:28 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 CBlip::GetSprID() const
|
2015-11-01 00:31:28 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetBlip(m_ID).mSprID;
|
2015-11-01 00:31:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Float32 CBlip::GetPositionX() const
|
2015-11-01 00:31:28 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetBlip(m_ID).mPosition.x;
|
2015-11-01 00:31:28 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Float32 CBlip::GetPositionY() const
|
2015-11-01 00:31:28 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetBlip(m_ID).mPosition.y;
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Float32 CBlip::GetPositionZ() const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetBlip(m_ID).mPosition.z;
|
2015-11-01 00:31:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 CBlip::GetColorR() const
|
2015-11-01 00:31:28 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetBlip(m_ID).mColor.r;
|
2015-11-01 00:31:28 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 CBlip::GetColorG() const
|
2015-11-01 00:31:28 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetBlip(m_ID).mColor.g;
|
2015-11-01 00:31:28 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 CBlip::GetColorB() const
|
2015-11-01 00:31:28 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetBlip(m_ID).mColor.b;
|
2015-11-01 00:31:28 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 CBlip::GetColorA() const
|
2015-11-01 00:31:28 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetBlip(m_ID).mColor.a;
|
2015-11-01 00:31:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
static Object & Blip_CreateEx(Int32 world, Float32 x, Float32 y, Float32 z, Int32 scale,
|
2016-02-20 23:25:00 +01:00
|
|
|
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Int32 sprid)
|
2015-11-01 00:31:28 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().NewBlip(-1, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
|
2016-02-20 23:25:00 +01:00
|
|
|
SQMOD_CREATE_DEFAULT, NullObject());
|
2015-11-01 00:31:28 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
static Object & Blip_CreateEx(Int32 world, Float32 x, Float32 y, Float32 z, Int32 scale,
|
2016-02-20 23:25:00 +01:00
|
|
|
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Int32 sprid,
|
|
|
|
Int32 header, Object & payload)
|
2015-11-01 00:31:28 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().NewBlip(-1, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
|
2015-11-01 00:31:28 +01:00
|
|
|
header, payload);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
static Object & Blip_CreateEx(Int32 index, Int32 world, Float32 x, Float32 y, Float32 z,
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 scale, Uint8 r, Uint8 g, Uint8 b, Uint8 a, Int32 sprid)
|
2015-11-01 00:31:28 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().NewBlip(index, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
|
2016-02-20 23:25:00 +01:00
|
|
|
SQMOD_CREATE_DEFAULT, NullObject());
|
2015-11-01 00:31:28 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
static Object & Blip_CreateEx(Int32 index, Int32 world, Float32 x, Float32 y, Float32 z, Int32 scale,
|
2016-02-20 23:25:00 +01:00
|
|
|
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Int32 sprid,
|
|
|
|
Int32 header, Object & payload)
|
2015-11-01 00:31:28 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().NewBlip(index, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
|
2015-11-01 00:31:28 +01:00
|
|
|
header, payload);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
static Object & Blip_Create(Int32 world, const Vector3 & pos, Int32 scale, const Color4 & color,
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 sprid)
|
2015-11-01 00:31:28 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().NewBlip(-1, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
|
2016-02-20 23:25:00 +01:00
|
|
|
SQMOD_CREATE_DEFAULT, NullObject());
|
2015-11-01 00:31:28 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
static Object & Blip_Create(Int32 world, const Vector3 & pos, Int32 scale, const Color4 & color,
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 sprid, Int32 header, Object & payload)
|
2015-11-01 00:31:28 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().NewBlip(-1, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
|
2015-11-01 00:31:28 +01:00
|
|
|
header, payload);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
static Object & Blip_Create(Int32 index, Int32 world, const Vector3 & pos, Int32 scale,
|
2016-02-20 23:25:00 +01:00
|
|
|
const Color4 & color, Int32 sprid)
|
2015-11-01 00:31:28 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().NewBlip(index, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
|
2016-02-20 23:25:00 +01:00
|
|
|
SQMOD_CREATE_DEFAULT, NullObject());
|
2015-11-01 00:31:28 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
static Object & Blip_Create(Int32 index, Int32 world, const Vector3 & pos, Int32 scale,
|
2016-02-20 23:25:00 +01:00
|
|
|
const Color4 & color, Int32 sprid, Int32 header, Object & payload)
|
2015-11-01 00:31:28 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().NewBlip(index, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprid,
|
2015-11-01 00:31:28 +01:00
|
|
|
header, payload);
|
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
static const Object & Blip_FindByID(Int32 id)
|
|
|
|
{
|
|
|
|
// Perform a range check on the specified identifier
|
|
|
|
if (INVALID_ENTITYEX(id, SQMOD_BLIP_POOL))
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("The specified blip identifier is invalid: %d", id);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Obtain the ends of the entity pool
|
2016-05-22 05:20:38 +02:00
|
|
|
Core::Blips::const_iterator itr = Core::Get().GetBlips().cbegin();
|
|
|
|
Core::Blips::const_iterator end = Core::Get().GetBlips().cend();
|
2016-03-10 04:57:13 +01:00
|
|
|
// Process each entity in the pool
|
|
|
|
for (; itr != end; ++itr)
|
|
|
|
{
|
|
|
|
// Does the identifier match the specified one?
|
|
|
|
if (itr->mID == id)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return itr->mObj; // Stop searching and return this entity
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
}
|
|
|
|
// Unable to locate a blip matching the specified identifier
|
|
|
|
return NullObject();
|
|
|
|
}
|
|
|
|
|
|
|
|
static const Object & Blip_FindByTag(CSStr tag)
|
|
|
|
{
|
|
|
|
// Perform a validity check on the specified tag
|
2016-03-12 21:51:44 +01:00
|
|
|
if (!tag || *tag == '\0')
|
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("The specified blip tag is invalid: null/empty");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Obtain the ends of the entity pool
|
2016-05-22 05:20:38 +02:00
|
|
|
Core::Blips::const_iterator itr = Core::Get().GetBlips().cbegin();
|
|
|
|
Core::Blips::const_iterator end = Core::Get().GetBlips().cend();
|
2016-03-10 04:57:13 +01:00
|
|
|
// Process each entity in the pool
|
|
|
|
for (; itr != end; ++itr)
|
|
|
|
{
|
|
|
|
// Does this entity even exist and does the tag match the specified one?
|
|
|
|
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return itr->mObj; // Stop searching and return this entity
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
}
|
|
|
|
// Unable to locate a blip matching the specified tag
|
|
|
|
return NullObject();
|
|
|
|
}
|
|
|
|
|
2016-03-10 05:18:39 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
static const Object & Blip_FindBySprID(Int32 sprid)
|
|
|
|
{
|
|
|
|
// Perform a range check on the specified identifier
|
|
|
|
if (sprid < 0)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("The specified sprite identifier is invalid: %d", sprid);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 05:18:39 +01:00
|
|
|
// Obtain the ends of the entity pool
|
2016-05-22 05:20:38 +02:00
|
|
|
Core::Blips::const_iterator itr = Core::Get().GetBlips().cbegin();
|
|
|
|
Core::Blips::const_iterator end = Core::Get().GetBlips().cend();
|
2016-03-10 05:18:39 +01:00
|
|
|
// Process each entity in the pool
|
|
|
|
for (; itr != end; ++itr)
|
|
|
|
{
|
|
|
|
// Does the identifier match the specified one?
|
|
|
|
if (itr->mSprID == sprid)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 05:18:39 +01:00
|
|
|
return itr->mObj; // Stop searching and return this entity
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 05:18:39 +01:00
|
|
|
}
|
|
|
|
// Unable to locate a blip matching the specified identifier
|
|
|
|
return NullObject();
|
|
|
|
}
|
|
|
|
|
2016-03-26 17:16:18 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
static Array Blip_FindActive()
|
|
|
|
{
|
|
|
|
// Remember the initial stack size
|
|
|
|
StackGuard sg;
|
|
|
|
// Obtain the ends of the entity pool
|
2016-05-22 05:20:38 +02:00
|
|
|
Core::Blips::const_iterator itr = Core::Get().GetBlips().cbegin();
|
|
|
|
Core::Blips::const_iterator end = Core::Get().GetBlips().cend();
|
2016-03-26 17:16:18 +01:00
|
|
|
// Allocate an empty array on the stack
|
|
|
|
sq_newarray(DefaultVM::Get(), 0);
|
|
|
|
// Process each entity in the pool
|
|
|
|
for (; itr != end; ++itr)
|
|
|
|
{
|
|
|
|
// Is this entity instance active?
|
|
|
|
if (VALID_ENTITY(itr->mID))
|
|
|
|
{
|
|
|
|
// Push the script object on the stack
|
|
|
|
sq_pushobject(DefaultVM::Get(), (HSQOBJECT &)((*itr).mObj));
|
|
|
|
// Append the object at the back of the array
|
|
|
|
if (SQ_FAILED(sq_arrayappend(DefaultVM::Get(), -1)))
|
|
|
|
{
|
|
|
|
STHROWF("Unable to append entity instance to the list");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Return the array at the top of the stack
|
|
|
|
return Var< Array >(DefaultVM::Get(), -1).value;
|
|
|
|
}
|
|
|
|
|
2015-10-29 21:07:15 +01:00
|
|
|
// ================================================================================================
|
2016-02-20 23:25:00 +01:00
|
|
|
void Register_CBlip(HSQUIRRELVM vm)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
RootTable(vm).Bind(_SC("SqBlip"),
|
|
|
|
Class< CBlip, NoConstructor< CBlip > >(vm, _SC("SqBlip"))
|
2016-06-03 20:26:19 +02:00
|
|
|
// Meta-methods
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("_cmp"), &CBlip::Cmp)
|
2016-03-10 04:57:13 +01:00
|
|
|
.SquirrelFunc(_SC("_typename"), &CBlip::Typename)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("_tostring"), &CBlip::ToString)
|
2016-03-10 05:18:39 +01:00
|
|
|
// Static Values
|
2016-03-10 04:57:13 +01:00
|
|
|
.SetStaticValue(_SC("MaxID"), CBlip::Max)
|
|
|
|
// Core Properties
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("ID"), &CBlip::GetID)
|
|
|
|
.Prop(_SC("Tag"), &CBlip::GetTag, &CBlip::SetTag)
|
|
|
|
.Prop(_SC("Data"), &CBlip::GetData, &CBlip::SetData)
|
|
|
|
.Prop(_SC("Active"), &CBlip::IsActive)
|
2016-03-10 05:18:39 +01:00
|
|
|
// Core Methods
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("Bind"), &CBlip::BindEvent)
|
2016-03-10 04:57:13 +01:00
|
|
|
// Core Overloads
|
2016-02-20 23:25:00 +01:00
|
|
|
.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)
|
2016-03-10 04:57:13 +01:00
|
|
|
// Properties
|
2016-02-20 23:25:00 +01:00
|
|
|
.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)
|
2016-06-12 23:23:30 +02:00
|
|
|
.Prop(_SC("Colour"), &CBlip::GetColor)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("SprID"), &CBlip::GetSprID)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Prop(_SC("PosX"), &CBlip::GetPositionX)
|
|
|
|
.Prop(_SC("PosY"), &CBlip::GetPositionY)
|
|
|
|
.Prop(_SC("PosZ"), &CBlip::GetPositionZ)
|
|
|
|
.Prop(_SC("Red"), &CBlip::GetColorR)
|
|
|
|
.Prop(_SC("Green"), &CBlip::GetColorG)
|
|
|
|
.Prop(_SC("Blue"), &CBlip::GetColorB)
|
|
|
|
.Prop(_SC("Alpha"), &CBlip::GetColorA)
|
2016-03-10 05:18:39 +01:00
|
|
|
// Static Functions
|
|
|
|
.StaticFunc(_SC("FindByID"), &Blip_FindByID)
|
|
|
|
.StaticFunc(_SC("FindByTag"), &Blip_FindByTag)
|
2016-03-26 17:16:18 +01:00
|
|
|
.StaticFunc(_SC("FindActive"), &Blip_FindActive)
|
2016-03-10 05:18:39 +01:00
|
|
|
.StaticFunc(_SC("FindBySprID"), &Blip_FindBySprID)
|
2016-03-10 04:57:13 +01:00
|
|
|
// Static Overloads
|
|
|
|
.StaticOverload< Object & (*)(Int32, Float32, Float32, Float32, Int32, Uint8, Uint8, Uint8, Uint8, Int32) >
|
|
|
|
(_SC("CreateEx"), &Blip_CreateEx)
|
|
|
|
.StaticOverload< Object & (*)(Int32, Float32, Float32, Float32, Int32, Uint8, Uint8, Uint8, Uint8, Int32, Int32, Object &) >
|
|
|
|
(_SC("CreateEx"), &Blip_CreateEx)
|
|
|
|
.StaticOverload< Object & (*)(Int32, Int32, Float32, Float32, Float32, Int32, Uint8, Uint8, Uint8, Uint8, Int32) >
|
|
|
|
(_SC("CreateEx"), &Blip_CreateEx)
|
|
|
|
.StaticOverload< Object & (*)(Int32, Int32, Float32, Float32, Float32, Int32, Uint8, Uint8, Uint8, Uint8, Int32, Int32, Object &) >
|
|
|
|
(_SC("CreateEx"), &Blip_CreateEx)
|
|
|
|
.StaticOverload< Object & (*)(Int32, const Vector3 &, Int32, const Color4 &, Int32) >
|
|
|
|
(_SC("Create"), &Blip_Create)
|
|
|
|
.StaticOverload< Object & (*)(Int32, const Vector3 &, Int32, const Color4 &, Int32, Int32, Object &) >
|
|
|
|
(_SC("Create"), &Blip_Create)
|
|
|
|
.StaticOverload< Object & (*)(Int32, Int32, const Vector3 &, Int32, const Color4 &, Int32) >
|
|
|
|
(_SC("Create"), &Blip_Create)
|
|
|
|
.StaticOverload< Object & (*)(Int32, Int32, const Vector3 &, Int32, const Color4 &, Int32, Int32, Object &) >
|
|
|
|
(_SC("Create"), &Blip_Create)
|
2015-09-30 02:56:11 +02:00
|
|
|
);
|
2016-03-10 04:57:13 +01:00
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
} // Namespace:: SqMod
|