// 通过指定的id, 删除一个区域 unsigned long CNpcPatrolAction::DelRegion(unsigned long ulId) { CUnreachRegion* pRegion = NULL; if(m_UnreachRegionMap.count(ulId)) { pRegion = m_UnreachRegionMap[ulId]; if(pRegion) { if(m_pSceneNode) { pRegion->DetachAllEntity(); //pRegion->m_pSceneNode->removeAndDestroyAllChildren(); pRegion->DestroyAllChildSceneNode(); m_pSceneNode->removeAndDestroyChild(pRegion->m_pSceneNode->getName()); // } delete pRegion; UNREACHREGIONMAP::iterator it; it = m_UnreachRegionMap.find(ulId); m_UnreachRegionMap.erase(it); } return 0; } return 0; }
void CNpcPatrolAction::ClearRegionData() { UNREACHREGIONMAP::iterator it; UNREACHREGIONMAP::iterator itEnd; CUnreachRegion* pRegion = NULL; itEnd = m_UnreachRegionMap.end(); for(it = m_UnreachRegionMap.begin(); it != itEnd; it++) { pRegion = it->second; if(pRegion) { // 如果场景节点存在 if(m_pSceneNode) { // 删除这个区域的所有实体. pRegion->DetachAllEntity(); //pRegion->m_pSceneNode->removeAndDestroyAllChildren(); // 删除区域的所有子节点 pRegion->DestroyAllChildSceneNode(); // 删除场景节点中区域节点. m_pSceneNode->removeAndDestroyChild(pRegion->m_pSceneNode->getName()); // } delete pRegion; } } m_UnreachRegionMap.clear(); m_ulCurMaxId = 0; }