]> git.localhorst.tv Git - blank.git/blobdiff - src/world/Entity.hpp
simple preloader
[blank.git] / src / world / Entity.hpp
index 7c96f4f3408d2c346c3c638f10ff83bb19f53213..25818c6f3da5666b671666a600ace04a9552e093 100644 (file)
@@ -4,7 +4,7 @@
 #include "Block.hpp"
 #include "Chunk.hpp"
 #include "../model/geometry.hpp"
-#include "../model/Model.hpp"
+#include "../model/EntityModel.hpp"
 
 #include <string>
 #include <glm/glm.hpp>
@@ -38,11 +38,19 @@ public:
        void Velocity(const glm::vec3 &) noexcept;
 
        const Block::Pos &Position() const noexcept { return position; }
+       void Position(const Chunk::Pos &, const Block::Pos &) noexcept;
        void Position(const Block::Pos &) noexcept;
        void Move(const glm::vec3 &delta) noexcept;
 
        const Chunk::Pos ChunkCoords() const noexcept { return chunk; }
 
+       glm::vec3 AbsolutePosition() const noexcept {
+               return glm::vec3(chunk * Chunk::Extent()) + position;
+       }
+       glm::vec3 AbsoluteDifference(const Entity &other) const noexcept {
+               return glm::vec3((chunk - other.chunk) * Chunk::Extent()) + position - other.position;
+       }
+
        const glm::quat &AngularVelocity() const noexcept { return angular_velocity; }
        void AngularVelocity(const glm::quat &) noexcept;
 
@@ -53,13 +61,16 @@ public:
        glm::mat4 Transform(const Chunk::Pos &chunk_offset) const noexcept;
        Ray Aim(const Chunk::Pos &chunk_offset) const noexcept;
 
+       void Remove() noexcept { remove = true; }
+       bool CanRemove() const noexcept { return remove; }
+
        void Update(int dt) noexcept;
 
        void Draw() noexcept;
 
 private:
        const Shape *shape;
-       Model model;
+       EntityModel model;
 
        std::string name;
 
@@ -73,6 +84,7 @@ private:
        glm::mat4 rotation;
 
        bool world_collision;
+       bool remove;
 
 };