Argentum Online - Servidor
entity.h
1 #ifndef ENTITY_H
2 #define ENTITY_H
3 
4 #include <cstdint>
5 
6 #include "../../../include/nlohmann/json.hpp"
7 #include "../../../include/types.h"
8 #include "../position.h"
9 #include "components/combat_component.h"
10 #include "components/experience_component.h"
11 #include "components/movement_component.h"
12 
13 class Map;
14 
15 class Entity {
16  protected:
17  const EntityId id;
18  Map& map;
19  const std::string name;
20 
21  MovementComponent* movement_component;
22  CombatComponent* combat_component;
23  ExperienceComponent experience_component;
24 
25  public:
26  Entity(EntityId id, Map& map, const std::string& name,
27  MovementComponent* movement_component,
28  CombatComponent* combat_component, unsigned int current_level,
29  unsigned int current_exp);
30  Entity(EntityId id, Map& map, const std::string& name,
31  unsigned int current_level, unsigned int current_exp);
32  virtual ~Entity();
33 
34  unsigned int heal(unsigned int hp);
35  virtual void die() = 0;
36  virtual bool is_alive() const = 0;
37 
38  bool can_spend_mp(unsigned int amount);
39  void spend_mp(unsigned int amount);
40 
41  std::string get_name() const;
42  unsigned int get_level() const;
43  unsigned int get_max_hp() const;
44 
45  virtual entity_type_t get_type() const = 0;
46  virtual nlohmann::json get_data() const = 0;
47  virtual void update(uint64_t delta_t) = 0;
48 
49  virtual position_t get_facing_position(position_t position);
50 
51  virtual bool can_attack(Entity* attacked) const;
52  attack_result_t attack(Entity* attacked);
53  attack_result_t receive_damage(attack_t attack);
54  void add_exp(int exp);
55 
56  EntityId get_id() const;
57 };
58 
59 #endif // ENTITY_H
MovementComponent
Definition: movement_component.h:9
Entity
Definition: entity.h:15
attack_result
Definition: combat_component.h:13
Map
Definition: map.h:47
ExperienceComponent
Definition: experience_component.h:6
position
Definition: position.h:8
attack
Definition: combat_component.h:8
CombatComponent
Definition: combat_component.h:19