/* * Actor.h * * Created on: 02.09.2012 * Author: Felix */ #ifndef DG_ACTOR_H_ #define DG_ACTOR_H_ #include "Sprite.h" class TileManager; class World; class Weapon; class Yaml; /** * Provides think function for AI, manages health, drops body on death. */ class Character : public Sprite { public: explicit Character(World& world, TileManager& tileManager, const Data& data, const Yaml& config); virtual ~Character() = 0; void onDamage(int damage); protected: virtual void onThink(int elapsed); virtual void onDeath(); float getMovementSpeed() const; void pullTrigger(); void releaseTrigger(); bool setDestination(const sf::Vector2f& destination); bool isMoving() const; bool isVisible(const sf::Vector2f& target) const; std::vector > getCharacters() const; private: void move(); private: /// Maximum distance where an enemy will be detected. static const float VISION_DISTANCE; friend class World; World& mWorld; TileManager& mTileManager; const int mMaxHealth; int mCurrentHealth; //< Current health. Between 0 and mMaxHealth. const float mMovementSpeed; std::unique_ptr mWeapon; std::vector mPath; //< Contains nodes to reach a set destination. sf::Vector2f mLastPosition; }; #endif /* DG_ACTOR_H_ */