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


C++ CBaseEntity::GetAbsMaxs方法代码示例

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


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

示例1: FriendNumber

CBaseEntity	*CAI_PlayerAlly::EnumFriends( CBaseEntity *pPrevious, int listNumber, bool bTrace )
{
	CBaseEntity *pFriend = pPrevious;
	char *pszFriend;
	trace_t tr;
	Vector vecCheck;

	pszFriend = m_szFriends[ FriendNumber(listNumber) ];
	while (pFriend = gEntList.FindEntityByClassname( pFriend, pszFriend ))
	{
		if (pFriend == this || !pFriend->IsAlive())
			// don't talk to self or dead people
			continue;
		if ( bTrace )
		{
			vecCheck = pFriend->GetAbsOrigin();
			vecCheck.z = pFriend->GetAbsMaxs().z;

			UTIL_TraceLine( GetAbsOrigin(), vecCheck, MASK_SOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &tr);
		}
		else
			tr.fraction = 1.0;

		if (tr.fraction == 1.0)
		{
			return pFriend;
		}
	}

	return NULL;
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:31,代码来源:npc_talker.cpp

示例2: GetAbsOrigin

//=========================================================
// FindNearestFriend
// Scan for nearest, visible friend. If fPlayer is true, look for
// nearest player
//=========================================================
CBaseEntity *CAI_PlayerAlly::FindNearestFriend(bool fPlayer)
{
	CBaseEntity *pFriend = NULL;
	CBaseEntity *pNearest = NULL;
	float range = 10000000.0;
	trace_t tr;
	Vector vecStart = GetAbsOrigin();
	Vector vecCheck;
	int i;
	const char *pszFriend;
	int cfriends;

	vecStart.z = GetAbsMaxs().z;
	
	if (fPlayer)
		cfriends = 1;
	else
		cfriends = TLK_CFRIENDS;

	// for each type of friend...

	for (i = cfriends-1; i > -1; i--)
	{
		if (fPlayer)
		{
			CBaseEntity *pPlayer = UTIL_PlayerByIndex(1);
			if ( pPlayer )
			{
				pszFriend = STRING(pPlayer->m_iClassname);
			}
			else
			{
				pszFriend = "player";
			}
		}
		else
			pszFriend = m_szFriends[FriendNumber(i)];

		if (!pszFriend)
			continue;

		// for each friend in this bsp...
		while (pFriend = gEntList.FindEntityByClassname( pFriend, pszFriend ))
		{
			if (pFriend == this || !pFriend->IsAlive())
				// don't talk to self or dead people
				continue;

			CAI_BaseNPC *pNPC = pFriend->MyNPCPointer();

			// If not a NPC for some reason, or in a script.
			if ( pNPC && (pNPC->m_NPCState == NPC_STATE_SCRIPT || pNPC->m_NPCState == NPC_STATE_PRONE))
				continue;

			if( pNPC && pNPC->IsSelected() )
			{
				// Don't bother people that are awaiting orders.
				return false;
			}

			vecCheck = pFriend->GetLocalOrigin();
			vecCheck.z = pFriend->GetAbsMaxs().z;

			// if closer than previous friend, and in range, see if he's visible

			if (range > (vecStart - vecCheck).Length())
			{
				UTIL_TraceLine(vecStart, vecCheck, MASK_SOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &tr);

				if (tr.fraction == 1.0)
				{
					// visible and in range, this is the new nearest scientist
					if ((vecStart - vecCheck).Length() < TALKRANGE_MIN)
					{
						pNearest = pFriend;
						range = (vecStart - vecCheck).Length();
					}
				}
			}
		}
	}
	return pNearest;
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:88,代码来源:npc_talker.cpp


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