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

Implemented searching entities by ID and Tag.

This commit is contained in:
Sandu Liviu Catalin 2016-03-10 06:18:39 +02:00
parent 70e5f0ba21
commit 58891f1e8b
10 changed files with 436 additions and 34 deletions

View File

@ -310,6 +310,26 @@ static const Object & Blip_FindByTag(CSStr tag)
return NullObject(); return NullObject();
} }
// ------------------------------------------------------------------------------------------------
static const Object & Blip_FindBySprID(Int32 sprid)
{
// Perform a range check on the specified identifier
if (sprid < 0)
SqThrowF("The specified sprite identifier is invalid: %d", sprid);
// Obtain the ends of the entity pool
Core::Blips::const_iterator itr = _Core->GetBlips().cbegin();
Core::Blips::const_iterator end = _Core->GetBlips().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does the identifier match the specified one?
if (itr->mSprID == sprid)
return itr->mObj; // Stop searching and return this entity
}
// Unable to locate a blip matching the specified identifier
return NullObject();
}
// ================================================================================================ // ================================================================================================
void Register_CBlip(HSQUIRRELVM vm) void Register_CBlip(HSQUIRRELVM vm)
{ {
@ -319,14 +339,14 @@ void Register_CBlip(HSQUIRRELVM vm)
.Func(_SC("_cmp"), &CBlip::Cmp) .Func(_SC("_cmp"), &CBlip::Cmp)
.SquirrelFunc(_SC("_typename"), &CBlip::Typename) .SquirrelFunc(_SC("_typename"), &CBlip::Typename)
.Func(_SC("_tostring"), &CBlip::ToString) .Func(_SC("_tostring"), &CBlip::ToString)
// Static values // Static Values
.SetStaticValue(_SC("MaxID"), CBlip::Max) .SetStaticValue(_SC("MaxID"), CBlip::Max)
// Core Properties // Core Properties
.Prop(_SC("ID"), &CBlip::GetID) .Prop(_SC("ID"), &CBlip::GetID)
.Prop(_SC("Tag"), &CBlip::GetTag, &CBlip::SetTag) .Prop(_SC("Tag"), &CBlip::GetTag, &CBlip::SetTag)
.Prop(_SC("Data"), &CBlip::GetData, &CBlip::SetData) .Prop(_SC("Data"), &CBlip::GetData, &CBlip::SetData)
.Prop(_SC("Active"), &CBlip::IsActive) .Prop(_SC("Active"), &CBlip::IsActive)
// Core Functions // Core Methods
.Func(_SC("Bind"), &CBlip::BindEvent) .Func(_SC("Bind"), &CBlip::BindEvent)
// Core Overloads // Core Overloads
.Overload< bool (CBlip::*)(void) >(_SC("Destroy"), &CBlip::Destroy) .Overload< bool (CBlip::*)(void) >(_SC("Destroy"), &CBlip::Destroy)
@ -346,6 +366,10 @@ void Register_CBlip(HSQUIRRELVM vm)
.Prop(_SC("G"), &CBlip::GetColorG) .Prop(_SC("G"), &CBlip::GetColorG)
.Prop(_SC("B"), &CBlip::GetColorB) .Prop(_SC("B"), &CBlip::GetColorB)
.Prop(_SC("A"), &CBlip::GetColorA) .Prop(_SC("A"), &CBlip::GetColorA)
// Static Functions
.StaticFunc(_SC("FindByID"), &Blip_FindByID)
.StaticFunc(_SC("FindByTag"), &Blip_FindByTag)
.StaticFunc(_SC("FindBySprID"), &Blip_FindBySprID)
// Static Overloads // Static Overloads
.StaticOverload< Object & (*)(Int32, Float32, Float32, Float32, Int32, Uint8, Uint8, Uint8, Uint8, Int32) > .StaticOverload< Object & (*)(Int32, Float32, Float32, Float32, Int32, Uint8, Uint8, Uint8, Uint8, Int32) >
(_SC("CreateEx"), &Blip_CreateEx) (_SC("CreateEx"), &Blip_CreateEx)

View File

@ -443,6 +443,45 @@ static Object & Checkpoint_Create(CPlayer & player, Int32 world, const Vector3 &
color.r, color.g, color.b, color.a, radius, header, payload); color.r, color.g, color.b, color.a, radius, header, payload);
} }
// ------------------------------------------------------------------------------------------------
static const Object & Checkpoint_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_CHECKPOINT_POOL))
SqThrowF("The specified checkpoint identifier is invalid: %d", id);
// Obtain the ends of the entity pool
Core::Checkpoints::const_iterator itr = _Core->GetCheckpoints().cbegin();
Core::Checkpoints::const_iterator end = _Core->GetCheckpoints().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does the identifier match the specified one?
if (itr->mID == id)
return itr->mObj; // Stop searching and return this entity
}
// Unable to locate a checkpoint matching the specified identifier
return NullObject();
}
static const Object & Checkpoint_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == 0)
SqThrowF("The specified checkpoint tag is invalid: null/empty");
// Obtain the ends of the entity pool
Core::Checkpoints::const_iterator itr = _Core->GetCheckpoints().cbegin();
Core::Checkpoints::const_iterator end = _Core->GetCheckpoints().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
return itr->mObj; // Stop searching and return this entity
}
// Unable to locate a checkpoint matching the specified tag
return NullObject();
}
// ================================================================================================ // ================================================================================================
void Register_CCheckpoint(HSQUIRRELVM vm) void Register_CCheckpoint(HSQUIRRELVM vm)
{ {
@ -452,14 +491,14 @@ void Register_CCheckpoint(HSQUIRRELVM vm)
.Func(_SC("_cmp"), &CCheckpoint::Cmp) .Func(_SC("_cmp"), &CCheckpoint::Cmp)
.SquirrelFunc(_SC("_typename"), &CCheckpoint::Typename) .SquirrelFunc(_SC("_typename"), &CCheckpoint::Typename)
.Func(_SC("_tostring"), &CCheckpoint::ToString) .Func(_SC("_tostring"), &CCheckpoint::ToString)
// Static values // Static Values
.SetStaticValue(_SC("MaxID"), CCheckpoint::Max) .SetStaticValue(_SC("MaxID"), CCheckpoint::Max)
// Core Properties // Core Properties
.Prop(_SC("ID"), &CCheckpoint::GetID) .Prop(_SC("ID"), &CCheckpoint::GetID)
.Prop(_SC("Tag"), &CCheckpoint::GetTag, &CCheckpoint::SetTag) .Prop(_SC("Tag"), &CCheckpoint::GetTag, &CCheckpoint::SetTag)
.Prop(_SC("Data"), &CCheckpoint::GetData, &CCheckpoint::SetData) .Prop(_SC("Data"), &CCheckpoint::GetData, &CCheckpoint::SetData)
.Prop(_SC("Active"), &CCheckpoint::IsActive) .Prop(_SC("Active"), &CCheckpoint::IsActive)
// Core Functions // Core Methods
.Func(_SC("Bind"), &CCheckpoint::BindEvent) .Func(_SC("Bind"), &CCheckpoint::BindEvent)
// Core Overloads // Core Overloads
.Overload< bool (CCheckpoint::*)(void) >(_SC("Destroy"), &CCheckpoint::Destroy) .Overload< bool (CCheckpoint::*)(void) >(_SC("Destroy"), &CCheckpoint::Destroy)
@ -480,11 +519,14 @@ void Register_CCheckpoint(HSQUIRRELVM vm)
.Prop(_SC("G"), &CCheckpoint::GetColG, &CCheckpoint::SetColG) .Prop(_SC("G"), &CCheckpoint::GetColG, &CCheckpoint::SetColG)
.Prop(_SC("B"), &CCheckpoint::GetColB, &CCheckpoint::SetColB) .Prop(_SC("B"), &CCheckpoint::GetColB, &CCheckpoint::SetColB)
.Prop(_SC("A"), &CCheckpoint::GetColA, &CCheckpoint::SetColA) .Prop(_SC("A"), &CCheckpoint::GetColA, &CCheckpoint::SetColA)
// Functions // Member Methods
.Func(_SC("StreamedFor"), &CCheckpoint::IsStreamedFor) .Func(_SC("StreamedFor"), &CCheckpoint::IsStreamedFor)
.Func(_SC("SetColor"), &CCheckpoint::SetColorEx) .Func(_SC("SetColor"), &CCheckpoint::SetColorEx)
.Func(_SC("SetPos"), &CCheckpoint::SetPositionEx) .Func(_SC("SetPos"), &CCheckpoint::SetPositionEx)
.Func(_SC("SetPosition"), &CCheckpoint::SetPositionEx) .Func(_SC("SetPosition"), &CCheckpoint::SetPositionEx)
// Static Functions
.StaticFunc(_SC("FindByID"), &Checkpoint_FindByID)
.StaticFunc(_SC("FindByTag"), &Checkpoint_FindByTag)
// Static Overloads // Static Overloads
.StaticOverload< Object & (*)(CPlayer &, Int32, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32) > .StaticOverload< Object & (*)(CPlayer &, Int32, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32) >
(_SC("CreateEx"), &Checkpoint_CreateEx) (_SC("CreateEx"), &Checkpoint_CreateEx)

View File

@ -417,6 +417,45 @@ static Object & Forcefield_Create(CPlayer & player, Int32 world, const Vector3 &
header, payload); header, payload);
} }
// ------------------------------------------------------------------------------------------------
static const Object & Forcefield_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_FORCEFIELD_POOL))
SqThrowF("The specified forcefield identifier is invalid: %d", id);
// Obtain the ends of the entity pool
Core::Forcefields::const_iterator itr = _Core->GetForcefields().cbegin();
Core::Forcefields::const_iterator end = _Core->GetForcefields().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does the identifier match the specified one?
if (itr->mID == id)
return itr->mObj; // Stop searching and return this entity
}
// Unable to locate a forcefield matching the specified identifier
return NullObject();
}
static const Object & Forcefield_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == 0)
SqThrowF("The specified forcefield tag is invalid: null/empty");
// Obtain the ends of the entity pool
Core::Forcefields::const_iterator itr = _Core->GetForcefields().cbegin();
Core::Forcefields::const_iterator end = _Core->GetForcefields().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
return itr->mObj; // Stop searching and return this entity
}
// Unable to locate a forcefield matching the specified tag
return NullObject();
}
// ================================================================================================ // ================================================================================================
void Register_CForcefield(HSQUIRRELVM vm) void Register_CForcefield(HSQUIRRELVM vm)
{ {
@ -426,14 +465,14 @@ void Register_CForcefield(HSQUIRRELVM vm)
.Func(_SC("_cmp"), &CForcefield::Cmp) .Func(_SC("_cmp"), &CForcefield::Cmp)
.SquirrelFunc(_SC("_typename"), &CForcefield::Typename) .SquirrelFunc(_SC("_typename"), &CForcefield::Typename)
.Func(_SC("_tostring"), &CForcefield::ToString) .Func(_SC("_tostring"), &CForcefield::ToString)
// Static values // Static Values
.SetStaticValue(_SC("MaxID"), CForcefield::Max) .SetStaticValue(_SC("MaxID"), CForcefield::Max)
// Core Properties // Core Properties
.Prop(_SC("ID"), &CForcefield::GetID) .Prop(_SC("ID"), &CForcefield::GetID)
.Prop(_SC("Tag"), &CForcefield::GetTag, &CForcefield::SetTag) .Prop(_SC("Tag"), &CForcefield::GetTag, &CForcefield::SetTag)
.Prop(_SC("Data"), &CForcefield::GetData, &CForcefield::SetData) .Prop(_SC("Data"), &CForcefield::GetData, &CForcefield::SetData)
.Prop(_SC("Active"), &CForcefield::IsActive) .Prop(_SC("Active"), &CForcefield::IsActive)
// Core Functions // Core Methods
.Func(_SC("Bind"), &CForcefield::BindEvent) .Func(_SC("Bind"), &CForcefield::BindEvent)
// Core Overloads // Core Overloads
.Overload< bool (CForcefield::*)(void) >(_SC("Destroy"), &CForcefield::Destroy) .Overload< bool (CForcefield::*)(void) >(_SC("Destroy"), &CForcefield::Destroy)
@ -453,11 +492,14 @@ void Register_CForcefield(HSQUIRRELVM vm)
.Prop(_SC("R"), &CForcefield::GetColR, &CForcefield::SetColR) .Prop(_SC("R"), &CForcefield::GetColR, &CForcefield::SetColR)
.Prop(_SC("G"), &CForcefield::GetColG, &CForcefield::SetColG) .Prop(_SC("G"), &CForcefield::GetColG, &CForcefield::SetColG)
.Prop(_SC("B"), &CForcefield::GetColB, &CForcefield::SetColB) .Prop(_SC("B"), &CForcefield::GetColB, &CForcefield::SetColB)
// Functions // Member Methods
.Func(_SC("StreamedFor"), &CForcefield::IsStreamedFor) .Func(_SC("StreamedFor"), &CForcefield::IsStreamedFor)
.Func(_SC("SetColor"), &CForcefield::SetColorEx) .Func(_SC("SetColor"), &CForcefield::SetColorEx)
.Func(_SC("SetPos"), &CForcefield::SetPositionEx) .Func(_SC("SetPos"), &CForcefield::SetPositionEx)
.Func(_SC("SetPosition"), &CForcefield::SetPositionEx) .Func(_SC("SetPosition"), &CForcefield::SetPositionEx)
// Static Functions
.StaticFunc(_SC("FindByID"), &Forcefield_FindByID)
.StaticFunc(_SC("FindByTag"), &Forcefield_FindByTag)
// Static Overloads // Static Overloads
.StaticOverload< Object & (*)(CPlayer &, Int32, Float32, Float32, Float32, Uint8, Uint8, Uint8, Float32) > .StaticOverload< Object & (*)(CPlayer &, Int32, Float32, Float32, Float32, Uint8, Uint8, Uint8, Float32) >
(_SC("CreateEx"), &Forcefield_CreateEx) (_SC("CreateEx"), &Forcefield_CreateEx)

View File

@ -164,6 +164,45 @@ static Object & Keybind_Create(bool release, Int32 primary, Int32 secondary, Int
return _Core->NewKeybind(-1, release, primary, secondary, alternative, header, payload); return _Core->NewKeybind(-1, release, primary, secondary, alternative, header, payload);
} }
// ------------------------------------------------------------------------------------------------
static const Object & Keybind_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_KEYBIND_POOL))
SqThrowF("The specified keybind identifier is invalid: %d", id);
// Obtain the ends of the entity pool
Core::Keybinds::const_iterator itr = _Core->GetKeybinds().cbegin();
Core::Keybinds::const_iterator end = _Core->GetKeybinds().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does the identifier match the specified one?
if (itr->mID == id)
return itr->mObj; // Stop searching and return this entity
}
// Unable to locate a keybind matching the specified identifier
return NullObject();
}
static const Object & Keybind_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == 0)
SqThrowF("The specified keybind tag is invalid: null/empty");
// Obtain the ends of the entity pool
Core::Keybinds::const_iterator itr = _Core->GetKeybinds().cbegin();
Core::Keybinds::const_iterator end = _Core->GetKeybinds().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
return itr->mObj; // Stop searching and return this entity
}
// Unable to locate a keybind matching the specified tag
return NullObject();
}
// ================================================================================================ // ================================================================================================
void Register_CKeybind(HSQUIRRELVM vm) void Register_CKeybind(HSQUIRRELVM vm)
{ {
@ -173,14 +212,14 @@ void Register_CKeybind(HSQUIRRELVM vm)
.Func(_SC("_cmp"), &CKeybind::Cmp) .Func(_SC("_cmp"), &CKeybind::Cmp)
.SquirrelFunc(_SC("_typename"), &CKeybind::Typename) .SquirrelFunc(_SC("_typename"), &CKeybind::Typename)
.Func(_SC("_tostring"), &CKeybind::ToString) .Func(_SC("_tostring"), &CKeybind::ToString)
// Static values // Static Values
.SetStaticValue(_SC("MaxID"), CKeybind::Max) .SetStaticValue(_SC("MaxID"), CKeybind::Max)
// Core Properties // Core Properties
.Prop(_SC("ID"), &CKeybind::GetID) .Prop(_SC("ID"), &CKeybind::GetID)
.Prop(_SC("Tag"), &CKeybind::GetTag, &CKeybind::SetTag) .Prop(_SC("Tag"), &CKeybind::GetTag, &CKeybind::SetTag)
.Prop(_SC("Data"), &CKeybind::GetData, &CKeybind::SetData) .Prop(_SC("Data"), &CKeybind::GetData, &CKeybind::SetData)
.Prop(_SC("Active"), &CKeybind::IsActive) .Prop(_SC("Active"), &CKeybind::IsActive)
// Core Functions // Core Methods
.Func(_SC("Bind"), &CKeybind::BindEvent) .Func(_SC("Bind"), &CKeybind::BindEvent)
// Core Overloads // Core Overloads
.Overload< bool (CKeybind::*)(void) >(_SC("Destroy"), &CKeybind::Destroy) .Overload< bool (CKeybind::*)(void) >(_SC("Destroy"), &CKeybind::Destroy)
@ -191,6 +230,9 @@ void Register_CKeybind(HSQUIRRELVM vm)
.Prop(_SC("Second"), &CKeybind::GetSecond) .Prop(_SC("Second"), &CKeybind::GetSecond)
.Prop(_SC("Third"), &CKeybind::GetThird) .Prop(_SC("Third"), &CKeybind::GetThird)
.Prop(_SC("Release"), &CKeybind::IsRelease) .Prop(_SC("Release"), &CKeybind::IsRelease)
// Static Functions
.StaticFunc(_SC("FindByID"), &Keybind_FindByID)
.StaticFunc(_SC("FindByTag"), &Keybind_FindByTag)
// Static Overloads // Static Overloads
.StaticOverload< Object & (*)(Int32, bool, Int32, Int32, Int32) > .StaticOverload< Object & (*)(Int32, bool, Int32, Int32, Int32) >
(_SC("CreateEx"), &Keybind_CreateEx) (_SC("CreateEx"), &Keybind_CreateEx)

View File

@ -564,6 +564,45 @@ static Object & Object_Create(Int32 model, Int32 world, const Vector3 & pos, Int
return _Core->NewObject(model, world, pos.x, pos.y, pos.z, alpha, header, payload); return _Core->NewObject(model, world, pos.x, pos.y, pos.z, alpha, header, payload);
} }
// ------------------------------------------------------------------------------------------------
static const Object & Object_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_OBJECT_POOL))
SqThrowF("The specified object identifier is invalid: %d", id);
// Obtain the ends of the entity pool
Core::Objects::const_iterator itr = _Core->GetObjects().cbegin();
Core::Objects::const_iterator end = _Core->GetObjects().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does the identifier match the specified one?
if (itr->mID == id)
return itr->mObj; // Stop searching and return this entity
}
// Unable to locate a object matching the specified identifier
return NullObject();
}
static const Object & Object_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == 0)
SqThrowF("The specified object tag is invalid: null/empty");
// Obtain the ends of the entity pool
Core::Objects::const_iterator itr = _Core->GetObjects().cbegin();
Core::Objects::const_iterator end = _Core->GetObjects().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
return itr->mObj; // Stop searching and return this entity
}
// Unable to locate a object matching the specified tag
return NullObject();
}
// ================================================================================================ // ================================================================================================
void Register_CObject(HSQUIRRELVM vm) void Register_CObject(HSQUIRRELVM vm)
{ {
@ -573,14 +612,14 @@ void Register_CObject(HSQUIRRELVM vm)
.Func(_SC("_cmp"), &CObject::Cmp) .Func(_SC("_cmp"), &CObject::Cmp)
.SquirrelFunc(_SC("_typename"), &CObject::Typename) .SquirrelFunc(_SC("_typename"), &CObject::Typename)
.Func(_SC("_tostring"), &CObject::ToString) .Func(_SC("_tostring"), &CObject::ToString)
// Static values // Static Values
.SetStaticValue(_SC("MaxID"), CObject::Max) .SetStaticValue(_SC("MaxID"), CObject::Max)
// Core Properties // Core Properties
.Prop(_SC("ID"), &CObject::GetID) .Prop(_SC("ID"), &CObject::GetID)
.Prop(_SC("Tag"), &CObject::GetTag, &CObject::SetTag) .Prop(_SC("Tag"), &CObject::GetTag, &CObject::SetTag)
.Prop(_SC("Data"), &CObject::GetData, &CObject::SetData) .Prop(_SC("Data"), &CObject::GetData, &CObject::SetData)
.Prop(_SC("Active"), &CObject::IsActive) .Prop(_SC("Active"), &CObject::IsActive)
// Core Functions // Core Methods
.Func(_SC("Bind"), &CObject::BindEvent) .Func(_SC("Bind"), &CObject::BindEvent)
// Core Overloads // Core Overloads
.Overload< bool (CObject::*)(void) >(_SC("Destroy"), &CObject::Destroy) .Overload< bool (CObject::*)(void) >(_SC("Destroy"), &CObject::Destroy)
@ -607,11 +646,11 @@ void Register_CObject(HSQUIRRELVM vm)
.Prop(_SC("EX"), &CObject::GetERotX) .Prop(_SC("EX"), &CObject::GetERotX)
.Prop(_SC("EY"), &CObject::GetERotY) .Prop(_SC("EY"), &CObject::GetERotY)
.Prop(_SC("EZ"), &CObject::GetERotZ) .Prop(_SC("EZ"), &CObject::GetERotZ)
// Functions // Member Methods
.Func(_SC("StreamedFor"), &CObject::IsStreamedFor) .Func(_SC("StreamedFor"), &CObject::IsStreamedFor)
.Func(_SC("SetAlpha"), &CObject::SetAlphaEx) .Func(_SC("SetAlpha"), &CObject::SetAlphaEx)
.Func(_SC("SetPosition"), &CObject::SetPositionEx) .Func(_SC("SetPosition"), &CObject::SetPositionEx)
// Overloads // Member Overloads
.Overload< void (CObject::*)(const Vector3 &, Int32) const > .Overload< void (CObject::*)(const Vector3 &, Int32) const >
(_SC("MoveTo"), &CObject::MoveTo) (_SC("MoveTo"), &CObject::MoveTo)
.Overload< void (CObject::*)(Float32, Float32, Float32, Int32) const > .Overload< void (CObject::*)(Float32, Float32, Float32, Int32) const >
@ -636,6 +675,9 @@ void Register_CObject(HSQUIRRELVM vm)
(_SC("RotateByEuler"), &CObject::RotateByEuler) (_SC("RotateByEuler"), &CObject::RotateByEuler)
.Overload< void (CObject::*)(Float32, Float32, Float32, Int32) const > .Overload< void (CObject::*)(Float32, Float32, Float32, Int32) const >
(_SC("RotateByEuler"), &CObject::RotateByEulerEx) (_SC("RotateByEuler"), &CObject::RotateByEulerEx)
// Static Functions
.StaticFunc(_SC("FindByID"), &Object_FindByID)
.StaticFunc(_SC("FindByTag"), &Object_FindByTag)
// Static Overloads // Static Overloads
.StaticOverload< Object & (*)(Int32, Int32, Float32, Float32, Float32, Int32) > .StaticOverload< Object & (*)(Int32, Int32, Float32, Float32, Float32, Int32) >
(_SC("CreateEx"), &Object_CreateEx) (_SC("CreateEx"), &Object_CreateEx)

View File

@ -350,6 +350,45 @@ static Object & Pickup_Create(Int32 model, Int32 world, Int32 quantity, const Ve
header, payload); header, payload);
} }
// ------------------------------------------------------------------------------------------------
static const Object & Pickup_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_PICKUP_POOL))
SqThrowF("The specified pickup identifier is invalid: %d", id);
// Obtain the ends of the entity pool
Core::Pickups::const_iterator itr = _Core->GetPickups().cbegin();
Core::Pickups::const_iterator end = _Core->GetPickups().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does the identifier match the specified one?
if (itr->mID == id)
return itr->mObj; // Stop searching and return this entity
}
// Unable to locate a pickup matching the specified identifier
return NullObject();
}
static const Object & Pickup_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == 0)
SqThrowF("The specified pickup tag is invalid: null/empty");
// Obtain the ends of the entity pool
Core::Pickups::const_iterator itr = _Core->GetPickups().cbegin();
Core::Pickups::const_iterator end = _Core->GetPickups().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
return itr->mObj; // Stop searching and return this entity
}
// Unable to locate a pickup matching the specified tag
return NullObject();
}
// ================================================================================================ // ================================================================================================
void Register_CPickup(HSQUIRRELVM vm) void Register_CPickup(HSQUIRRELVM vm)
{ {
@ -359,14 +398,14 @@ void Register_CPickup(HSQUIRRELVM vm)
.Func(_SC("_cmp"), &CPickup::Cmp) .Func(_SC("_cmp"), &CPickup::Cmp)
.SquirrelFunc(_SC("_typename"), &CPickup::Typename) .SquirrelFunc(_SC("_typename"), &CPickup::Typename)
.Func(_SC("_tostring"), &CPickup::ToString) .Func(_SC("_tostring"), &CPickup::ToString)
// Static values // Static Values
.SetStaticValue(_SC("MaxID"), CPickup::Max) .SetStaticValue(_SC("MaxID"), CPickup::Max)
// Core Properties // Core Properties
.Prop(_SC("ID"), &CPickup::GetID) .Prop(_SC("ID"), &CPickup::GetID)
.Prop(_SC("Tag"), &CPickup::GetTag, &CPickup::SetTag) .Prop(_SC("Tag"), &CPickup::GetTag, &CPickup::SetTag)
.Prop(_SC("Data"), &CPickup::GetData, &CPickup::SetData) .Prop(_SC("Data"), &CPickup::GetData, &CPickup::SetData)
.Prop(_SC("Active"), &CPickup::IsActive) .Prop(_SC("Active"), &CPickup::IsActive)
// Core Functions // Core Methods
.Func(_SC("Bind"), &CPickup::BindEvent) .Func(_SC("Bind"), &CPickup::BindEvent)
// Core Overloads // Core Overloads
.Overload< bool (CPickup::*)(void) >(_SC("Destroy"), &CPickup::Destroy) .Overload< bool (CPickup::*)(void) >(_SC("Destroy"), &CPickup::Destroy)
@ -386,11 +425,14 @@ void Register_CPickup(HSQUIRRELVM vm)
.Prop(_SC("X"), &CPickup::GetPosX, &CPickup::SetPosX) .Prop(_SC("X"), &CPickup::GetPosX, &CPickup::SetPosX)
.Prop(_SC("Y"), &CPickup::GetPosY, &CPickup::SetPosY) .Prop(_SC("Y"), &CPickup::GetPosY, &CPickup::SetPosY)
.Prop(_SC("Z"), &CPickup::GetPosZ, &CPickup::SetPosZ) .Prop(_SC("Z"), &CPickup::GetPosZ, &CPickup::SetPosZ)
// Functions // Member Methods
.Func(_SC("StreamedFor"), &CPickup::IsStreamedFor) .Func(_SC("StreamedFor"), &CPickup::IsStreamedFor)
.Func(_SC("Refresh"), &CPickup::Refresh) .Func(_SC("Refresh"), &CPickup::Refresh)
.Func(_SC("SetPos"), &CPickup::SetPositionEx) .Func(_SC("SetPos"), &CPickup::SetPositionEx)
.Func(_SC("SetPosition"), &CPickup::SetPositionEx) .Func(_SC("SetPosition"), &CPickup::SetPositionEx)
// Static Functions
.StaticFunc(_SC("FindByID"), &Pickup_FindByID)
.StaticFunc(_SC("FindByTag"), &Pickup_FindByTag)
// Static Overloads // Static Overloads
.StaticOverload< Object & (*)(Int32, Int32, Int32, Float32, Float32, Float32, Int32, bool) > .StaticOverload< Object & (*)(Int32, Int32, Int32, Float32, Float32, Float32, Int32, bool) >
(_SC("CreateEx"), &Pickup_CreateEx) (_SC("CreateEx"), &Pickup_CreateEx)

View File

@ -1614,6 +1614,45 @@ SQInteger CPlayer::AnnounceEx(HSQUIRRELVM vm)
return 0; return 0;
} }
// ------------------------------------------------------------------------------------------------
static const Object & Player_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_PLAYER_POOL))
SqThrowF("The specified player identifier is invalid: %d", id);
// Obtain the ends of the entity pool
Core::Players::const_iterator itr = _Core->GetPlayers().cbegin();
Core::Players::const_iterator end = _Core->GetPlayers().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does the identifier match the specified one?
if (itr->mID == id)
return itr->mObj; // Stop searching and return this entity
}
// Unable to locate a player matching the specified identifier
return NullObject();
}
static const Object & Player_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == 0)
SqThrowF("The specified player tag is invalid: null/empty");
// Obtain the ends of the entity pool
Core::Players::const_iterator itr = _Core->GetPlayers().cbegin();
Core::Players::const_iterator end = _Core->GetPlayers().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
return itr->mObj; // Stop searching and return this entity
}
// Unable to locate a player matching the specified tag
return NullObject();
}
// ================================================================================================ // ================================================================================================
void Register_CPlayer(HSQUIRRELVM vm) void Register_CPlayer(HSQUIRRELVM vm)
{ {
@ -1623,14 +1662,14 @@ void Register_CPlayer(HSQUIRRELVM vm)
.Func(_SC("_cmp"), &CPlayer::Cmp) .Func(_SC("_cmp"), &CPlayer::Cmp)
.SquirrelFunc(_SC("_typename"), &CPlayer::Typename) .SquirrelFunc(_SC("_typename"), &CPlayer::Typename)
.Func(_SC("_tostring"), &CPlayer::ToString) .Func(_SC("_tostring"), &CPlayer::ToString)
// Static values // Static Values
.SetStaticValue(_SC("MaxID"), CPlayer::Max) .SetStaticValue(_SC("MaxID"), CPlayer::Max)
// Core Properties // Core Properties
.Prop(_SC("ID"), &CPlayer::GetID) .Prop(_SC("ID"), &CPlayer::GetID)
.Prop(_SC("Tag"), &CPlayer::GetTag, &CPlayer::SetTag) .Prop(_SC("Tag"), &CPlayer::GetTag, &CPlayer::SetTag)
.Prop(_SC("Data"), &CPlayer::GetData, &CPlayer::SetData) .Prop(_SC("Data"), &CPlayer::GetData, &CPlayer::SetData)
.Prop(_SC("Active"), &CPlayer::IsActive) .Prop(_SC("Active"), &CPlayer::IsActive)
// Core Functions // Core Methods
.Func(_SC("Bind"), &CPlayer::BindEvent) .Func(_SC("Bind"), &CPlayer::BindEvent)
// Properties // Properties
.Prop(_SC("Class"), &CPlayer::GetClass) .Prop(_SC("Class"), &CPlayer::GetClass)
@ -1698,7 +1737,7 @@ void Register_CPlayer(HSQUIRRELVM vm)
.Prop(_SC("X"), &CPlayer::GetPosX, &CPlayer::SetPosX) .Prop(_SC("X"), &CPlayer::GetPosX, &CPlayer::SetPosX)
.Prop(_SC("Y"), &CPlayer::GetPosY, &CPlayer::SetPosY) .Prop(_SC("Y"), &CPlayer::GetPosY, &CPlayer::SetPosY)
.Prop(_SC("Z"), &CPlayer::GetPosZ, &CPlayer::SetPosZ) .Prop(_SC("Z"), &CPlayer::GetPosZ, &CPlayer::SetPosZ)
// Functions // Member Methods
.Func(_SC("StreamedFor"), &CPlayer::IsStreamedFor) .Func(_SC("StreamedFor"), &CPlayer::IsStreamedFor)
.Func(_SC("Kick"), &CPlayer::Kick) .Func(_SC("Kick"), &CPlayer::Kick)
.Func(_SC("Ban"), &CPlayer::Ban) .Func(_SC("Ban"), &CPlayer::Ban)
@ -1721,7 +1760,7 @@ void Register_CPlayer(HSQUIRRELVM vm)
.Func(_SC("Redirect"), &CPlayer::Redirect) .Func(_SC("Redirect"), &CPlayer::Redirect)
.Func(_SC("GetMsgPrefix"), &CPlayer::GetMessagePrefix) .Func(_SC("GetMsgPrefix"), &CPlayer::GetMessagePrefix)
.Func(_SC("SetMsgPrefix"), &CPlayer::SetMessagePrefix) .Func(_SC("SetMsgPrefix"), &CPlayer::SetMessagePrefix)
// Raw Functions // Raw Methods
.SquirrelFunc(_SC("Msg"), &CPlayer::Msg) .SquirrelFunc(_SC("Msg"), &CPlayer::Msg)
.SquirrelFunc(_SC("MsgP"), &CPlayer::MsgP) .SquirrelFunc(_SC("MsgP"), &CPlayer::MsgP)
.SquirrelFunc(_SC("MsgEx"), &CPlayer::MsgEx) .SquirrelFunc(_SC("MsgEx"), &CPlayer::MsgEx)
@ -1730,7 +1769,7 @@ void Register_CPlayer(HSQUIRRELVM vm)
.SquirrelFunc(_SC("AnnounceEx"), &CPlayer::AnnounceEx) .SquirrelFunc(_SC("AnnounceEx"), &CPlayer::AnnounceEx)
.SquirrelFunc(_SC("Text"), &CPlayer::Announce) .SquirrelFunc(_SC("Text"), &CPlayer::Announce)
.SquirrelFunc(_SC("TextEx"), &CPlayer::AnnounceEx) .SquirrelFunc(_SC("TextEx"), &CPlayer::AnnounceEx)
// Overloads // Member Overloads
.Overload< void (CPlayer::*)(const Vector3 &) const > .Overload< void (CPlayer::*)(const Vector3 &) const >
(_SC("AddSpeed"), &CPlayer::AddSpeed) (_SC("AddSpeed"), &CPlayer::AddSpeed)
.Overload< void (CPlayer::*)(Float32, Float32, Float32) const > .Overload< void (CPlayer::*)(Float32, Float32, Float32) const >
@ -1743,6 +1782,9 @@ void Register_CPlayer(HSQUIRRELVM vm)
(_SC("Embark"), &CPlayer::Embark) (_SC("Embark"), &CPlayer::Embark)
.Overload< void (CPlayer::*)(CVehicle &, SQInt32, bool, bool) const > .Overload< void (CPlayer::*)(CVehicle &, SQInt32, bool, bool) const >
(_SC("Embark"), &CPlayer::Embark) (_SC("Embark"), &CPlayer::Embark)
// Static Functions
.StaticFunc(_SC("FindByID"), &Player_FindByID)
.StaticFunc(_SC("FindByTag"), &Player_FindByTag)
); );
} }

View File

@ -449,6 +449,45 @@ static Object & Sprite_Create(Int32 index, CSStr file, const Vector2i & pos, con
return _Core->NewSprite(index, file, pos.x, pos.y, rot.x, rot.y, angle, alpha, rel, header, payload); return _Core->NewSprite(index, file, pos.x, pos.y, rot.x, rot.y, angle, alpha, rel, header, payload);
} }
// ------------------------------------------------------------------------------------------------
static const Object & Sprite_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_SPRITE_POOL))
SqThrowF("The specified sprite identifier is invalid: %d", id);
// Obtain the ends of the entity pool
Core::Sprites::const_iterator itr = _Core->GetSprites().cbegin();
Core::Sprites::const_iterator end = _Core->GetSprites().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does the identifier match the specified one?
if (itr->mID == id)
return itr->mObj; // Stop searching and return this entity
}
// Unable to locate a sprite matching the specified identifier
return NullObject();
}
static const Object & Sprite_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == 0)
SqThrowF("The specified sprite tag is invalid: null/empty");
// Obtain the ends of the entity pool
Core::Sprites::const_iterator itr = _Core->GetSprites().cbegin();
Core::Sprites::const_iterator end = _Core->GetSprites().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
return itr->mObj; // Stop searching and return this entity
}
// Unable to locate a sprite matching the specified tag
return NullObject();
}
// ================================================================================================ // ================================================================================================
void Register_CSprite(HSQUIRRELVM vm) void Register_CSprite(HSQUIRRELVM vm)
{ {
@ -458,14 +497,14 @@ void Register_CSprite(HSQUIRRELVM vm)
.Func(_SC("_cmp"), &CSprite::Cmp) .Func(_SC("_cmp"), &CSprite::Cmp)
.SquirrelFunc(_SC("_typename"), &CSprite::Typename) .SquirrelFunc(_SC("_typename"), &CSprite::Typename)
.Func(_SC("_tostring"), &CSprite::ToString) .Func(_SC("_tostring"), &CSprite::ToString)
// Static values // Static Values
.SetStaticValue(_SC("MaxID"), CSprite::Max) .SetStaticValue(_SC("MaxID"), CSprite::Max)
// Core Properties // Core Properties
.Prop(_SC("ID"), &CSprite::GetID) .Prop(_SC("ID"), &CSprite::GetID)
.Prop(_SC("Tag"), &CSprite::GetTag, &CSprite::SetTag) .Prop(_SC("Tag"), &CSprite::GetTag, &CSprite::SetTag)
.Prop(_SC("Data"), &CSprite::GetData, &CSprite::SetData) .Prop(_SC("Data"), &CSprite::GetData, &CSprite::SetData)
.Prop(_SC("Active"), &CSprite::IsActive) .Prop(_SC("Active"), &CSprite::IsActive)
// Core Functions // Core Methods
.Func(_SC("Bind"), &CSprite::BindEvent) .Func(_SC("Bind"), &CSprite::BindEvent)
// Core Overloads // Core Overloads
.Overload< bool (CSprite::*)(void) >(_SC("Destroy"), &CSprite::Destroy) .Overload< bool (CSprite::*)(void) >(_SC("Destroy"), &CSprite::Destroy)
@ -473,7 +512,7 @@ void Register_CSprite(HSQUIRRELVM vm)
.Overload< bool (CSprite::*)(Int32, Object &) >(_SC("Destroy"), &CSprite::Destroy) .Overload< bool (CSprite::*)(Int32, Object &) >(_SC("Destroy"), &CSprite::Destroy)
// Properties // Properties
.Prop(_SC("Path"), &CSprite::GetFilePath) .Prop(_SC("Path"), &CSprite::GetFilePath)
// Functions // Member Methods
.Func(_SC("ShowAll"), &CSprite::ShowAll) .Func(_SC("ShowAll"), &CSprite::ShowAll)
.Func(_SC("ShowTo"), &CSprite::ShowFor) .Func(_SC("ShowTo"), &CSprite::ShowFor)
.Func(_SC("ShowFor"), &CSprite::ShowFor) .Func(_SC("ShowFor"), &CSprite::ShowFor)
@ -490,7 +529,7 @@ void Register_CSprite(HSQUIRRELVM vm)
.Func(_SC("SetAlphaAll"), &CSprite::SetAlphaAll) .Func(_SC("SetAlphaAll"), &CSprite::SetAlphaAll)
.Func(_SC("SetAlphaFor"), &CSprite::SetAlphaFor) .Func(_SC("SetAlphaFor"), &CSprite::SetAlphaFor)
.Func(_SC("SetAlphaRange"), &CSprite::SetAlphaRange) .Func(_SC("SetAlphaRange"), &CSprite::SetAlphaRange)
// Overloads // Member Overloads
.Overload< void (CSprite::*)(const Vector2i &) const > .Overload< void (CSprite::*)(const Vector2i &) const >
(_SC("SetPositionAll"), &CSprite::SetPositionAll) (_SC("SetPositionAll"), &CSprite::SetPositionAll)
.Overload< void (CSprite::*)(Int32, Int32) const > .Overload< void (CSprite::*)(Int32, Int32) const >
@ -507,6 +546,9 @@ void Register_CSprite(HSQUIRRELVM vm)
(_SC("SetCenterFor"), &CSprite::SetCenterFor) (_SC("SetCenterFor"), &CSprite::SetCenterFor)
.Overload< void (CSprite::*)(CPlayer &, Int32, Int32) const > .Overload< void (CSprite::*)(CPlayer &, Int32, Int32) const >
(_SC("SetCenterFor"), &CSprite::SetCenterForEx) (_SC("SetCenterFor"), &CSprite::SetCenterForEx)
// Static Functions
.StaticFunc(_SC("FindByID"), &Sprite_FindByID)
.StaticFunc(_SC("FindByTag"), &Sprite_FindByTag)
// Static Overloads // Static Overloads
.StaticOverload< Object & (*)(CSStr, Int32, Int32, Int32, Int32, Float32, Int32, bool rel) > .StaticOverload< Object & (*)(CSStr, Int32, Int32, Int32, Int32, Float32, Int32, bool rel) >
(_SC("CreateEx"), &Sprite_CreateEx) (_SC("CreateEx"), &Sprite_CreateEx)

View File

@ -374,6 +374,45 @@ static Object & Textdraw_Create(Int32 index, CSStr text, const Vector2i & pos, c
return _Core->NewTextdraw(index, text, pos.x, pos.y, color.GetARGB(), rel, header, payload); return _Core->NewTextdraw(index, text, pos.x, pos.y, color.GetARGB(), rel, header, payload);
} }
// ------------------------------------------------------------------------------------------------
static const Object & Textdraw_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_TEXTDRAW_POOL))
SqThrowF("The specified textdraw identifier is invalid: %d", id);
// Obtain the ends of the entity pool
Core::Textdraws::const_iterator itr = _Core->GetTextdraws().cbegin();
Core::Textdraws::const_iterator end = _Core->GetTextdraws().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does the identifier match the specified one?
if (itr->mID == id)
return itr->mObj; // Stop searching and return this entity
}
// Unable to locate a textdraw matching the specified identifier
return NullObject();
}
static const Object & Textdraw_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == 0)
SqThrowF("The specified textdraw tag is invalid: null/empty");
// Obtain the ends of the entity pool
Core::Textdraws::const_iterator itr = _Core->GetTextdraws().cbegin();
Core::Textdraws::const_iterator end = _Core->GetTextdraws().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
return itr->mObj; // Stop searching and return this entity
}
// Unable to locate a textdraw matching the specified tag
return NullObject();
}
// ================================================================================================ // ================================================================================================
void Register_CTextdraw(HSQUIRRELVM vm) void Register_CTextdraw(HSQUIRRELVM vm)
{ {
@ -383,14 +422,14 @@ void Register_CTextdraw(HSQUIRRELVM vm)
.Func(_SC("_cmp"), &CTextdraw::Cmp) .Func(_SC("_cmp"), &CTextdraw::Cmp)
.SquirrelFunc(_SC("_typename"), &CTextdraw::Typename) .SquirrelFunc(_SC("_typename"), &CTextdraw::Typename)
.Func(_SC("_tostring"), &CTextdraw::ToString) .Func(_SC("_tostring"), &CTextdraw::ToString)
// Static values // Static Values
.SetStaticValue(_SC("MaxID"), CTextdraw::Max) .SetStaticValue(_SC("MaxID"), CTextdraw::Max)
// Core Properties // Core Properties
.Prop(_SC("ID"), &CTextdraw::GetID) .Prop(_SC("ID"), &CTextdraw::GetID)
.Prop(_SC("Tag"), &CTextdraw::GetTag, &CTextdraw::SetTag) .Prop(_SC("Tag"), &CTextdraw::GetTag, &CTextdraw::SetTag)
.Prop(_SC("Data"), &CTextdraw::GetData, &CTextdraw::SetData) .Prop(_SC("Data"), &CTextdraw::GetData, &CTextdraw::SetData)
.Prop(_SC("Active"), &CTextdraw::IsActive) .Prop(_SC("Active"), &CTextdraw::IsActive)
// Core Functions // Core Methods
.Func(_SC("Bind"), &CTextdraw::BindEvent) .Func(_SC("Bind"), &CTextdraw::BindEvent)
// Core Overloads // Core Overloads
.Overload< bool (CTextdraw::*)(void) >(_SC("Destroy"), &CTextdraw::Destroy) .Overload< bool (CTextdraw::*)(void) >(_SC("Destroy"), &CTextdraw::Destroy)
@ -398,7 +437,7 @@ void Register_CTextdraw(HSQUIRRELVM vm)
.Overload< bool (CTextdraw::*)(Int32, Object &) >(_SC("Destroy"), &CTextdraw::Destroy) .Overload< bool (CTextdraw::*)(Int32, Object &) >(_SC("Destroy"), &CTextdraw::Destroy)
// Properties // Properties
.Prop(_SC("Text"), &CTextdraw::GetText) .Prop(_SC("Text"), &CTextdraw::GetText)
// Functions // Member Methods
.Func(_SC("ShowAll"), &CTextdraw::ShowAll) .Func(_SC("ShowAll"), &CTextdraw::ShowAll)
.Func(_SC("ShowTo"), &CTextdraw::ShowFor) .Func(_SC("ShowTo"), &CTextdraw::ShowFor)
.Func(_SC("ShowFor"), &CTextdraw::ShowFor) .Func(_SC("ShowFor"), &CTextdraw::ShowFor)
@ -409,7 +448,7 @@ void Register_CTextdraw(HSQUIRRELVM vm)
.Func(_SC("HideRange"), &CTextdraw::HideRange) .Func(_SC("HideRange"), &CTextdraw::HideRange)
.Func(_SC("SetPositionRange"), &CTextdraw::SetPositionRange) .Func(_SC("SetPositionRange"), &CTextdraw::SetPositionRange)
.Func(_SC("SetColorRange"), &CTextdraw::SetColorRange) .Func(_SC("SetColorRange"), &CTextdraw::SetColorRange)
// Overloads // Member Overloads
.Overload< void (CTextdraw::*)(const Vector2i &) const > .Overload< void (CTextdraw::*)(const Vector2i &) const >
(_SC("SetPositionAll"), &CTextdraw::SetPositionAll) (_SC("SetPositionAll"), &CTextdraw::SetPositionAll)
.Overload< void (CTextdraw::*)(Int32, Int32) const > .Overload< void (CTextdraw::*)(Int32, Int32) const >
@ -426,6 +465,9 @@ void Register_CTextdraw(HSQUIRRELVM vm)
(_SC("SetColorFor"), &CTextdraw::SetColorFor) (_SC("SetColorFor"), &CTextdraw::SetColorFor)
.Overload< void (CTextdraw::*)(CPlayer &, Uint8, Uint8, Uint8, Uint8) const > .Overload< void (CTextdraw::*)(CPlayer &, Uint8, Uint8, Uint8, Uint8) const >
(_SC("SetColorFor"), &CTextdraw::SetColorForEx) (_SC("SetColorFor"), &CTextdraw::SetColorForEx)
// Static Functions
.StaticFunc(_SC("FindByID"), &Textdraw_FindByID)
.StaticFunc(_SC("FindByTag"), &Textdraw_FindByTag)
// Static Overloads // Static Overloads
.StaticOverload< Object & (*)(CSStr, Int32, Int32, Uint8, Uint8, Uint8, Uint8, bool) > .StaticOverload< Object & (*)(CSStr, Int32, Int32, Uint8, Uint8, Uint8, Uint8, bool) >
(_SC("CreateEx"), &Textdraw_CreateEx) (_SC("CreateEx"), &Textdraw_CreateEx)

View File

@ -1219,6 +1219,45 @@ static Object & Vehicle_Create(Int32 model, Int32 world, const Vector3 & pos, Fl
header, payload); header, payload);
} }
// ------------------------------------------------------------------------------------------------
static const Object & Vehicle_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_VEHICLE_POOL))
SqThrowF("The specified vehicle identifier is invalid: %d", id);
// Obtain the ends of the entity pool
Core::Vehicles::const_iterator itr = _Core->GetVehicles().cbegin();
Core::Vehicles::const_iterator end = _Core->GetVehicles().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does the identifier match the specified one?
if (itr->mID == id)
return itr->mObj; // Stop searching and return this entity
}
// Unable to locate a vehicle matching the specified identifier
return NullObject();
}
static const Object & Vehicle_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == 0)
SqThrowF("The specified vehicle tag is invalid: null/empty");
// Obtain the ends of the entity pool
Core::Vehicles::const_iterator itr = _Core->GetVehicles().cbegin();
Core::Vehicles::const_iterator end = _Core->GetVehicles().cend();
// Process each entity in the pool
for (; itr != end; ++itr)
{
// Does this entity even exist and does the tag match the specified one?
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
return itr->mObj; // Stop searching and return this entity
}
// Unable to locate a vehicle matching the specified tag
return NullObject();
}
// ================================================================================================ // ================================================================================================
void Register_CVehicle(HSQUIRRELVM vm) void Register_CVehicle(HSQUIRRELVM vm)
{ {
@ -1228,14 +1267,14 @@ void Register_CVehicle(HSQUIRRELVM vm)
.Func(_SC("_cmp"), &CVehicle::Cmp) .Func(_SC("_cmp"), &CVehicle::Cmp)
.SquirrelFunc(_SC("_typename"), &CVehicle::Typename) .SquirrelFunc(_SC("_typename"), &CVehicle::Typename)
.Func(_SC("_tostring"), &CVehicle::ToString) .Func(_SC("_tostring"), &CVehicle::ToString)
// Static values // Static Values
.SetStaticValue(_SC("MaxID"), CVehicle::Max) .SetStaticValue(_SC("MaxID"), CVehicle::Max)
// Core Properties // Core Properties
.Prop(_SC("ID"), &CVehicle::GetID) .Prop(_SC("ID"), &CVehicle::GetID)
.Prop(_SC("Tag"), &CVehicle::GetTag, &CVehicle::SetTag) .Prop(_SC("Tag"), &CVehicle::GetTag, &CVehicle::SetTag)
.Prop(_SC("Data"), &CVehicle::GetData, &CVehicle::SetData) .Prop(_SC("Data"), &CVehicle::GetData, &CVehicle::SetData)
.Prop(_SC("Active"), &CVehicle::IsActive) .Prop(_SC("Active"), &CVehicle::IsActive)
// Core Functions // Core Methods
.Func(_SC("Bind"), &CVehicle::BindEvent) .Func(_SC("Bind"), &CVehicle::BindEvent)
// Core Overloads // Core Overloads
.Overload< bool (CVehicle::*)(void) >(_SC("Destroy"), &CVehicle::Destroy) .Overload< bool (CVehicle::*)(void) >(_SC("Destroy"), &CVehicle::Destroy)
@ -1290,7 +1329,7 @@ void Register_CVehicle(HSQUIRRELVM vm)
.Prop(_SC("EX"), &CVehicle::GetERotX, &CVehicle::SetERotX) .Prop(_SC("EX"), &CVehicle::GetERotX, &CVehicle::SetERotX)
.Prop(_SC("EY"), &CVehicle::GetERotY, &CVehicle::SetERotY) .Prop(_SC("EY"), &CVehicle::GetERotY, &CVehicle::SetERotY)
.Prop(_SC("EZ"), &CVehicle::GetERotZ, &CVehicle::SetERotZ) .Prop(_SC("EZ"), &CVehicle::GetERotZ, &CVehicle::SetERotZ)
// Functions // Member Methods
.Func(_SC("StreamedFor"), &CVehicle::IsStreamedFor) .Func(_SC("StreamedFor"), &CVehicle::IsStreamedFor)
.Func(_SC("Occupant"), &CVehicle::GetOccupant) .Func(_SC("Occupant"), &CVehicle::GetOccupant)
.Func(_SC("OccupantID"), &CVehicle::GetOccupantID) .Func(_SC("OccupantID"), &CVehicle::GetOccupantID)
@ -1319,7 +1358,7 @@ void Register_CVehicle(HSQUIRRELVM vm)
.Func(_SC("ExistsHandling"), &CVehicle::ExistsHandling) .Func(_SC("ExistsHandling"), &CVehicle::ExistsHandling)
.Func(_SC("GetHandlingData"), &CVehicle::GetHandlingData) .Func(_SC("GetHandlingData"), &CVehicle::GetHandlingData)
.Func(_SC("SetHandlingData"), &CVehicle::SetHandlingData) .Func(_SC("SetHandlingData"), &CVehicle::SetHandlingData)
// Overloads // Member Overloads
.Overload< void (CVehicle::*)(const Vector3 &, bool) const > .Overload< void (CVehicle::*)(const Vector3 &, bool) const >
(_SC("SetPos"), &CVehicle::SetPositionEx) (_SC("SetPos"), &CVehicle::SetPositionEx)
.Overload< void (CVehicle::*)(Float32, Float32, Float32) const > .Overload< void (CVehicle::*)(Float32, Float32, Float32) const >
@ -1356,6 +1395,9 @@ void Register_CVehicle(HSQUIRRELVM vm)
(_SC("Embark"), &CVehicle::Embark) (_SC("Embark"), &CVehicle::Embark)
.Overload< void (CVehicle::*)(CPlayer &, Int32, bool, bool) const > .Overload< void (CVehicle::*)(CPlayer &, Int32, bool, bool) const >
(_SC("Embark"), &CVehicle::Embark) (_SC("Embark"), &CVehicle::Embark)
// Static Functions
.StaticFunc(_SC("FindByID"), &Vehicle_FindByID)
.StaticFunc(_SC("FindByTag"), &Vehicle_FindByTag)
// Static Overloads // Static Overloads
.StaticOverload< Object & (*)(Int32, Int32, Float32, Float32, Float32, Float32, Int32, Int32) > .StaticOverload< Object & (*)(Int32, Int32, Float32, Float32, Float32, Float32, Int32, Int32) >
(_SC("CreateEx"), &Vehicle_CreateEx) (_SC("CreateEx"), &Vehicle_CreateEx)