FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
FIFE::Location Class Reference

#include <location.h>

+ Collaboration diagram for FIFE::Location:

Public Member Functions

 Location ()
 Default constructor. More...
 
 Location (const Location &loc)
 Copy constructor. More...
 
 Location (Layer *layer)
 Utility constructor. More...
 
 ~Location ()
 Destructor. More...
 
void reset ()
 Resets location (so that layer and coordinate information becomes invalid) More...
 
Locationoperator= (const Location &rhs)
 Assignment operator. More...
 
bool operator== (const Location &loc) const
 Compares equality of two locations. More...
 
bool operator!= (const Location &loc) const
 Compares unequality of two locations. More...
 
MapgetMap () const
 Gets the map where this location is pointing to. More...
 
void setLayer (Layer *layer)
 Sets layer where this location is pointing to. More...
 
LayergetLayer () const
 Gets the layer where this location is pointing to. More...
 
void setExactLayerCoordinates (const ExactModelCoordinate &coordinates)
 Sets precise layer coordinates to this location. More...
 
void setLayerCoordinates (const ModelCoordinate &coordinates)
 Sets "cell precise" layer coordinates to this location. More...
 
void setMapCoordinates (const ExactModelCoordinate &coordinates)
 Sets map coordinates to this location. More...
 
ExactModelCoordinategetExactLayerCoordinatesRef ()
 Gets reference to exact layer coordinates. More...
 
ExactModelCoordinate getExactLayerCoordinates () const
 Gets exact layer coordinates set to this location. More...
 
ExactModelCoordinate getExactLayerCoordinates (const Layer *layer) const
 Gets exact layer coordinates of this location mapped on given layer. More...
 
ModelCoordinate getLayerCoordinates () const
 Gets cell precision layer coordinates set to this location. More...
 
ModelCoordinate getLayerCoordinates (const Layer *layer) const
 Gets cell precision layer coordinates of this location mapped on given layer. More...
 
ExactModelCoordinate getMapCoordinates () const
 Gets map coordinates set to this location. More...
 
double getCellOffsetDistance () const
 Gets offset distance from cell center. More...
 
bool isValid () const
 Tells if location is valid Location is valid if: More...
 
double getMapDistanceTo (const Location &location) const
 Gets distance in map coordinates to another location on the Map. More...
 
double getLayerDistanceTo (const Location &location) const
 Gets layer distance to another location. More...
 

Private Member Functions

bool isValid (const Layer *layer) const
 

Private Attributes

Layerm_layer
 
ExactModelCoordinate m_exact_layer_coords
 

Detailed Description

Definition at line 41 of file location.h.

Constructor & Destructor Documentation

◆ Location() [1/3]

FIFE::Location::Location ( )

Default constructor.

Definition at line 39 of file location.cpp.

References reset().

◆ Location() [2/3]

FIFE::Location::Location ( const Location loc)

Copy constructor.

Definition at line 43 of file location.cpp.

References m_exact_layer_coords, m_layer, and reset().

◆ Location() [3/3]

FIFE::Location::Location ( Layer layer)

Utility constructor.

Definition at line 49 of file location.cpp.

References m_layer, and reset().

◆ ~Location()

FIFE::Location::~Location ( )

Destructor.

Definition at line 54 of file location.cpp.

Member Function Documentation

◆ getCellOffsetDistance()

double FIFE::Location::getCellOffsetDistance ( ) const

Gets offset distance from cell center.

Returns
offset distance

Definition at line 157 of file location.cpp.

References m_exact_layer_coords, FIFE::Math< T >::Sqrt(), FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.

Referenced by operator!=().

+ Here is the caller graph for this function:

◆ getExactLayerCoordinates() [1/2]

ExactModelCoordinate FIFE::Location::getExactLayerCoordinates ( ) const

Gets exact layer coordinates set to this location.

Returns
exact layer coordinates

Definition at line 109 of file location.cpp.

References m_exact_layer_coords.

Referenced by FIFE::Map::addInstanceForTransfer(), FIFE::RoutePather::followRoute(), operator!=(), FIFE::InstanceDistanceSortLocation::operator()(), FIFE::operator<<(), and FIFE::Map::update().

+ Here is the caller graph for this function:

◆ getExactLayerCoordinates() [2/2]

ExactModelCoordinate FIFE::Location::getExactLayerCoordinates ( const Layer layer) const

Gets exact layer coordinates of this location mapped on given layer.

Exceptions
NotSetin the following cases:
  • given layer is not set (NULL)
  • given layer does not have cellgrid assigned
Returns
exact layer coordinates

Definition at line 129 of file location.cpp.

References FIFE::Layer::getCellGrid(), isValid(), m_exact_layer_coords, m_layer, FIFE::CellGrid::toExactLayerCoordinates(), and FIFE::CellGrid::toMapCoordinates().

◆ getExactLayerCoordinatesRef()

ExactModelCoordinate & FIFE::Location::getExactLayerCoordinatesRef ( )

Gets reference to exact layer coordinates.

This means that if you modify the coordinates, location gets modified directly

Returns
reference to exact layer coordinates

Definition at line 105 of file location.cpp.

References m_exact_layer_coords.

Referenced by FIFE::SingleLayerSearch::calcPath(), FIFE::MultiLayerSearch::calcPathStep(), FIFE::Layer::getInstancesAt(), FIFE::Camera::getMatchingInstances(), FIFE::Instance::Instance(), FIFE::CellCacheChangeListener::onInstanceCreate(), FIFE::CellCacheChangeListener::onInstanceDelete(), operator!=(), and FIFE::InstanceDistanceSortCameraAndLocation::operator()().

+ Here is the caller graph for this function:

◆ getLayer()

◆ getLayerCoordinates() [1/2]

ModelCoordinate FIFE::Location::getLayerCoordinates ( ) const

◆ getLayerCoordinates() [2/2]

ModelCoordinate FIFE::Location::getLayerCoordinates ( const Layer layer) const

Gets cell precision layer coordinates of this location mapped on given layer.

See also
getExactLayerCoordinates(const Layer* layer)

Definition at line 143 of file location.cpp.

References FIFE::Layer::getCellGrid(), getLayerCoordinates(), isValid(), m_exact_layer_coords, m_layer, FIFE::CellGrid::toLayerCoordinates(), and FIFE::CellGrid::toMapCoordinates().

◆ getLayerDistanceTo()

double FIFE::Location::getLayerDistanceTo ( const Location location) const

Gets layer distance to another location.

Parameters
locationis the location you want to get the distance to In case location resides on different layer, it is mapped to this layer

Definition at line 180 of file location.cpp.

References getLayerCoordinates(), m_layer, FIFE::Math< T >::Sqrt(), FIFE::PointType3D< T >::x, FIFE::PointType3D< T >::y, and FIFE::PointType3D< T >::z.

Referenced by operator!=(), FIFE::Instance::processMovement(), FIFE::MultiLayerSearch::searchBetweenTargetsMap(), and FIFE::MultiLayerSearch::searchBetweenTargetsNeighbor().

+ Here is the caller graph for this function:

◆ getMap()

Map * FIFE::Location::getMap ( ) const

Gets the map where this location is pointing to.

Note
this information is fetched from the set layer
Returns
map where this location is pointing to, NULL in case its invalid

Definition at line 72 of file location.cpp.

References FIFE::Layer::getMap(), and m_layer.

Referenced by operator!=().

+ Here is the caller graph for this function:

◆ getMapCoordinates()

◆ getMapDistanceTo()

double FIFE::Location::getMapDistanceTo ( const Location location) const

Gets distance in map coordinates to another location on the Map.

Parameters
locationis the location you want to get the distance to

Definition at line 169 of file location.cpp.

References getMapCoordinates(), FIFE::Math< T >::Sqrt(), FIFE::PointType3D< T >::x, FIFE::PointType3D< T >::y, and FIFE::PointType3D< T >::z.

Referenced by operator!=().

+ Here is the caller graph for this function:

◆ isValid() [1/2]

bool FIFE::Location::isValid ( ) const

Tells if location is valid Location is valid if:

  • layer is set
  • layer has cellgrid

Definition at line 121 of file location.cpp.

References m_layer.

Referenced by getExactLayerCoordinates(), getLayerCoordinates(), operator!=(), setExactLayerCoordinates(), and setMapCoordinates().

+ Here is the caller graph for this function:

◆ isValid() [2/2]

bool FIFE::Location::isValid ( const Layer layer) const
private

Definition at line 125 of file location.cpp.

References FIFE::Layer::getCellGrid().

◆ operator!=()

◆ operator=()

Location & FIFE::Location::operator= ( const Location rhs)

◆ operator==()

bool FIFE::Location::operator== ( const Location loc) const
inline

Compares equality of two locations.

Definition at line 69 of file location.h.

References m_exact_layer_coords, and m_layer.

◆ reset()

void FIFE::Location::reset ( )

Resets location (so that layer and coordinate information becomes invalid)

Definition at line 57 of file location.cpp.

References m_exact_layer_coords, m_layer, FIFE::PointType3D< T >::x, FIFE::PointType3D< T >::y, and FIFE::PointType3D< T >::z.

Referenced by Location(), and FIFE::Camera::removeLayer().

+ Here is the caller graph for this function:

◆ setExactLayerCoordinates()

void FIFE::Location::setExactLayerCoordinates ( const ExactModelCoordinate coordinates)

Sets precise layer coordinates to this location.

Exceptions
NotSetin the following cases:
  • layer is not set (NULL)
  • layer does not have cellgrid assigned
Parameters
coordinatescoordinates to set

Definition at line 87 of file location.cpp.

References isValid(), and m_exact_layer_coords.

Referenced by FIFE::Layer::addInstance(), FIFE::Map::addInstanceForTransfer(), FIFE::SingleLayerSearch::calcPath(), FIFE::Layer::createInstance(), FIFE::Map::getMinMaxCoordinates(), operator!=(), setLayerCoordinates(), and FIFE::Instance::updateMultiInstances().

+ Here is the caller graph for this function:

◆ setLayer()

void FIFE::Location::setLayer ( Layer layer)

◆ setLayerCoordinates()

void FIFE::Location::setLayerCoordinates ( const ModelCoordinate coordinates)

◆ setMapCoordinates()

void FIFE::Location::setMapCoordinates ( const ExactModelCoordinate coordinates)

Sets map coordinates to this location.

Parameters
coordinatescoordinates to set

Definition at line 98 of file location.cpp.

References FIFE::Layer::getCellGrid(), isValid(), m_exact_layer_coords, m_layer, and FIFE::CellGrid::toExactLayerCoordinates().

Referenced by FIFE::CoordinateRenderer::adjustLayerArea(), FIFE::RoutePather::followRoute(), FIFE::getFacing(), FIFE::Camera::getLayerViewPort(), FIFE::Camera::getLocation(), operator!=(), and FIFE::Instance::updateMultiInstances().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_exact_layer_coords

◆ m_layer


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