#define BLANK_WORLD_ENTITY_HPP_
#include "Chunk.hpp"
-#include "../model/CompositeModel.hpp"
+#include "../model/CompositeInstance.hpp"
#include "../model/geometry.hpp"
+#include <cstdint>
#include <string>
#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>
public:
Entity() noexcept;
- CompositeModel &GetModel() noexcept { return model; }
- const CompositeModel &GetModel() const noexcept { return model; }
+ CompositeInstance &GetModel() noexcept { return model; }
+ const CompositeInstance &GetModel() const noexcept { return model; }
+
+ std::uint32_t ID() const noexcept { return id; }
+ void ID(std::uint32_t i) noexcept { id = i; }
const std::string &Name() const noexcept { return name; }
void Name(const std::string &n) { name = n; }
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 Ref() noexcept { ++ref_count; }
+ void UnRef() noexcept { --ref_count; }
+ void Kill() noexcept { dead = true; }
+ bool Referenced() const noexcept { return ref_count > 0; }
+ bool Dead() const noexcept { return dead; }
+ bool CanRemove() const noexcept { return dead && ref_count <= 0; }
void Update(int dt) noexcept;
void Render(const glm::mat4 &M, DirectionalLighting &prog) noexcept {
- model.Render(M, prog);
+ if (model) model.Render(M, prog);
}
private:
- CompositeModel model;
+ CompositeInstance model;
+ std::uint32_t id;
std::string name;
AABB bounds;
glm::vec3 angular_velocity;
+ int ref_count;
+
bool world_collision;
- bool remove;
+ bool dead;
};