Пример #1
0
/**
 * \brief Checks the collisions between an entity and the detectors of the map.
 *
 * This function is called by an entity sensitive to the entity detectors
 * when this entity has just moved on the map, or when a detector
 * wants to check this entity.
 * We check whether or not the entity overlaps an entity detector.
 * If the map is suspended, this function does nothing.
 *
 * \param entity the entity that has just moved (this entity should have
 * a movement sensible to the collisions)
 */
void Map::check_collision_with_detectors(MapEntity& entity) {

  if (suspended) {
    return;
  }

  const std::list<Detector*>& detectors = entities->get_detectors();

  // Check each detector.
  std::list<Detector*>::const_iterator it;
  const std::list<Detector*>::const_iterator end = detectors.end();
  for (it = detectors.begin(); it != end; ++it) {

    Detector* detector = *it;
    if (detector->is_enabled()
        && !detector->is_being_removed()) {
      detector->check_collision(entity);
    }
  }
}