mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-02-22 12:47:13 +01:00
Implement function to retrieve all active objects.
This commit is contained in:
parent
534a582561
commit
6683930250
@ -594,6 +594,7 @@ static const Object & Object_FindByID(Int32 id)
|
|||||||
return NullObject();
|
return NullObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
static const Object & Object_FindByTag(CSStr tag)
|
static const Object & Object_FindByTag(CSStr tag)
|
||||||
{
|
{
|
||||||
// Perform a validity check on the specified tag
|
// Perform a validity check on the specified tag
|
||||||
@ -615,6 +616,35 @@ static const Object & Object_FindByTag(CSStr tag)
|
|||||||
return NullObject();
|
return NullObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static Array Object_FindActive()
|
||||||
|
{
|
||||||
|
// Remember the initial stack size
|
||||||
|
StackGuard sg;
|
||||||
|
// Obtain the ends of the entity pool
|
||||||
|
Core::Objects::const_iterator itr = _Core->GetObjects().cbegin();
|
||||||
|
Core::Objects::const_iterator end = _Core->GetObjects().cend();
|
||||||
|
// Allocate an empty array on the stack
|
||||||
|
sq_newarray(DefaultVM::Get(), 0);
|
||||||
|
// Process each entity in the pool
|
||||||
|
for (; itr != end; ++itr)
|
||||||
|
{
|
||||||
|
// Is this entity instance active?
|
||||||
|
if (VALID_ENTITY(itr->mID))
|
||||||
|
{
|
||||||
|
// Push the script object on the stack
|
||||||
|
sq_pushobject(DefaultVM::Get(), (HSQOBJECT &)((*itr).mObj));
|
||||||
|
// Append the object at the back of the array
|
||||||
|
if (SQ_FAILED(sq_arrayappend(DefaultVM::Get(), -1)))
|
||||||
|
{
|
||||||
|
STHROWF("Unable to append entity instance to the list");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Return the array at the top of the stack
|
||||||
|
return Var< Array >(DefaultVM::Get(), -1).value;
|
||||||
|
}
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
void Register_CObject(HSQUIRRELVM vm)
|
void Register_CObject(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
@ -690,6 +720,7 @@ void Register_CObject(HSQUIRRELVM vm)
|
|||||||
// Static Functions
|
// Static Functions
|
||||||
.StaticFunc(_SC("FindByID"), &Object_FindByID)
|
.StaticFunc(_SC("FindByID"), &Object_FindByID)
|
||||||
.StaticFunc(_SC("FindByTag"), &Object_FindByTag)
|
.StaticFunc(_SC("FindByTag"), &Object_FindByTag)
|
||||||
|
.StaticFunc(_SC("FindActive"), &Object_FindActive)
|
||||||
// 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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user