本文整理汇总了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;
}
示例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 );
}
}
示例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;
}