CAIHumanStateAttackMove::~CAIHumanStateAttackMove() { AI_FACTORY_DELETE(m_pStrategyFollowPath); AI_FACTORY_DELETE(m_pStrategyShoot); // Decrement attack counter. if( GetAI() ) { g_pAICentralKnowledgeMgr->RemoveKnowledge( kCK_Attacking, GetAI() ); AIASSERT( !g_pAICentralKnowledgeMgr->CountMatches( kCK_Attacking, GetAI() ), GetAI()->m_hObject, "~CAIHumanStateAttackMove: Too many attackers registered!" ); } }
void CAICentralKnowledgeMgr::RemoveKnowledge(EnumAICentralKnowledgeType eKnowledgeType, ILTBaseClass *pAI, ILTBaseClass *pKnowledgeTarget) { AIASSERT( pAI, LTNULL, "CAICentralKnowledgeMgr::RemoveKnowledge: Knowledge removal request without an associated AI." ); AIASSERT( eKnowledgeType != kCK_InvalidType, pAI->m_hObject, "CAICentralKnowledgeMgr::RemoveKnowledge: Knowledge needs a valid type." ); CAICentralKnowledgeRecord* pAICentralKnowledgeRecord; // Note: It is assumed that there are not multiple identical knowledge records. // Iterate over matching knowledge types. AICENTRAL_KNOWLEDGE_MAP::iterator it; for( it = m_mapCentralKnowledge.lower_bound( eKnowledgeType ); it != m_mapCentralKnowledge.upper_bound( eKnowledgeType ); ++it ) { pAICentralKnowledgeRecord = it->second; if( ( pAICentralKnowledgeRecord->m_pAI == pAI ) && ( pAICentralKnowledgeRecord->m_pKnowledgeTarget == pKnowledgeTarget ) ) { AI_FACTORY_DELETE( pAICentralKnowledgeRecord ); m_mapCentralKnowledge.erase( it ); return; } } }
void CAICentralKnowledgeMgr::Load(ILTMessage_Read *pMsg) { EnumAICentralKnowledgeType eKnowledgeType; uint32 cKnowledge; LOAD_DWORD(cKnowledge); CAICentralKnowledgeRecord* pAICentralKnowledgeRecord; for( uint32 iKnowledge=0; iKnowledge < cKnowledge; ++iKnowledge ) { LOAD_DWORD_CAST( eKnowledgeType, EnumAICentralKnowledgeType ); pAICentralKnowledgeRecord = AI_FACTORY_NEW( CAICentralKnowledgeRecord ); pAICentralKnowledgeRecord->Load(pMsg); // Some Knowledge records may have handles to objects that have transitioned // to a new level. Delete these records. if( ( !pAICentralKnowledgeRecord->m_pAI ) || ( !pAICentralKnowledgeRecord->m_pKnowledgeTarget ) ) { AI_FACTORY_DELETE( pAICentralKnowledgeRecord ); } else { m_mapCentralKnowledge.insert( AICENTRAL_KNOWLEDGE_MAP::value_type( eKnowledgeType, pAICentralKnowledgeRecord ) ); } } }
void CAICentralKnowledgeMgr::OnLinkBroken( LTObjRefNotifier *pRef, HOBJECT hObj ) { AICENTRAL_KNOWLEDGE_MAP::iterator it = m_mapCentralKnowledge.begin(); while( it != m_mapCentralKnowledge.end() ) { if( ( it->second->m_bLinkKnowledge ) && ( ( &it->second->m_hAI == pRef ) || ( &it->second->m_hKnowledgeTarget == pRef ) ) ) { AI_FACTORY_DELETE(it->second); AICENTRAL_KNOWLEDGE_MAP::iterator next = it; ++next; m_mapCentralKnowledge.erase(it); it = next; } else { // If knowledge is not linked, the record will // exist after the objects it references are destroyed. // NULLify the pointers to objects that are being unlinked. if( &it->second->m_hAI == pRef ) { it->second->m_pAI = LTNULL; } if( &it->second->m_hKnowledgeTarget ) { it->second->m_pKnowledgeTarget = LTNULL; } ++it; } } }
void CAIGoalMgr::RemoveGoal(EnumAIGoalType eGoalType) { ASSERT(eGoalType != kGoal_InvalidType); // Find goal of specified type. CAIGoalAbstract* pGoal; AIGOAL_LIST::iterator it; for(it = m_lstGoals.begin(); it != m_lstGoals.end(); ++it) { pGoal = *it; if(pGoal->GetGoalType() == eGoalType) { if(m_pCurGoal == pGoal) { m_pCurGoal = NULL; } // Delete the goal. pGoal->TermGoal(); AI_FACTORY_DELETE(pGoal); m_lstGoals.erase(it); return; } } }
void CAISensorMgr::TermAISensorMgr() { // Delete instances of sensors. AISENSOR_LIST::iterator itSensor; for( itSensor = m_lstAISensors.begin(); itSensor != m_lstAISensors.end(); ++itSensor ) { AI_FACTORY_DELETE( *itSensor ); } m_lstAISensors.resize( 0 ); }
void CAICentralKnowledgeMgr::Term() { ASSERT(g_pAICentralKnowledgeMgr != NULL); AICENTRAL_KNOWLEDGE_MAP::iterator it; for(it = m_mapCentralKnowledge.begin(); it != m_mapCentralKnowledge.end(); ++it ) { AI_FACTORY_DELETE(it->second); } // Remove all entries. m_mapCentralKnowledge.clear( ); }
CAIPlan::~CAIPlan() { DeactivatePlan(); // Delete the plan. CAIPlanStep* pPlanStep; AIPLAN_STEP_LIST::iterator itPlan; for( itPlan = m_lstAIPlanSteps.begin(); itPlan != m_lstAIPlanSteps.end(); ++itPlan ) { pPlanStep = *itPlan; AI_FACTORY_DELETE( pPlanStep ); } m_lstAIPlanSteps.resize( 0 ); }
AISENSOR_LIST::iterator CAISensorMgr::DeleteAISensor( EnumAISensorType eSensorType ) { // Delete instance of a sensor. CAISensorAbstract* pSensor; AISENSOR_LIST::iterator itSensor; for( itSensor = m_lstAISensors.begin(); itSensor != m_lstAISensors.end(); ++itSensor ) { pSensor = *itSensor; if( pSensor->GetSensorType() == eSensorType ) { AI_FACTORY_DELETE( pSensor ); return m_lstAISensors.erase( itSensor ); } } return m_lstAISensors.end(); }
void CAICentralKnowledgeMgr::RemoveAllKnowledge(EnumAICentralKnowledgeType eKnowledgeType, ILTBaseClass *pAI) { AIASSERT( pAI, LTNULL, "CAICentralKnowledgeMgr::RemoveAllKnowledge: Knowledge removal request without an associated AI." ); AIASSERT( eKnowledgeType != kCK_InvalidType, pAI->m_hObject, "CAICentralKnowledgeMgr::RemoveAllKnowledge: Knowledge needs a valid type." ); CAICentralKnowledgeRecord* pAICentralKnowledgeRecord; // Iterate over matching knowledge types. AICENTRAL_KNOWLEDGE_MAP::iterator it; for( it = m_mapCentralKnowledge.lower_bound( eKnowledgeType ); it != m_mapCentralKnowledge.upper_bound( eKnowledgeType ); ++it ) { pAICentralKnowledgeRecord = it->second; AI_FACTORY_DELETE( pAICentralKnowledgeRecord ); } // Remove all matching keys. m_mapCentralKnowledge.erase( eKnowledgeType ); }
CAIHumanStateObstruct::~CAIHumanStateObstruct() { AI_FACTORY_DELETE( m_pStrategyFollowPath ); }