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