FIFE 2008.0
|
00001 /*************************************************************************** 00002 * Copyright (C) 2005-2008 by the FIFE team * 00003 * http://www.fifengine.de * 00004 * This file is part of FIFE. * 00005 * * 00006 * FIFE is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Lesser General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2.1 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * Lesser General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with this library; if not, write to the * 00018 * Free Software Foundation, Inc., * 00019 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 00020 ***************************************************************************/ 00021 00022 #ifndef FIFE_LOCATION_H 00023 #define FIFE_LOCATION_H 00024 00025 // Standard C++ library includes 00026 #include <iostream> 00027 00028 // 3rd party library includes 00029 00030 // FIFE includes 00031 // These includes are split up in two parts, separated by one empty line 00032 // First block: files included from the FIFE root src directory 00033 // Second block: files included from the same folder 00034 #include "model/metamodel/modelcoords.h" 00035 #include "util/base/exception.h" 00036 00037 namespace FIFE { 00038 class Map; 00039 class Layer; 00040 00041 class Location { 00042 public: 00045 Location(); 00046 00049 Location(const Location& loc); 00050 00053 Location(Layer* layer); 00054 00057 ~Location(); 00058 00061 void reset(); 00062 00065 Location& operator=(const Location& rhs); 00066 00069 inline bool operator==(const Location& loc) const { 00070 return ((m_layer == loc.m_layer) && (m_exact_layer_coords == loc.m_exact_layer_coords)); 00071 } 00072 00075 inline bool operator!=(const Location& loc) const { 00076 return !(*this == loc); 00077 } 00078 00083 Map* getMap() const; 00084 00088 void setLayer(Layer* layer); 00089 00093 Layer* getLayer() const; 00094 00101 void setExactLayerCoordinates(const ExactModelCoordinate& coordinates); 00102 00109 void setLayerCoordinates(const ModelCoordinate& coordinates); 00110 00114 void setMapCoordinates(const ExactModelCoordinate& coordinates); 00115 00120 ExactModelCoordinate& getExactLayerCoordinatesRef(); 00121 00125 ExactModelCoordinate getExactLayerCoordinates() const; 00126 00133 ExactModelCoordinate getExactLayerCoordinates(const Layer* layer) const; 00134 00138 ModelCoordinate getLayerCoordinates() const; 00139 00143 ModelCoordinate getLayerCoordinates(const Layer* layer) const; 00144 00148 ExactModelCoordinate getMapCoordinates() const; 00149 00153 double getCellOffsetDistance() const; 00154 00160 bool isValid() const; 00161 00165 double getMapDistanceTo(const Location& location) const; 00166 00171 double getLayerDistanceTo(const Location& location) const; 00172 00173 private: 00174 bool isValid(const Layer* layer) const; 00175 00176 Layer* m_layer; 00177 ExactModelCoordinate m_exact_layer_coords; 00178 }; 00179 00184 std::ostream& operator<<(std::ostream&, const Location&); 00185 } 00186 #endif //FIFE_LOCATION_H