This repository has been archived on 2019-12-07. You can view files and clone it, but cannot push or open issues or pull requests.
dungeon-gunner/source/abstract/Character.h
Felix Ableitner aa6df65e97 Changed sprites to always render as rectangle.
Also created Rectangle/Circle subclasses for sprite to handle
collision detection and moved collision detection from World to
CollisionModel (static methods).
2013-05-08 00:42:26 +02:00

60 lines
1.3 KiB
C++

/*
* Actor.h
*
* Created on: 02.09.2012
* Author: Felix
*/
#ifndef DG_ACTOR_H_
#define DG_ACTOR_H_
#include "Circle.h"
class Pathfinder;
class World;
class Weapon;
class Yaml;
/**
* Provides think function for AI, manages health, drops body on death.
*/
class Character : public Circle {
public:
explicit Character(const sf::Vector2f& position, Category category,
unsigned short mask, const Yaml& config, World& world,
Pathfinder& pathfinder);
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<std::shared_ptr<Character> > getCharacters() const;
private:
void move();
private:
/// Maximum distance where an enemy will be detected.
static const float VISION_DISTANCE;
friend class World;
World& mWorld;
Pathfinder& mPathfinder;
const int mMaxHealth;
int mCurrentHealth; //< Current health. Between 0 and mMaxHealth.
const float mMovementSpeed;
std::unique_ptr<Weapon> mWeapon;
std::vector<sf::Vector2f> mPath; //< Contains nodes to reach a set destination.
sf::Vector2f mLastPosition;
};
#endif /* DG_ACTOR_H_ */