]> git.localhorst.tv Git - blobs.git/blob - src/creature/Creature.hpp
abstract needs a little
[blobs.git] / src / creature / Creature.hpp
1 #ifndef BLOBS_CREATURE_CREATURE_HPP_
2 #define BLOBS_CREATURE_CREATURE_HPP_
3
4 #include "Need.hpp"
5 #include "Situation.hpp"
6 #include "../graphics/glm.hpp"
7 #include "../graphics/SimpleVAO.hpp"
8
9 #include <memory>
10 #include <string>
11 #include <vector>
12
13
14 namespace blobs {
15 namespace app {
16         struct Assets;
17 }
18 namespace graphics {
19         class Viewport;
20 }
21 namespace world {
22         class Body;
23         class Planet;
24 }
25 namespace creature {
26
27 class Creature {
28
29 public:
30         Creature();
31         ~Creature();
32
33         Creature(const Creature &) = delete;
34         Creature &operator =(const Creature &) = delete;
35
36         Creature(Creature &&) = delete;
37         Creature &operator =(Creature &&) = delete;
38
39 public:
40         void Name(const std::string &n) noexcept { name = n; }
41         const std::string &Name() const noexcept { return name; }
42
43         void Health(double h) noexcept { health = h; }
44         double Health() const noexcept { return health; }
45         void Hurt(double d) noexcept;
46
47         void AddNeed(std::unique_ptr<Need> &&n) { needs.emplace_back(std::move(n)); }
48         const std::vector<std::unique_ptr<Need>> &Needs() const noexcept { return needs; }
49
50         void Tick(double dt);
51
52         Situation &GetSituation() noexcept { return situation; }
53         const Situation &GetSituation() const noexcept { return situation; }
54
55         glm::dmat4 LocalTransform() noexcept;
56
57         void BuildVAO();
58         void Draw(app::Assets &, graphics::Viewport &);
59
60 private:
61         std::string name;
62         double health;
63         std::vector<std::unique_ptr<Need>> needs;
64
65         Situation situation;
66
67         struct Attributes {
68                 glm::vec3 position;
69                 glm::vec3 normal;
70                 glm::vec3 texture;
71         };
72         graphics::SimpleVAO<Attributes, unsigned short> vao;
73
74 };
75
76 /// put creature on planet and configure it to (hopefully) survive
77 void Spawn(Creature &, world::Planet &, app::Assets &);
78
79 }
80 }
81
82 #endif