diff options
Diffstat (limited to 'src/game-server/being.h')
-rw-r--r-- | src/game-server/being.h | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/src/game-server/being.h b/src/game-server/being.h index de30ad60..dd9790db 100644 --- a/src/game-server/being.h +++ b/src/game-server/being.h @@ -32,7 +32,7 @@ #include "game-server/attack.h" #include "game-server/timeout.h" -class Being; +class BeingComponent; class MapComposite; class StatusEffect; @@ -50,29 +50,31 @@ typedef std::map< int, Status > StatusEffects; * Generic being (living actor). Keeps direction, destination and a few other * relevant properties. Used for characters & monsters (all animated objects). */ -class Being : public Actor +class BeingComponent : public Component, public sigc::trackable { public: + static const ComponentType type = CT_Being; + /** * Proxy constructor. */ - Being(EntityType type); + BeingComponent(Entity &entity); /** * Update being state. */ - virtual void update(); + virtual void update(Entity &entity); /** Restores all hit points of the being */ - void heal(); + void heal(Entity &entity); /** Restores a specific number of hit points of the being */ - void heal(int hp); + void heal(Entity &entity, int hp); /** * Changes status and calls all the "died" listeners. */ - virtual void died(); + virtual void died(Entity &entity); /** * Gets the destination coordinates of the being. @@ -83,14 +85,13 @@ class Being : public Actor /** * Sets the destination coordinates of the being. */ - void setDestination(const Point &dst); + void setDestination(Entity &entity, const Point &dst); /** * Sets the destination coordinates of the being to the current * position. */ - void clearDestination() - { setDestination(getPosition()); } + void clearDestination(Entity &entity); /** * Gets the old coordinates of the being. @@ -101,15 +102,14 @@ class Being : public Actor /** * Sets the facing direction of the being. */ - void setDirection(BeingDirection direction) - { mDirection = direction; raiseUpdateFlags(UPDATEFLAG_DIRCHANGE); } + void setDirection(Entity &entity, BeingDirection direction); BeingDirection getDirection() const { return mDirection; } /** * Sets the current action. */ - void setAction(BeingAction action); + void setAction(Entity &entity, BeingAction action); /** * Sets the current action. @@ -120,12 +120,12 @@ class Being : public Actor /** * Moves the being toward its destination. */ - void move(); + void move(Entity &entity); /** * Returns the path to the being's current destination. */ - virtual Path findPath(); + virtual Path findPath(Entity &); /** Gets the gender of the being (male or female). */ BeingGender getGender() const @@ -137,7 +137,7 @@ class Being : public Actor /** * Sets an attribute. */ - void setAttribute(unsigned id, double value); + void setAttribute(Entity &entity, unsigned id, double value); /** * Creates an Attribute that did not exist before @@ -188,11 +188,13 @@ class Being : public Actor * @param lvl If non-zero, indicates that a temporary modifier can be * dispelled prematuraly by a spell of given level. */ - void applyModifier(unsigned attr, double value, unsigned layer, - unsigned duration = 0, unsigned id = 0); + void applyModifier(Entity &entity, unsigned attr, double value, + unsigned layer, unsigned duration = 0, + unsigned id = 0); - bool removeModifier(unsigned attr, double value, unsigned layer, - unsigned id = 0, bool fullcheck = false); + bool removeModifier(Entity &entity, unsigned attr, double value, + unsigned layer, unsigned id = 0, + bool fullcheck = false); /** * Called when an attribute modifier is changed. @@ -200,14 +202,14 @@ class Being : public Actor * attributes if it has changed. * @returns Whether it was changed. */ - void recalculateBaseAttribute(unsigned); + void recalculateBaseAttribute(Entity &, unsigned); /** * Attribute has changed, recalculate base value of dependant * attributes (and handle other actions for the modified * attribute) */ - void updateDerivedAttributes(unsigned); + void updateDerivedAttributes(Entity &entity, unsigned); /** * Sets a statuseffect on this being @@ -256,13 +258,13 @@ class Being : public Actor static void setRecalculateBaseAttributeCallback(Script *script) { script->assignCallback(mRecalculateBaseAttributeCallback); } - sigc::signal<void, Being *> signal_died; - sigc::signal<void, Being *, unsigned> signal_attribute_changed; + sigc::signal<void, Entity *> signal_died; + sigc::signal<void, Entity *, unsigned> signal_attribute_changed; /** * Activate an emote flag on the being. */ - void triggerEmote(int id); + void triggerEmote(Entity &entity, int id); /** * Tells the last emote used. @@ -274,7 +276,8 @@ class Being : public Actor * Update the being direction when moving so avoid directions desyncs * with other clients. */ - void updateDirection(const Point ¤tPos, + void updateDirection(Entity &entity, + const Point ¤tPos, const Point &destPos); protected: @@ -290,8 +293,8 @@ class Being : public Actor BeingGender mGender; /**< Gender of the being. */ private: - Being(const Being &rhs); - Being &operator=(const Being &rhs); + BeingComponent(const BeingComponent &rhs); + BeingComponent &operator=(const BeingComponent &rhs); /** * Connected to signal_inserted to reset the old position. |