FIFE
|
A container of Layer(s)
.
More...
#include <map.h>
Public Member Functions | |
Map (const std::string &identifier, RenderBackend *renderbackend, const std::vector< RendererBase * > &renderers, TimeProvider *tp_master=NULL) | |
Construct a map To add map to model, one should call Model::addMap (otherwise map is not registered with the engine properly) More... | |
~Map () | |
Destructor. More... | |
const std::string & | getId () const |
Get the identifier for this map. More... | |
void | setId (const std::string &id) |
Sets the identifier for this map. More... | |
Layer * | createLayer (const std::string &identifier, CellGrid *grid) |
Add a Layer to this Map. More... | |
void | deleteLayer (Layer *) |
Delete a layer from the map. More... | |
const std::list< Layer * > & | getLayers () const |
Get the layers on this map. More... | |
Layer * | getLayer (const std::string &identifier) |
Get the layer with the given id. More... | |
uint32_t | getLayerCount () const |
Get the overall number of layers. More... | |
void | deleteLayers () |
Delete all layers from the map. More... | |
void | getMatchingCoordinates (const ModelCoordinate &coord_to_map, const Layer *from_layer, const Layer *to_layer, std::vector< ModelCoordinate > &matching_coords) const |
Maps coordinate from one layer to another. More... | |
void | getMinMaxCoordinates (ExactModelCoordinate &min, ExactModelCoordinate &max) |
Retrieves the minimum/maximum coordinates of instances on the map. More... | |
bool | update () |
Called periodically to update events on map. More... | |
void | setTimeMultiplier (float multip) |
Sets speed for the map. More... | |
float | getTimeMultiplier () const |
Gets model speed. More... | |
TimeProvider * | getTimeProvider () |
Gets timeprovider used in the map. More... | |
void | addChangeListener (MapChangeListener *listener) |
Adds new change listener. More... | |
void | removeChangeListener (MapChangeListener *listener) |
Removes associated change listener. More... | |
bool | isChanged () |
Returns true, if map information was changed during previous update round. More... | |
std::vector< Layer * > & | getChangedLayers () |
Returns layers that were changed during previous update round. More... | |
Camera * | addCamera (const std::string &id, Layer *layer, const Rect &viewport) |
Adds camera to the map. More... | |
void | removeCamera (const std::string &id) |
Removes a camera from the map. More... | |
Camera * | getCamera (const std::string &id) |
Get a camera by its identifier. More... | |
const std::vector< Camera * > & | getCameras () const |
Get a list containing all cameras. More... | |
void | setFilename (const std::string &file) |
const std::string & | getFilename () const |
void | addInstanceForTransfer (Instance *instance, const Location &target) |
Adds instance that is to be transferred to another layer. More... | |
void | removeInstanceForTransfer (Instance *instance) |
Removes instance that should be transferred to another layer. More... | |
void | initializeCellCaches () |
Creates cellcaches for this map. More... | |
void | finalizeCellCaches () |
Creates cellcaches for this map. More... | |
![]() | |
FifeClass () | |
virtual | ~FifeClass () |
fifeid_t | getFifeId () |
Gets unique id of this instance inside the engine. More... | |
Private Member Functions | |
Map (const Map &map) | |
Map & | operator= (const Map &map) |
Private Attributes | |
std::string | m_id |
std::string | m_filename |
std::list< Layer * > | m_layers |
TimeProvider | m_timeProvider |
std::vector< MapChangeListener * > | m_changeListeners |
listeners for map changes More... | |
std::vector< Layer * > | m_changedLayers |
holds changed layers after each update More... | |
std::vector< Camera * > | m_cameras |
holds the cameras attached to this map More... | |
RenderBackend * | m_renderBackend |
pointer to renderbackend More... | |
std::vector< RendererBase * > | m_renderers |
holds handles to all created renderers More... | |
bool | m_changed |
true, if something was changed on map during previous update (layer change, creation, deletion) More... | |
std::map< Instance *, Location > | m_transferInstances |
holds instances which should be transferred on the next update More... | |
FIFE::Map::Map | ( | const std::string & | identifier, |
RenderBackend * | renderbackend, | ||
const std::vector< RendererBase * > & | renderers, | ||
TimeProvider * | tp_master = NULL |
||
) |
FIFE::Map::~Map | ( | ) |
|
private |
Adds camera to the map.
The Map takes ownership of the camera so don't delete it.
Definition at line 241 of file map.cpp.
References FIFE::Camera::addRenderer(), getCamera(), m_cameras, m_renderBackend, and m_renderers.
Referenced by FIFE::MapLoader::load().
void FIFE::Map::addChangeListener | ( | MapChangeListener * | listener | ) |
Adds new change listener.
listener | to add |
Definition at line 226 of file map.cpp.
References m_changeListeners.
Referenced by FIFE::Camera::updateMap().
Adds instance that is to be transferred to another layer.
instance | A pointer to the instance that is to be transferred. |
target | A const reference to the target location. |
Definition at line 295 of file map.cpp.
References FIFE::Location::getExactLayerCoordinates(), FIFE::Location::getLayer(), m_transferInstances, FIFE::Location::setExactLayerCoordinates(), and FIFE::Location::setLayer().
Referenced by FIFE::Instance::processMovement().
Map owns the returned pointer to the new Layer, so don't delete it!
Definition at line 82 of file map.cpp.
References m_changed, m_changeListeners, and m_layers.
Referenced by FIFE::MapLoader::load().
void FIFE::Map::deleteLayer | ( | Layer * | layer | ) |
Delete a layer from the map.
Definition at line 101 of file map.cpp.
References m_changed, m_changeListeners, and m_layers.
void FIFE::Map::deleteLayers | ( | ) |
Delete all layers from the map.
Definition at line 118 of file map.cpp.
References m_changeListeners, and m_layers.
Referenced by ~Map().
void FIFE::Map::finalizeCellCaches | ( | ) |
Creates cellcaches for this map.
Called from maploader.
Definition at line 335 of file map.cpp.
References FIFE::CellCache::createCells(), FIFE::CellCache::forceUpdate(), and m_layers.
Referenced by FIFE::MapLoader::load().
Camera * FIFE::Map::getCamera | ( | const std::string & | id | ) |
Get a camera by its identifier.
Definition at line 280 of file map.cpp.
References m_cameras.
Referenced by addCamera().
const std::vector< Camera * > & FIFE::Map::getCameras | ( | ) | const |
Get a list containing all cameras.
Definition at line 291 of file map.cpp.
References m_cameras.
Referenced by FIFE::MapSaver::save().
|
inline |
Returns layers that were changed during previous update round.
Definition at line 177 of file map.h.
References m_changedLayers.
|
inline |
Definition at line 197 of file map.h.
References m_filename.
|
inline |
Get the identifier for this map.
Definition at line 103 of file map.h.
References m_id.
Referenced by FIFE::MapSaver::save().
Layer * FIFE::Map::getLayer | ( | const std::string & | identifier | ) |
Get the layer with the given id.
Definition at line 69 of file map.cpp.
References m_layers.
Referenced by initializeCellCaches(), FIFE::MapLoader::load(), and FIFE::Layer::~Layer().
uint32_t FIFE::Map::getLayerCount | ( | ) | const |
Get the overall number of layers.
Definition at line 78 of file map.cpp.
References m_layers.
Referenced by FIFE::InstanceRenderer::renderUnsorted().
|
inline |
Get the layers on this map.
Definition at line 119 of file map.h.
References m_layers.
Referenced by FIFE::RendererBase::activateAllLayers(), FIFE::Camera::render(), FIFE::InstanceRenderer::renderUnsorted(), FIFE::MapSaver::save(), FIFE::MultiLayerSearch::searchBetweenTargetsMap(), FIFE::Camera::updateMap(), and FIFE::Camera::updateRenderLists().
void FIFE::Map::getMatchingCoordinates | ( | const ModelCoordinate & | coord_to_map, |
const Layer * | from_layer, | ||
const Layer * | to_layer, | ||
std::vector< ModelCoordinate > & | matching_coords | ||
) | const |
Maps coordinate from one layer to another.
void FIFE::Map::getMinMaxCoordinates | ( | ExactModelCoordinate & | min, |
ExactModelCoordinate & | max | ||
) |
Retrieves the minimum/maximum coordinates of instances on the map.
min | A reference to a ExactModelCoordinate that will hold the minimum coordinate. |
max | A reference to a ExactModelCoordinate that will hold the maximum coordinate. |
Definition at line 138 of file map.cpp.
References FIFE::Location::getMapCoordinates(), m_layers, FIFE::Location::setExactLayerCoordinates(), FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.
|
inline |
Gets model speed.
Definition at line 155 of file map.h.
References FIFE::TimeProvider::getMultiplier(), and m_timeProvider.
|
inline |
Gets timeprovider used in the map.
Definition at line 159 of file map.h.
References m_timeProvider.
Referenced by FIFE::Instance::bindTimeProvider(), FIFE::Instance::getRuntime(), and FIFE::Instance::getTotalTimeMultiplier().
void FIFE::Map::initializeCellCaches | ( | ) |
Creates cellcaches for this map.
Called from maploader.
Definition at line 311 of file map.cpp.
References FIFE::Layer::addInteractLayer(), getLayer(), and m_layers.
Referenced by FIFE::MapLoader::load().
|
inline |
Returns true, if map information was changed during previous update round.
Definition at line 173 of file map.h.
References m_changedLayers.
void FIFE::Map::removeCamera | ( | const std::string & | id | ) |
void FIFE::Map::removeChangeListener | ( | MapChangeListener * | listener | ) |
Removes associated change listener.
listener | to remove |
Definition at line 230 of file map.cpp.
References m_changeListeners.
Referenced by FIFE::Camera::updateMap().
void FIFE::Map::removeInstanceForTransfer | ( | Instance * | instance | ) |
Removes instance that should be transferred to another layer.
instance | A pointer to the instance that should be transferred. |
Definition at line 304 of file map.cpp.
References m_transferInstances.
|
inline |
Definition at line 196 of file map.h.
References m_filename.
Referenced by FIFE::MapLoader::load().
|
inline |
|
inline |
Sets speed for the map.
Definition at line 151 of file map.h.
References m_timeProvider, and FIFE::TimeProvider::setMultiplier().
bool FIFE::Map::update | ( | ) |
Called periodically to update events on map.
Definition at line 170 of file map.cpp.
References FIFE::Layer::addInstance(), FIFE::Location::getExactLayerCoordinates(), FIFE::Location::getLayer(), FIFE::Instance::getOldLocationRef(), m_cameras, m_changed, m_changedLayers, m_changeListeners, m_layers, m_transferInstances, FIFE::Layer::removeInstance(), and FIFE::CellCache::update().
|
private |
holds the cameras attached to this map
Definition at line 234 of file map.h.
Referenced by addCamera(), getCamera(), getCameras(), removeCamera(), update(), and ~Map().
|
private |
true, if something was changed on map during previous update (layer change, creation, deletion)
Definition at line 243 of file map.h.
Referenced by createLayer(), deleteLayer(), and update().
|
private |
holds changed layers after each update
Definition at line 231 of file map.h.
Referenced by getChangedLayers(), isChanged(), and update().
|
private |
listeners for map changes
Definition at line 228 of file map.h.
Referenced by addChangeListener(), createLayer(), deleteLayer(), deleteLayers(), removeChangeListener(), and update().
|
private |
Definition at line 219 of file map.h.
Referenced by getFilename(), and setFilename().
|
private |
|
private |
Definition at line 221 of file map.h.
Referenced by createLayer(), deleteLayer(), deleteLayers(), finalizeCellCaches(), getLayer(), getLayerCount(), getLayers(), getMinMaxCoordinates(), initializeCellCaches(), and update().
|
private |
|
private |
holds handles to all created renderers
Definition at line 240 of file map.h.
Referenced by addCamera().
|
private |
Definition at line 222 of file map.h.
Referenced by getTimeMultiplier(), getTimeProvider(), and setTimeMultiplier().
holds instances which should be transferred on the next update
Definition at line 246 of file map.h.
Referenced by addInstanceForTransfer(), removeInstanceForTransfer(), and update().