本文整理汇总了C++中CAI_Hint::HintMatchesCriteria方法的典型用法代码示例。如果您正苦于以下问题:C++ CAI_Hint::HintMatchesCriteria方法的具体用法?C++ CAI_Hint::HintMatchesCriteria怎么用?C++ CAI_Hint::HintMatchesCriteria使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAI_Hint
的用法示例。
在下文中一共展示了CAI_Hint::HintMatchesCriteria方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindAllHints
//-----------------------------------------------------------------------------
int CAI_HintManager::FindAllHints( CAI_BaseNPC *pNPC, const Vector &position, const CHintCriteria &hintCriteria, CUtlVector<CAI_Hint *> *pResult )
{
// If we have no hints, bail
int c = CAI_HintManager::gm_AllHints.Count();
if ( !c )
return NULL;
// Remove the nearest flag. It makes now sense with random.
bool hadNearest = hintCriteria.HasFlag( bits_HINT_NODE_NEAREST );
(const_cast<CHintCriteria &>(hintCriteria)).ClearFlag( bits_HINT_NODE_NEAREST );
// Now loop till we find a valid hint or return to the start
CAI_Hint *pTestHint;
for ( int i = 0; i < c; ++i )
{
pTestHint = CAI_HintManager::gm_AllHints[ i ];
Assert( pTestHint );
if ( pTestHint->HintMatchesCriteria( pNPC, hintCriteria, position, NULL ) )
pResult->AddToTail( pTestHint );
}
if ( hadNearest )
(const_cast<CHintCriteria &>(hintCriteria)).SetFlag( bits_HINT_NODE_NEAREST );
return pResult->Count();
}
示例2: defined
//-----------------------------------------------------------------------------
// Purpose:
// Input : *hintCriteria -
// Output : CAI_Hint
//-----------------------------------------------------------------------------
CAI_Hint *CAI_HintManager::FindHint( CAI_BaseNPC *pNPC, const Vector &position, const CHintCriteria &hintCriteria )
{
#if defined( HINT_PROFILING )
CFastTimer timer;
timer.Start();
#endif
bool singleType = hintCriteria.MatchesSingleHintType();
bool lookingForNearest = hintCriteria.HasFlag( bits_HINT_NODE_NEAREST );
bool bIgnoreHintType = true;
CUtlVector< CAIHintVector * > lists;
if ( singleType )
{
int slot = CAI_HintManager::gm_TypedHints.Find( hintCriteria.GetFirstHintType() );
if ( slot != CAI_HintManager::gm_TypedHints.InvalidIndex() )
{
lists.AddToTail( &CAI_HintManager::gm_TypedHints[ slot ] );
}
}
else
{
int typeCount = hintCriteria.NumHintTypes();
if ( typeCount > 0 )
{
for ( int listType = 0; listType < typeCount; ++listType )
{
int slot = CAI_HintManager::gm_TypedHints.Find( hintCriteria.GetHintType( listType ) );
if ( slot != CAI_HintManager::gm_TypedHints.InvalidIndex() )
{
lists.AddToTail( &CAI_HintManager::gm_TypedHints[ slot ] );
}
}
}
else
{
// Still need to check hint type in this case
lists.AddToTail( &CAI_HintManager::gm_AllHints );
bIgnoreHintType = false;
}
}
CAI_Hint *pBestHint = NULL;
int visited = 0;
int listCount = lists.Count();
if ( listCount == 0 )
return NULL;
// Try the fast match path
int i, count;
// Start with hint after the last one used
CAI_Hint *pTestHint = NULL;
float flBestDistance = MAX_TRACE_LENGTH;
if ( !lookingForNearest )
{
// Fast check of previous results
count = CAI_HintManager::GetFoundHintCount();
for ( i = 0; i < count; ++i )
{
pTestHint = CAI_HintManager::GetFoundHint( i );
if ( pTestHint )
{
Assert( dynamic_cast<CAI_Hint *>(pTestHint) != NULL );
++visited;
if ( pTestHint->HintMatchesCriteria( pNPC, hintCriteria, position, &flBestDistance ) )
{
#if defined( HINT_PROFILING )
Msg( "fast result visited %d\n", visited );
#endif
return pTestHint;
}
}
}
}
// Longer search, reset best distance
flBestDistance = MAX_TRACE_LENGTH;
for ( int listNum = 0; listNum < listCount; ++listNum )
{
CAIHintVector *list = lists[ listNum ];
count = list->Count();
// -------------------------------------------
// If we have no hints, bail
// -------------------------------------------
if ( !count )
continue;
// Now loop till we find a valid hint or return to the start
for ( i = 0 ; i < count; ++i )
{
//.........这里部分代码省略.........