예제 #1
0
/**
 * \brief Returns whether there exists at least one entity with the specified
 * name prefix on the map.
 * \param prefix Prefix of the name.
 * \return \c true if there exists an entity with this prefix.
 */
bool MapEntities::has_entity_with_prefix(const std::string& prefix) {

  list<MapEntity*>::iterator i;
  for (i = all_entities.begin(); i != all_entities.end(); i++) {

    MapEntity* entity = *i;
    if (entity->has_prefix(prefix) && !entity->is_being_removed()) {
      return true;
    }
  }

  return false;
}
예제 #2
0
파일: MapEntities.cpp 프로젝트: ziz/solarus
/**
 * @brief Returns the entity with the specified type and name, or NULL if it doesn't exist.
 * @param type type of entity
 * @param name name of the entity to get
 * @return the entity requested, or NULL if there is no entity with the specified type and name
 */
MapEntity* MapEntities::find_entity(EntityType type, const std::string &name) {

  list<MapEntity*>::iterator i;
  for (i = all_entities.begin(); i != all_entities.end(); i++) {

    MapEntity *entity = *i;
    if (entity->get_type() == type && entity->get_name() == name && !entity->is_being_removed()) {
      return entity;
    }
  }

  return NULL;
}
예제 #3
0
/**
 * \brief Returns the entity with the specified name, or NULL if it doesn't exist.
 * \param name Name of the entity to find.
 * \return The entity requested, or NULL if there is no entity with the specified name.
 */
MapEntity* MapEntities::find_entity(const std::string& name) {

  if (named_entities.find(name) == named_entities.end()) {
    return NULL;
  }

  MapEntity* entity = named_entities[name];

  if (entity->is_being_removed()) {
    return NULL;
  }

  return entity;
}
예제 #4
0
/**
 * \brief Returns the entities of the map having the specified name prefix.
 * \param prefix Prefix of the name.
 * \return The entities of this type and having this prefix in their name.
 */
list<MapEntity*> MapEntities::get_entities_with_prefix(const std::string& prefix) {

  list<MapEntity*> entities;

  list<MapEntity*>::iterator i;
  for (i = all_entities.begin(); i != all_entities.end(); i++) {

    MapEntity* entity = *i;
    if (entity->has_prefix(prefix) && !entity->is_being_removed()) {
      entities.push_back(entity);
    }
  }

  return entities;
}
예제 #5
0
파일: MapEntities.cpp 프로젝트: ziz/solarus
/**
 * @brief Returns all entities of the map with the specified type.
 * @param type type of entity
 * @return the entities of this type
 */
list<MapEntity*> MapEntities::get_entities(EntityType type) {

  list<MapEntity*> entities;

  list<MapEntity*>::iterator i;
  for (i = all_entities.begin(); i != all_entities.end(); i++) {

    MapEntity *entity = *i;
    if (entity->get_type() == type && !entity->is_being_removed()) {
      entities.push_back(entity);
    }
  }

  return entities;
}