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