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


C++ CAI_BaseNPC::DispatchInteraction方法代码示例

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


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

示例1: FindEntity

//------------------------------------------------------------------------------
// Purpose:
//------------------------------------------------------------------------------
CBaseEntity* CScriptedTarget::FindEntity( void )
{
	// ---------------------------------------------------
	//	First try to find the entity by name
	// ---------------------------------------------------
	CBaseEntity *pEntity = gEntList.FindEntityByName( NULL, m_iszEntity );
	if (pEntity && pEntity->GetFlags() & FL_NPC)
	{
		CAI_BaseNPC* pNPC	= pEntity->MyNPCPointer();
		if (pNPC->DispatchInteraction( g_interactionScriptedTarget, NULL, this ))
		{
			return pEntity;
		}
	}

	// ---------------------------------------------------
	//	If that fails, assume we were given a classname
	//  and find nearest entity in radius of that class
	// ---------------------------------------------------
	float			flNearestDist	= MAX_COORD_RANGE;
	CBaseEntity*	pNearestEnt		= NULL;
	CBaseEntity*	pTestEnt		= NULL;

	for ( CEntitySphereQuery sphere( GetAbsOrigin(), m_flRadius ); ( pTestEnt = sphere.GetCurrentEntity() ) != NULL; sphere.NextEntity() )
	{
		if (pTestEnt->GetFlags() & FL_NPC)
		{
			if (FClassnameIs( pTestEnt, STRING(m_iszEntity)))
			{
				float flTestDist = (pTestEnt->GetAbsOrigin() - GetAbsOrigin()).Length();
				if (flTestDist < flNearestDist)
				{
					flNearestDist	= flTestDist;
					pNearestEnt		= pTestEnt;
				}
			}
		}
	}
	
	// UNDONE: If nearest fails, try next nearest
	if (pNearestEnt)
	{
		CAI_BaseNPC* pNPC	= pNearestEnt->MyNPCPointer();
		if (pNPC->DispatchInteraction( g_interactionScriptedTarget, NULL, this ))
		{
			return pNearestEnt;
		}
	}

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

示例2: TurnOff

//------------------------------------------------------------------------------
// Purpose:
//------------------------------------------------------------------------------
void CScriptedTarget::TurnOff( void )
{
	SetThink( NULL );
	m_iDisabled		= true;

	// If I have a target entity, free him
	if (GetTarget())
	{
		CAI_BaseNPC* pNPC	= GetTarget()->MyNPCPointer();
		pNPC->DispatchInteraction( g_interactionScriptedTarget, NULL, NULL );
	}
}
开发者ID:Au-heppa,项目名称:source-sdk-2013,代码行数:15,代码来源:scriptedtarget.cpp

示例3:

int	CAI_Squad::BroadcastInteraction( int interactionType, void *data, CBaseCombatCharacter *sender )
{
	//Must have a squad
	if ( m_SquadMembers.Count() == 0 )
		return false;

	//Broadcast to all members of the squad
	for ( int i = 0; i < m_SquadMembers.Count(); i++ )
	{
		CAI_BaseNPC *pMember = m_SquadMembers[i]->MyNPCPointer();
		
		//Validate and don't send again to the sender
		if ( ( pMember != NULL) && ( pMember != sender ) )
		{
			//Send it
			pMember->DispatchInteraction( interactionType, data, sender );
		}
	}

	return true;
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:21,代码来源:ai_squad.cpp


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