diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-01-02 13:26:47 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-01-02 13:26:47 +0000 |
commit | 0a47b2fb30c83f8b021c2015891fe8c936ca6bf0 (patch) | |
tree | 21525442898ca4e41eb8ab51a16cf5384ffef40c /src/object.h | |
parent | 5999cff421b0e0b5cd7a0da4d4b0a492f8cc303b (diff) | |
download | manaserv-0a47b2fb30c83f8b021c2015891fe8c936ca6bf0.tar.gz manaserv-0a47b2fb30c83f8b021c2015891fe8c936ca6bf0.tar.bz2 manaserv-0a47b2fb30c83f8b021c2015891fe8c936ca6bf0.tar.xz manaserv-0a47b2fb30c83f8b021c2015891fe8c936ca6bf0.zip |
Removed obsolete files. Added a generic trigger system.
Diffstat (limited to 'src/object.h')
-rw-r--r-- | src/object.h | 96 |
1 files changed, 67 insertions, 29 deletions
diff --git a/src/object.h b/src/object.h index b3511bf8..4ad8c0be 100644 --- a/src/object.h +++ b/src/object.h @@ -28,6 +28,16 @@ #include "point.h" +// Object type enumeration +enum { + OBJECT_ITEM = 0, // A simple item + OBJECT_ACTOR, // An item that toggle map/quest actions (doors, switchs, ...) and can speak (map panels). + OBJECT_NPC, // Non-Playable-Character is an actor capable of movement and maybe actions + OBJECT_MONSTER, // A monster (moving actor with AI. Should be able to toggle map/quest actions, too) + OBJECT_PLAYER, // A normal being + OBJECT_OTHER // Server-only object +}; + class MapComposite; enum @@ -37,59 +47,59 @@ enum ATTACK = 4 }; - /** - * Generic in-game object definition. * Base class for in-game objects. */ -class Object +class Thing { public: /** * Constructor. */ - Object(int type) - : mType(type), - mUpdateFlags(0) + Thing(int type) + : mType(type) {} /** * Empty virtual destructor. */ - virtual ~Object() {} + virtual ~Thing() {} /** - * Get type. + * Gets type. * * @return the type. */ - unsigned int getType() const + int getType() const { return mType; } /** - * Sets the coordinates. - * - * @param p the coordinates. + * Returns whether this thing is visible on the map or not. (Object) */ - void setPosition(const Point &p) - { mPos = p; } + bool isVisible() const + { return mType != OBJECT_OTHER; } /** - * Gets the coordinates. - * - * @return the coordinates. + * Returns whether this thing can move on the map or not. (MovingObject) */ - Point const &getPosition() const - { return mPos; } + bool canMove() const + { return mType == OBJECT_PLAYER || mType == OBJECT_MONSTER || + mType == OBJECT_NPC; } + + /** + * Returns whether this thing can fight or not. (Being) + */ + bool canFight() const + { return mType == OBJECT_PLAYER || mType == OBJECT_MONSTER; } /** - * Update the internal status. + * Updates the internal status. */ virtual void update() = 0; /** - * Gets the map the object is located on. + * Gets the map this thing is located on. * * @return ID of map. */ @@ -97,11 +107,46 @@ class Object { return mMapId; } /** - * Sets the map the object is located on. + * Sets the map this thing is located on. */ void setMapId(int mapId) { mMapId = mapId; } + private: + unsigned short mMapId; /**< id of the map being is on */ + char mType; /**< Object type */ +}; + +/** + * Generic client-visible object definition. + */ +class Object: public Thing +{ + public: + /** + * Constructor. + */ + Object(int type) + : Thing(type), + mUpdateFlags(0) + {} + + /** + * Sets the coordinates. + * + * @param p the coordinates. + */ + void setPosition(const Point &p) + { mPos = p; } + + /** + * Gets the coordinates. + * + * @return the coordinates. + */ + Point const &getPosition() const + { return mPos; } + /** * Gets what changed in the object. */ @@ -121,9 +166,7 @@ class Object { mUpdateFlags = 0; } private: - char mType; /**< Object type */ char mUpdateFlags; /**< changes in object status */ - unsigned short mMapId; /**< id of the map being is on */ Point mPos; /**< coordinates */ }; @@ -211,9 +254,4 @@ class MovingObject: public Object unsigned short mActionTime; /**< delay until next action */ }; -/** - * Type definition for a list of Objects. - */ -typedef std::vector< Object * > Objects; - #endif // _TMWSERV_OBJECT_H_ |