00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _TMWSERV_THING_H_
00022 #define _TMWSERV_THING_H_
00023
00024 #include <set>
00025
00026 class EventListener;
00027 class MapComposite;
00028
00032 enum ThingType
00033 {
00034 OBJECT_ITEM = 0,
00035 OBJECT_ACTOR,
00037 OBJECT_NPC,
00039 OBJECT_MONSTER,
00041 OBJECT_CHARACTER,
00042 OBJECT_EFFECT,
00043 OBJECT_OTHER
00044 };
00045
00050 class Thing
00051 {
00052 public:
00056 Thing(ThingType type, MapComposite *map = NULL)
00057 : mMap(map),
00058 mType(type)
00059 {}
00060
00061 virtual ~Thing();
00062
00068 ThingType getType() const
00069 { return mType; }
00070
00074 bool isVisible() const
00075 { return mType != OBJECT_OTHER; }
00076
00080 bool canMove() const
00081 { return mType == OBJECT_CHARACTER || mType == OBJECT_MONSTER ||
00082 mType == OBJECT_NPC; }
00083
00087 bool canFight() const
00088 { return mType == OBJECT_CHARACTER || mType == OBJECT_MONSTER; }
00089
00093 virtual void update() = 0;
00094
00098 MapComposite *getMap() const
00099 { return mMap; }
00100
00104 virtual void setMap(MapComposite *map)
00105 { mMap = map; }
00106
00110 void addListener(const EventListener *);
00111
00115 void removeListener(const EventListener *);
00116
00120 virtual void inserted();
00121
00125 virtual void removed();
00126
00127 protected:
00128 typedef std::set< const EventListener * > Listeners;
00129 Listeners mListeners;
00131 private:
00132 MapComposite *mMap;
00133 ThingType mType;
00134 };
00135
00136 #endif // _TMWSERV_THING_H_