1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#ifndef SHARED_ENTITY_PLAYER_HH_
#define SHARED_ENTITY_PLAYER_HH_
#include <algorithm>
#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 <typename... Args>
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<shared::item::items>(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
|