]> git.localhorst.tv Git - blank.git/blob - src/world/Entity.hpp
some code reorganization
[blank.git] / src / world / Entity.hpp
1 #ifndef BLANK_WORLD_ENTITY_HPP_
2 #define BLANK_WORLD_ENTITY_HPP_
3
4 #include "Block.hpp"
5 #include "Chunk.hpp"
6 #include "../model/Model.hpp"
7
8 #include <glm/glm.hpp>
9 #include <glm/gtc/quaternion.hpp>
10
11
12 namespace blank {
13
14 class Ray;
15 class Shape;
16
17 class Entity {
18
19 public:
20         Entity() noexcept;
21
22         bool HasShape() const noexcept { return shape; }
23         const Shape *GetShape() const noexcept { return shape; }
24         void SetShape(const Shape *, const glm::vec3 &color);
25         void SetShapeless() noexcept;
26
27         const glm::vec3 &Velocity() const noexcept { return velocity; }
28         void Velocity(const glm::vec3 &) noexcept;
29
30         const Block::Pos &Position() const noexcept { return position; }
31         void Position(const Block::Pos &) noexcept;
32         void Move(const glm::vec3 &delta) noexcept;
33
34         const Chunk::Pos ChunkCoords() const noexcept { return chunk; }
35
36         const glm::quat &AngularVelocity() const noexcept { return angular_velocity; }
37         void AngularVelocity(const glm::quat &) noexcept;
38
39         const glm::mat4 &Rotation() const noexcept { return rotation; }
40         void Rotation(const glm::mat4 &) noexcept;
41         void Rotate(const glm::quat &delta) noexcept;
42
43         glm::mat4 Transform(const Chunk::Pos &chunk_offset) const noexcept;
44         Ray Aim(const Chunk::Pos &chunk_offset) const noexcept;
45
46         void Update(int dt) noexcept;
47
48         void Draw() noexcept;
49
50 private:
51         const Shape *shape;
52         Model model;
53
54         glm::vec3 velocity;
55         Block::Pos position;
56         Chunk::Pos chunk;
57
58         glm::quat angular_velocity;
59         glm::mat4 rotation;
60
61 };
62
63 }
64
65 #endif