2012-10-01 09:02:44 +00:00
|
|
|
/*
|
|
|
|
* Actor.h
|
|
|
|
*
|
|
|
|
* Created on: 02.09.2012
|
|
|
|
* Author: Felix
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DG_ACTOR_H_
|
|
|
|
#define DG_ACTOR_H_
|
|
|
|
|
2013-05-07 22:00:05 +00:00
|
|
|
#include "Circle.h"
|
2012-10-01 09:13:26 +00:00
|
|
|
|
2013-07-06 19:21:25 +00:00
|
|
|
#include "../items/Gadget.h"
|
|
|
|
|
2013-04-28 16:11:39 +00:00
|
|
|
class Pathfinder;
|
2012-12-22 00:44:36 +00:00
|
|
|
class World;
|
2012-10-13 16:57:12 +00:00
|
|
|
class Weapon;
|
2012-10-12 17:34:07 +00:00
|
|
|
class Yaml;
|
2012-10-01 09:13:26 +00:00
|
|
|
|
2012-10-01 09:02:44 +00:00
|
|
|
/**
|
2012-10-04 17:24:46 +00:00
|
|
|
* Provides think function for AI, manages health, drops body on death.
|
2012-10-01 09:02:44 +00:00
|
|
|
*/
|
2013-05-07 22:00:05 +00:00
|
|
|
class Character : public Circle {
|
2013-05-08 17:49:04 +00:00
|
|
|
public:
|
|
|
|
enum Faction {
|
|
|
|
FACTION_PLAYER = 1,
|
|
|
|
FACTION_ENEMIES = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Maximum distance where an enemy will be detected.
|
|
|
|
static const float VISION_DISTANCE;
|
|
|
|
|
2012-09-12 12:21:57 +00:00
|
|
|
public:
|
2013-08-07 15:39:43 +00:00
|
|
|
explicit Character(const Vector2f& position, Category category,
|
2013-05-07 22:00:05 +00:00
|
|
|
unsigned short mask, const Yaml& config, World& world,
|
|
|
|
Pathfinder& pathfinder);
|
2012-10-01 09:02:44 +00:00
|
|
|
virtual ~Character() = 0;
|
|
|
|
|
|
|
|
void onDamage(int damage);
|
2013-05-08 17:49:04 +00:00
|
|
|
Faction getFaction() const;
|
2013-05-08 09:19:21 +00:00
|
|
|
|
2012-10-01 09:02:44 +00:00
|
|
|
protected:
|
2013-03-09 15:25:04 +00:00
|
|
|
virtual void onThink(int elapsed);
|
2012-10-01 09:02:44 +00:00
|
|
|
virtual void onDeath();
|
2012-10-13 16:50:28 +00:00
|
|
|
float getMovementSpeed() const;
|
2012-12-24 00:14:22 +00:00
|
|
|
void pullTrigger();
|
|
|
|
void releaseTrigger();
|
2013-08-07 15:39:43 +00:00
|
|
|
bool setDestination(const Vector2f& destination);
|
2013-04-05 14:54:51 +00:00
|
|
|
bool isMoving() const;
|
2013-08-07 15:39:43 +00:00
|
|
|
bool isVisible(const Vector2f& target) const;
|
2013-04-05 14:54:51 +00:00
|
|
|
std::vector<std::shared_ptr<Character> > getCharacters() const;
|
2013-06-25 15:44:40 +00:00
|
|
|
int getMagazineAmmo() const;
|
|
|
|
int getTotalAmmo() const;
|
2013-07-06 11:38:15 +00:00
|
|
|
std::string getWeaponName() const;
|
2013-06-25 15:44:40 +00:00
|
|
|
void reload();
|
2013-06-25 20:00:40 +00:00
|
|
|
void toggleWeapon();
|
|
|
|
void selectFirstWeapon();
|
|
|
|
void selectSecondWeapon();
|
2013-07-06 12:37:16 +00:00
|
|
|
int getHealth() const;
|
2013-07-06 19:21:25 +00:00
|
|
|
void setLeftGadget(std::shared_ptr<Gadget> gadget);
|
|
|
|
void setRightGadget(std::shared_ptr<Gadget> gadget);
|
|
|
|
void useLeftGadget();
|
|
|
|
void useRightGadget();
|
2013-07-10 21:41:24 +00:00
|
|
|
std::string getLeftGadgetName() const;
|
|
|
|
std::string getRightGadgetName() const;
|
2013-07-21 08:52:50 +00:00
|
|
|
void pickUpItem();
|
2013-07-06 19:21:25 +00:00
|
|
|
|
|
|
|
protected:
|
2012-10-01 09:02:44 +00:00
|
|
|
|
2013-04-25 19:57:37 +00:00
|
|
|
private:
|
|
|
|
void move();
|
|
|
|
|
2012-10-01 09:02:44 +00:00
|
|
|
private:
|
2013-07-10 21:25:53 +00:00
|
|
|
friend class Shield;
|
|
|
|
|
2013-06-21 16:00:38 +00:00
|
|
|
/// Distance to a path point where it will be considered as reached (to
|
|
|
|
/// avoid floating point equality check).
|
|
|
|
static const float POINT_REACHED_DISTANCE;
|
2013-07-21 08:52:50 +00:00
|
|
|
/// Maximum distance from character where an item can be picked up.
|
|
|
|
static const float ITEM_PICKUP_MAX_DISTANCE_SQUARED;
|
2013-03-29 16:59:35 +00:00
|
|
|
friend class World;
|
2012-12-22 00:44:36 +00:00
|
|
|
World& mWorld;
|
2013-04-28 16:11:39 +00:00
|
|
|
Pathfinder& mPathfinder;
|
2012-12-22 00:44:36 +00:00
|
|
|
|
2012-10-01 09:02:44 +00:00
|
|
|
const int mMaxHealth;
|
2012-09-12 12:21:57 +00:00
|
|
|
int mCurrentHealth; //< Current health. Between 0 and mMaxHealth.
|
2012-10-13 16:50:28 +00:00
|
|
|
const float mMovementSpeed;
|
2013-06-25 20:00:40 +00:00
|
|
|
std::shared_ptr<Weapon> mFirstWeapon;
|
|
|
|
std::shared_ptr<Weapon> mSecondWeapon;
|
|
|
|
std::shared_ptr<Weapon> mActiveWeapon;
|
2013-07-06 19:21:25 +00:00
|
|
|
std::shared_ptr<Gadget> mLeftGadget;
|
|
|
|
std::shared_ptr<Gadget> mRightGadget;
|
2013-08-07 15:39:43 +00:00
|
|
|
std::vector<Vector2f> mPath; //< Contains nodes to reach a set destination.
|
|
|
|
Vector2f mLastPosition;
|
2013-05-08 17:49:04 +00:00
|
|
|
Faction mFaction;
|
2012-10-01 09:02:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* DG_ACTOR_H_ */
|