location.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FIFE_LOCATION_H
00023 #define FIFE_LOCATION_H
00024
00025
00026 #include <iostream>
00027
00028
00029
00030
00031
00032
00033
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