#ifndef SHARED_ENTITY_PLAYER_HH_ #define SHARED_ENTITY_PLAYER_HH_ #include #include "shared/entity/moveable.hh" #include "shared/entity/animate.hh" #include "shared/item/items.hh" #include "shared/movement/struct.hh" namespace shared { class player : virtual public shared::moveable { public: static constexpr float HEIGHT = 1.9f; static constexpr float EYE_HEIGHT = HEIGHT * 0.8f; static constexpr float HALFWIDTH = 0.25f; static constexpr int INVENTORY_COLS = 10; static constexpr int INVENTORY_ROWS = 5; public: shared::item::items inventory; public: template player(shared::item::items&& inventory, const commands_t& commands, const shared::math::angles& viewangles, const glm::vec3& velocity, const std::uint32_t& active_item, Args&&... args) noexcept : shared::entity(args...), shared::animate(commands, viewangles, velocity, active_item, args...), inventory(std::forward(inventory)) {} player(const proto::player& proto) noexcept : entity(proto.animate().entity()), animate(proto.animate()), inventory(proto.inventory()) {} // constructor for no inventory player(const proto::animate& proto) noexcept : entity(proto.entity()), animate(proto), inventory() {} virtual ~player() noexcept {} public: void pack(proto::player* const proto) const noexcept { this->animate::pack(proto->mutable_animate()); this->inventory.pack(proto->mutable_inventory()); } virtual const movement::aabb& get_aabb() const noexcept override { static constexpr movement::aabb aabb = { .min = {-HALFWIDTH + movement::EPSILON, 0.0f + movement::EPSILON, -HALFWIDTH + movement::EPSILON}, .max = {HALFWIDTH - movement::EPSILON, HEIGHT - movement::EPSILON, HALFWIDTH - movement::EPSILON}}; return aabb; } }; } // namespace shared #endif