00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00030 #if !defined(Location_h)
00031 #define Location_h
00032
00036 class Location {
00037 public:
00038 Location(const Location &source) : posX(source.posX), posY(source.posY) {}
00039
00040 Location() : posX(0), posY(0) {}
00041
00042 virtual ~Location();
00043 virtual bool ParseNode(const TiXmlNode * node);
00044 virtual TiXmlNode * WriteNode(TiXmlNode * node) const { return WriteLocation(node); }
00045 TiXmlNode * WriteLocation(TiXmlNode * node) const;
00046 virtual const string GetName(const Player *) const { string s; return s; }
00047
00048 void SetLocation(const Location & loc) { posX = loc.posX; posY = loc.posY; }
00049 void SetLocation(long px, long py) { posX = px; posY = py; }
00050 long GetPosX() const { return posX; }
00051 long GetPosY() const { return posY; }
00052 void SetPosX(long x) { posX = x; }
00053 void SetPosY(long y) { posY = y; }
00054 double Distance(const Location & other) const;
00055 double Distance(double px, double py) const;
00056 bool IsWith(const Location & other) const { return posX == other.posX && posY == other.posY; }
00057 bool IsWith(long x, long y) const { return posX == x && posY == y; }
00058 virtual long GetID() const { return 0; }
00059 virtual long SeenBy(const Player *) const { return true; }
00060 virtual long SeenBy(unsigned long) const { return true; }
00061
00062 static void MoveToward(const Location &start, const Location & dest, double * px, double * py, long distance);
00063
00064 friend bool operator ==(const Location &a, const Location &b) { return a.IsWith(b); }
00065 friend bool operator !=(const Location &a, const Location &b) { return !(a == b); }
00066
00067 protected:
00068 long posX;
00069 long posY;
00070 };
00071
00072 #endif // !defined(Location_h)