本文整理汇总了C++中CAI::GetAIWorkingMemory方法的典型用法代码示例。如果您正苦于以下问题:C++ CAI::GetAIWorkingMemory方法的具体用法?C++ CAI::GetAIWorkingMemory怎么用?C++ CAI::GetAIWorkingMemory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAI
的用法示例。
在下文中一共展示了CAI::GetAIWorkingMemory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CollectGarbage
void CAIMgr::CollectGarbage()
{
// Central memory garbage collection.
m_pAICentralMemory->CollectGarbage();
// Individual AI working memory garbage collection.
CAI::AIList::const_iterator it = CAI::GetAIList().begin();
for (; it != CAI::GetAIList().end(); ++it)
{
CAI* pAI = *it;
if (pAI)
{
pAI->GetAIWorkingMemory()->CollectGarbage();
}
}
}
示例2: DeactivateGoal
void CAIGoalCircleFlamePot::DeactivateGoal()
{
super::DeactivateGoal();
// If:
// 1) The player is an enemy.
// 2) There is another AI very close by
// 3) That AI does not have a blitz task
// ...this AI should blitz the player. This is an anti-clumping measure.
HOBJECT hTarget = m_pAI->GetAIBlackBoard()->GetBBTargetObject();
bool bShouldBlitz = false;
if ( m_pAI->HasTarget( kTarget_Character )
&& IsPlayer( hTarget ) )
{
CAI::AIList::const_iterator itEachAI = CAI::GetAIList().begin();
CAI::AIList::const_iterator itLastAI = CAI::GetAIList().end();
for ( ; itEachAI != itLastAI; ++itEachAI )
{
CAI* pCurrentAI = *itEachAI;
// Ignore NULL, self and dead AI.
if ( NULL == pCurrentAI
|| pCurrentAI == m_pAI
|| IsDeadAI( pCurrentAI->GetHOBJECT() ) )
{
continue;
}
// Ignore AIs who are far away in 2D (false positives are okay).
LTVector vDelta2D = ( pCurrentAI->GetPosition() - m_pAI->GetPosition() );
vDelta2D.y = 0.0f;
if ( vDelta2D.MagSqr() > g_flTooCloseToEnemySqr )
{
continue;
}
// Ignore AI who are already blitzing.
CAIWMFact factQuery;
factQuery.SetFactType( kFact_Task );
factQuery.SetTaskType( kTask_BlitzCharacter );
if ( pCurrentAI->GetAIWorkingMemory()->FindWMFact( factQuery ) )
{
continue;
}
// AI should blitz.
bShouldBlitz = true;
break;
}
}
if ( bShouldBlitz || ( 0 == GetRandom( 0, 2 ) ) )
{
CAIWMFact factQuery;
factQuery.SetFactType( kFact_Task );
factQuery.SetTaskType( kTask_BlitzCharacter );
CAIWMFact* pFact = m_pAI->GetAIWorkingMemory()->CreateWMFact( kFact_Task );
if ( pFact )
{
pFact->SetTaskType( kTask_BlitzCharacter );
pFact->SetTargetObject( hTarget );
pFact->SetIndex( kContext_None );
pFact->SetFactFlags( kFactFlag_Scripted, 1.f );
}
}
}
示例3: Activate
void CAITargetSelectCharacterSquad::Activate( CAI* pAI )
{
super::Activate( pAI );
// Sanity check.
if( !pAI )
{
return;
}
// Bail if AI is not in a squad.
ENUM_AI_SQUAD_ID eSquad = g_pAICoordinator->GetSquadID( pAI->m_hObject );
CAISquad* pSquad = g_pAICoordinator->FindSquad( eSquad );
if( !pSquad )
{
return;
}
// Find a squad member targeting a character.
CAI* pMember = NULL;
bool bTargetingCharacter = false;
uint32 cMembers = pSquad->GetNumSquadMembers();
LTObjRef* pMembers = pSquad->GetSquadMembers();
if( pMembers )
{
for( uint32 iMember=0; iMember < cMembers; ++iMember )
{
pMember = (CAI*)g_pLTServer->HandleToObject( pMembers[iMember] );
if( pMember && pMember->HasTarget( kTarget_Character ) )
{
break;
}
}
}
// Bail if we failed to find a squad member.
if( !pMember )
{
return;
}
// Bail if squad member is not targeting a character.
if( !pMember->HasTarget( kTarget_Character ) )
{
return;
}
HOBJECT hTarget = pMember->GetAIBlackBoard()->GetBBTargetObject();
// Bail if squad member has no memory of the character.
CAIWMFact factQuery;
factQuery.SetFactType( kFact_Character );
factQuery.SetTargetObject( hTarget );
CAIWMFact* pFact = pMember->GetAIWorkingMemory()->FindWMFact( factQuery );
if( !pFact )
{
return;
}
// Create a memory for this character.
CAIWMFact* pTargetFact;
pTargetFact = pAI->GetAIWorkingMemory()->CreateWMFact( kFact_Character );
pTargetFact->SetTargetObject( hTarget, 1.f );
EnumAIStimulusID eStimulusID;
EnumAIStimulusType eStimulusType;
pFact->GetStimulus( &eStimulusType, &eStimulusID );
pTargetFact->SetStimulus( eStimulusType, eStimulusID, 0.f );
pTargetFact->SetPos( pFact->GetPos(), 1.f );
pTargetFact->SetRadius( 0.f, 1.f );
// Target the character.
TargetCharacter( pAI, pTargetFact );
}