当前位置: 首页>>代码示例>>C++>>正文


C++ CGlobalEntityList::FindEntityByClassname方法代码示例

本文整理汇总了C++中CGlobalEntityList::FindEntityByClassname方法的典型用法代码示例。如果您正苦于以下问题:C++ CGlobalEntityList::FindEntityByClassname方法的具体用法?C++ CGlobalEntityList::FindEntityByClassname怎么用?C++ CGlobalEntityList::FindEntityByClassname使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CGlobalEntityList的用法示例。


在下文中一共展示了CGlobalEntityList::FindEntityByClassname方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

//-----------------------------------------------------------------------------
// Purpose: Finds the first entity within radius distance by class name.
// Input  : pStartEntity - The entity to start from when doing the search.
//			szName - Entity class name, ie "info_target".
//			vecSrc - Center of search radius.
//			flRadius - Search radius for classname search, 0 to search everywhere.
// Output : Returns a pointer to the found entity, NULL if none.
//-----------------------------------------------------------------------------
CBaseEntity *CGlobalEntityList::FindEntityByClassnameWithin( CBaseEntity *pStartEntity, const char *szName, const Vector &vecSrc, float flRadius )
{
	//
	// Check for matching class names within the search radius.
	//
	CBaseEntity *pEntity = pStartEntity;
	float flMaxDist2 = flRadius * flRadius;
	if (flMaxDist2 == 0)
	{
		return gEntList.FindEntityByClassname( pEntity, szName );
	}

	while ((pEntity = gEntList.FindEntityByClassname( pEntity, szName )) != NULL)
	{
		if ( !pEntity->edict() )
			continue;

		float flDist2 = (pEntity->GetAbsOrigin() - vecSrc).LengthSqr();

		if (flMaxDist2 > flDist2)
		{
			return pEntity;
		}
	}

	return NULL;
}
开发者ID:Au-heppa,项目名称:source-sdk-2013,代码行数:35,代码来源:entitylist.cpp

示例2:

//-----------------------------------------------------------------------------
// Purpose: Finds the first entity within radius distance by class name.
// Input  : pStartEntity - The entity to start from when doing the search.
//			szName - Entity class name, ie "info_target".
//			vecSrc - Center of search radius.
//			flRadius - Search radius for classname search, 0 to search everywhere.
// Output : Returns a pointer to the found entity, NULL if none.
//-----------------------------------------------------------------------------
CBaseEntity *CGlobalEntityList::FindEntityByClassnameWithin( CBaseEntity *pStartEntity, const char *szName, const Vector &vecSrc, float flRadius, int brushPrecision )
{
	//
	// Check for matching class names within the search radius.
	//
	CBaseEntity *pEntity = pStartEntity;
	float flMaxDist2 = flRadius * flRadius;
	if (flMaxDist2 == 0)
	{
		return gEntList.FindEntityByClassname( pEntity, szName );
	}

	while ((pEntity = gEntList.FindEntityByClassname( pEntity, szName )) != NULL)
	{
		if ( !pEntity->edict() )
			continue;

		Vector origin;
		if ( pEntity->IsBSPModel() && pEntity->CollisionProp())
		{
			if ( brushPrecision == BRUSHPRECISION_NEAREST )
				pEntity->CollisionProp()->CalcNearestPoint(vecSrc,&origin);
			else
				origin = pEntity->CollisionProp()->GetCollisionOrigin();
		}
		else
			origin = pEntity->GetAbsOrigin();


		float flDist2 = (origin - vecSrc).LengthSqr();

		if (flMaxDist2 > flDist2)
		{
			return pEntity;
		}
	}

	return NULL;
}
开发者ID:Entropy-Soldier,项目名称:ges-legacy-code,代码行数:47,代码来源:entitylist.cpp


注:本文中的CGlobalEntityList::FindEntityByClassname方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。