Source SDK

Source SDK

Not enough ratings
UTIL_EntitiesInBox
By Effluvia
это UTIL, предоставленный в Исходном коде для поиска сущностей в указанном поле. Он принимает список сущностей, мин, максимумы и флаги , возвращая количество сущностей, а также список.

   
Award
Favorite
Favorited
Unfavorite
Предисловие
Информация расписанная снизу принадлежит Valve
Моя задача была - перевод на русский язык | адаптация к Steam
Содержание
Использование
//----------------------------------------------------------------------------- // Purpose: Returns the number of entities in the box, plus an array of pointers to the entities. // // Input : CBaseEntity - *pList | A pointer to an array, the function will store a pointer to the Entities it finds in this array. // Input : int - listMax | Maximum number of entities to return // Input : Vector - &mins | The mins of a box to check. World space coordinate. // Input : Vector - &maxs | The maxs of a box to check. World space coordinate. // Input : int - flagmask | // Output : *pList // Output : int - Returns the amount of entities it finds //----------------------------------------------------------------------------- inline int UTIL_EntitiesInBox( CBaseEntity **pList, int listMax, const Vector &mins, const Vector &maxs, int flagMask )

//----------------------------------------------------------------------------- // Purpose: Returns the number of entities in the box. // // Input : Vector - &mins | The mins of a box to check. World space coordinate. // Input : Vector - &maxs | The maxs of a box to check. World space coordinate. // Input : CFlaggedEntitiesEnum *pEnum | TODO // Output : int - Returns the amount of entities it finds //----------------------------------------------------------------------------- int UTIL_EntitiesInBox( const Vector &mins, const Vector &maxs, CFlaggedEntitiesEnum *pEnum );
flagmask доступен в const.h, lines 97-132

Примеры
//Create an array of CBaseEntity pointers CBaseEntity* pList[20]; //Put the pointers in the pList, and get how many entities there are int count = UTIL_EntitiesInBox( pList, 20, spawnOrigin + NAI_Hull::Mins( HULL_MEDIUM ), spawnOrigin + NAI_Hull::Maxs( HULL_MEDIUM ), 0 ); //Iterate over all the possible targets for ( int i = 0; i < count; i++ ) { //If the particular entity's movetype isn't MOVETYPE_VPHYSICS, skip the rest of this loop, and go to the next entity if ( pList->GetMoveType() != MOVETYPE_VPHYSICS )
continue;

if ( PhysGetEntityMass( pList ) > ANTLION_MAKER_BLOCKED_MASS )
{
bBlocked = true;
iNumBlocked++;
pBlocker = pList;

if ( pTestHint == pNode )
{
bChosenHintBlocked = true;
}

break;
}
} [/code]

//This uses the overloaded function, and only returns the number of entities. CBaseEntity *entityList[64]; Vector range(ROLLERMINE_WAKEUP_DIST,ROLLERMINE_WAKEUP_DIST,64); int boxCount = UTIL_EntitiesInBox( entityList, ARRAYSIZE(entityList), GetAbsOrigin()-range, GetAbsOrigin()+range, FL_NPC );