#ifndef ECOSYSTEME_ANIMAL_TEMPLATE_HPP #define ECOSYSTEME_ANIMAL_TEMPLATE_HPP 1 template void Animal::rechercheEspece(int i, std::vector &animaux) noexcept { for(auto it: Univers::m_organismes_univers[m_univers_ID]) { if(it->position().first == i) { // vérification index if(auto animal = dynamic_cast(it)) { // vérification espece if(genre != animal->genre) { // vérification genre if(animal->m_partenaire == nullptr) { // animal pas déjà occupé animaux.push_back(animal); return; } } } } } } template void Animal::animauxEnvirons(std::vector &animaux) noexcept { int longueur_univers = Univers::m_dimensions_univers[m_univers_ID].first, taille_max_univers = longueur_univers * Univers::m_dimensions_univers[m_univers_ID].second, i; // En haut à gauche i = m_index - longueur_univers - 1; if(i >= 0 && i % longueur_univers < longueur_univers - 1) { rechercheEspece(i, animaux); } // En haut i = m_index - longueur_univers; if(i >= 0) { rechercheEspece(i, animaux); } // En haut à droite i = m_index - longueur_univers + 1; if(i >= 0 && i % longueur_univers != 0) { rechercheEspece(i, animaux); } // A gauche i = m_index - 1; if(i >= 0 && i % longueur_univers < longueur_univers - 1) { rechercheEspece(i, animaux); } // A droite i = m_index + 1; if(i < taille_max_univers && i % longueur_univers != 0) { rechercheEspece(i, animaux); } // En bas à gauche i = m_index + longueur_univers - 1; if(i < taille_max_univers && i % longueur_univers < longueur_univers - 1) { rechercheEspece(i, animaux); } // En bas i = m_index + longueur_univers; if(i < taille_max_univers) { rechercheEspece(i, animaux); } // En bas à droite i = m_index + longueur_univers + 1; if(i < taille_max_univers && i % longueur_univers != 0) { rechercheEspece(i, animaux); } } #endif