]> git.localhorst.tv Git - blobs.git/blob - src/world/Creature.hpp
83623a2ba04ad19f40147a2cf8f82507e2d2bfd3
[blobs.git] / src / world / Creature.hpp
1 #ifndef BLOBS_WORLD_CREATURE_HPP_
2 #define BLOBS_WORLD_CREATURE_HPP_
3
4 #include "../graphics/glm.hpp"
5 #include "../graphics/SimpleVAO.hpp"
6
7
8 namespace blobs {
9 namespace app {
10         struct Assets;
11 }
12 namespace graphics {
13         class Viewport;
14 }
15 namespace world {
16
17 class Body;
18 class Planet;
19
20 class Creature {
21
22 public:
23         Creature();
24         ~Creature();
25
26         Creature(const Creature &) = delete;
27         Creature &operator =(const Creature &) = delete;
28
29         Creature(Creature &&) = delete;
30         Creature &operator =(Creature &&) = delete;
31
32 public:
33         void SetBody(Body &b) noexcept { body = &b; }
34         Body &GetBody() noexcept { return *body; }
35         const Body &GetBody() const noexcept { return *body; }
36
37         void Surface(int s) noexcept { surface = s; }
38         void Position(const glm::dvec3 &p) noexcept { position = p; }
39
40         void RequireBreathing(int r) noexcept { breathes = r; }
41         int Breathes() const noexcept { return breathes; }
42         bool MustBreathe() const noexcept { return breathes > -1; }
43
44         void RequireDrinking(int r) noexcept { drinks = r; }
45         int Drinks() const noexcept { return drinks; }
46         bool MustDrink() const noexcept { return drinks > -1; }
47
48         void RequireEating(int r) noexcept { eats = r; }
49         int Eats() const noexcept { return eats; }
50         bool MustEat() const noexcept { return eats > -1; }
51
52         glm::dmat4 LocalTransform() noexcept;
53
54         void BuildVAO();
55         void Draw(app::Assets &, graphics::Viewport &);
56
57 private:
58         Body *body;
59         int surface;
60         glm::dvec3 position;
61
62         int breathes;
63         int drinks;
64         int eats;
65
66         struct Attributes {
67                 glm::vec3 position;
68                 glm::vec3 normal;
69                 glm::vec3 texture;
70         };
71         graphics::SimpleVAO<Attributes, unsigned short> vao;
72
73 };
74
75 /// put creature on planet and configure it to (hopefully) survive
76 void Spawn(Creature &, Planet &, app::Assets &);
77
78 }
79 }
80
81 #endif