FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
FIFE::Map Class Reference

A container of Layer(s). More...

#include <map.h>

+ Inheritance diagram for FIFE::Map:
+ Collaboration diagram for FIFE::Map:

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...
 
LayercreateLayer (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...
 
LayergetLayer (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 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...
 
TimeProvidergetTimeProvider ()
 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...
 
CameraaddCamera (const std::string &id, const Rect &viewport)
 Adds camera to the map. More...
 
void removeCamera (const std::string &id)
 Removes a camera from the map. More...
 
CameragetCamera (const std::string &id)
 Get a camera by its identifier. More...
 
const std::vector< Camera * > & getCameras () const
 Get a list containing all cameras. More...
 
uint32_t getActiveCameraCount () const
 Return the number of enabled cameras in this map. 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...
 
TriggerControllergetTriggerController () const
 
- Public Member Functions inherited from FIFE::FifeClass
 FifeClass ()
 
virtual ~FifeClass ()
 
fifeid_t getFifeId ()
 Gets unique id of this instance inside the engine. More...
 

Private Member Functions

 Map (const Map &map)
 
Mapoperator= (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...
 
RenderBackendm_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 *, Locationm_transferInstances
 holds instances which should be transferred on the next update More...
 
TriggerControllerm_triggerController
 

Detailed Description

A container of Layer(s).

The actual data is contained in Layer objects

See also
Layer

Definition at line 88 of file map.h.

Constructor & Destructor Documentation

◆ Map() [1/2]

FIFE::Map::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)

Definition at line 47 of file map.cpp.

References m_triggerController.

◆ ~Map()

FIFE::Map::~Map ( )

Destructor.

Definition at line 61 of file map.cpp.

References deleteLayers(), m_cameras, and m_triggerController.

◆ Map() [2/2]

FIFE::Map::Map ( const Map map)
private

Member Function Documentation

◆ addCamera()

Camera * FIFE::Map::addCamera ( const std::string &  id,
const Rect viewport 
)

Adds camera to the map.

The Map takes ownership of the camera so don't delete it.

Definition at line 245 of file map.cpp.

References FIFE::Camera::addRenderer(), getCamera(), m_cameras, m_renderBackend, and m_renderers.

Referenced by FIFE::MapLoader::load().

+ Here is the caller graph for this function:

◆ addChangeListener()

void FIFE::Map::addChangeListener ( MapChangeListener listener)

Adds new change listener.

Parameters
listenerto add

Definition at line 230 of file map.cpp.

References m_changeListeners.

Referenced by FIFE::Model::createMap(), and FIFE::Camera::init().

+ Here is the caller graph for this function:

◆ addInstanceForTransfer()

void FIFE::Map::addInstanceForTransfer ( Instance instance,
const Location target 
)

Adds instance that is to be transferred to another layer.

Parameters
instanceA pointer to the instance that is to be transferred.
targetA const reference to the target location.

Definition at line 306 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().

+ Here is the caller graph for this function:

◆ createLayer()

Layer * FIFE::Map::createLayer ( const std::string &  identifier,
CellGrid grid 
)

Add a Layer to this Map.

Map owns the returned pointer to the new Layer, so don't delete it!

Definition at line 86 of file map.cpp.

References m_changed, m_changeListeners, and m_layers.

Referenced by FIFE::MapLoader::load().

+ Here is the caller graph for this function:

◆ deleteLayer()

void FIFE::Map::deleteLayer ( Layer layer)

Delete a layer from the map.

Definition at line 105 of file map.cpp.

References m_changed, m_changeListeners, and m_layers.

◆ deleteLayers()

void FIFE::Map::deleteLayers ( )

Delete all layers from the map.

Definition at line 122 of file map.cpp.

References m_changeListeners, and m_layers.

Referenced by ~Map().

+ Here is the caller graph for this function:

◆ finalizeCellCaches()

void FIFE::Map::finalizeCellCaches ( )

Creates cellcaches for this map.

Called from maploader.

Definition at line 346 of file map.cpp.

References FIFE::CellCache::createCells(), FIFE::CellCache::forceUpdate(), and m_layers.

Referenced by FIFE::MapLoader::load().

+ Here is the caller graph for this function:

◆ getActiveCameraCount()

uint32_t FIFE::Map::getActiveCameraCount ( ) const

Return the number of enabled cameras in this map.

Definition at line 295 of file map.cpp.

References m_cameras.

◆ getCamera()

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().

+ Here is the caller graph for this function:

◆ getCameras()

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().

+ Here is the caller graph for this function:

◆ getChangedLayers()

std::vector<Layer*>& FIFE::Map::getChangedLayers ( )
inline

Returns layers that were changed during previous update round.

Definition at line 173 of file map.h.

◆ getFilename()

const std::string& FIFE::Map::getFilename ( ) const
inline

Definition at line 197 of file map.h.

◆ getId()

const std::string& FIFE::Map::getId ( ) const
inline

Get the identifier for this map.

Definition at line 104 of file map.h.

Referenced by FIFE::MapSaver::save().

+ Here is the caller graph for this function:

◆ getLayer()

Layer * FIFE::Map::getLayer ( const std::string &  identifier)

Get the layer with the given id.

Definition at line 73 of file map.cpp.

References m_layers.

Referenced by initializeCellCaches(), FIFE::MapLoader::load(), and FIFE::Layer::~Layer().

+ Here is the caller graph for this function:

◆ getLayerCount()

uint32_t FIFE::Map::getLayerCount ( ) const

Get the overall number of layers.

Definition at line 82 of file map.cpp.

References m_layers.

Referenced by FIFE::Layer::getLayerCount(), FIFE::Camera::getLocation(), and FIFE::Layer::getZOffset().

+ Here is the caller graph for this function:

◆ getLayers()

const std::list<Layer*>& FIFE::Map::getLayers ( ) const
inline

◆ getMinMaxCoordinates()

void FIFE::Map::getMinMaxCoordinates ( ExactModelCoordinate min,
ExactModelCoordinate max 
)

Retrieves the minimum/maximum coordinates of instances on the map.

Parameters
minA reference to a ExactModelCoordinate that will hold the minimum coordinate.
maxA reference to a ExactModelCoordinate that will hold the maximum coordinate.

Definition at line 142 of file map.cpp.

References FIFE::Location::getMapCoordinates(), m_layers, FIFE::Location::setExactLayerCoordinates(), FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.

◆ getTimeMultiplier()

float FIFE::Map::getTimeMultiplier ( ) const
inline

Gets model speed.

See also
setTimeMultiplier.

Definition at line 151 of file map.h.

◆ getTimeProvider()

TimeProvider* FIFE::Map::getTimeProvider ( )
inline

Gets timeprovider used in the map.

Definition at line 155 of file map.h.

Referenced by FIFE::Instance::bindTimeProvider(), FIFE::Instance::getRuntime(), and FIFE::Instance::getTotalTimeMultiplier().

+ Here is the caller graph for this function:

◆ getTriggerController()

TriggerController* FIFE::Map::getTriggerController ( ) const
inline

Definition at line 220 of file map.h.

Referenced by FIFE::MapLoader::load(), and FIFE::MapSaver::save().

+ Here is the caller graph for this function:

◆ initializeCellCaches()

void FIFE::Map::initializeCellCaches ( )

Creates cellcaches for this map.

Called from maploader.

Definition at line 322 of file map.cpp.

References FIFE::Layer::addInteractLayer(), getLayer(), and m_layers.

Referenced by FIFE::MapLoader::load().

+ Here is the caller graph for this function:

◆ isChanged()

bool FIFE::Map::isChanged ( )
inline

Returns true, if map information was changed during previous update round.

Definition at line 169 of file map.h.

◆ operator=()

Map& FIFE::Map::operator= ( const Map map)
private

◆ removeCamera()

void FIFE::Map::removeCamera ( const std::string &  id)

Removes a camera from the map.

Definition at line 263 of file map.cpp.

References m_cameras.

◆ removeChangeListener()

void FIFE::Map::removeChangeListener ( MapChangeListener listener)

Removes associated change listener.

Parameters
listenerto remove

Definition at line 234 of file map.cpp.

References m_changeListeners.

Referenced by FIFE::Camera::~Camera().

+ Here is the caller graph for this function:

◆ removeInstanceForTransfer()

void FIFE::Map::removeInstanceForTransfer ( Instance instance)

Removes instance that should be transferred to another layer.

Parameters
instanceA pointer to the instance that should be transferred.

Definition at line 315 of file map.cpp.

References m_transferInstances.

◆ setFilename()

void FIFE::Map::setFilename ( const std::string &  file)
inline

Definition at line 196 of file map.h.

Referenced by FIFE::MapLoader::load().

+ Here is the caller graph for this function:

◆ setId()

void FIFE::Map::setId ( const std::string &  id)
inline

Sets the identifier for this map.

Definition at line 108 of file map.h.

◆ setTimeMultiplier()

void FIFE::Map::setTimeMultiplier ( float  multip)
inline

Sets speed for the map.

See Model::setTimeMultiplier.

Definition at line 147 of file map.h.

◆ update()

Member Data Documentation

◆ m_cameras

std::vector<Camera*> FIFE::Map::m_cameras
private

holds the cameras attached to this map

Definition at line 239 of file map.h.

Referenced by addCamera(), getActiveCameraCount(), getCamera(), getCameras(), removeCamera(), update(), and ~Map().

◆ m_changed

bool FIFE::Map::m_changed
private

true, if something was changed on map during previous update (layer change, creation, deletion)

Definition at line 248 of file map.h.

Referenced by createLayer(), deleteLayer(), and update().

◆ m_changedLayers

std::vector<Layer*> FIFE::Map::m_changedLayers
private

holds changed layers after each update

Definition at line 236 of file map.h.

Referenced by update().

◆ m_changeListeners

std::vector<MapChangeListener*> FIFE::Map::m_changeListeners
private

listeners for map changes

Definition at line 233 of file map.h.

Referenced by addChangeListener(), createLayer(), deleteLayer(), deleteLayers(), removeChangeListener(), and update().

◆ m_filename

std::string FIFE::Map::m_filename
private

Definition at line 224 of file map.h.

◆ m_id

std::string FIFE::Map::m_id
private

Definition at line 220 of file map.h.

◆ m_layers

std::list<Layer*> FIFE::Map::m_layers
private

◆ m_renderBackend

RenderBackend* FIFE::Map::m_renderBackend
private

pointer to renderbackend

Definition at line 242 of file map.h.

Referenced by addCamera().

◆ m_renderers

std::vector<RendererBase*> FIFE::Map::m_renderers
private

holds handles to all created renderers

Definition at line 245 of file map.h.

Referenced by addCamera().

◆ m_timeProvider

TimeProvider FIFE::Map::m_timeProvider
private

Definition at line 227 of file map.h.

◆ m_transferInstances

std::map<Instance*, Location> FIFE::Map::m_transferInstances
private

holds instances which should be transferred on the next update

Definition at line 251 of file map.h.

Referenced by addInstanceForTransfer(), removeInstanceForTransfer(), and update().

◆ m_triggerController

TriggerController* FIFE::Map::m_triggerController
private

Definition at line 253 of file map.h.

Referenced by Map(), and ~Map().


The documentation for this class was generated from the following files: