#ifndef SHARED_ENTITY_ANIMATE_HH_ #define SHARED_ENTITY_ANIMATE_HH_ #include "shared/entity/entity.hh" namespace shared { // An animate is a thing with viewangles, commands and velocity, ie mobs, // players etc. class animate : virtual public entity { public: using commands_t = std::uint32_t; enum mask : commands_t { forward = 1 << 0, left = 1 << 1, backward = 1 << 2, right = 1 << 3, jump = 1 << 4, crouch = 1 << 5, sprint = 1 << 6, attack = 1 << 7, flying = 1 << 30 }; protected: commands_t commands; shared::math::angles viewangles; glm::vec3 velocity; std::uint32_t active_item; public: template animate(const commands_t& commands, const shared::math::angles& viewangles, const glm::vec3& velocity, const std::uint32_t& active_item, Args&&... args) noexcept : entity(std::forward(args)...), commands(commands), viewangles(viewangles), velocity(velocity), active_item(active_item) { } animate(const proto::animate& proto) noexcept : entity(proto.entity()), commands(proto.commands()), viewangles(shared::net::get_angles(proto.viewangles())), velocity(shared::net::get_vec3(proto.velocity())), active_item(proto.active_item()) {} public: void pack(proto::animate* const proto) const noexcept { this->entity::pack(proto->mutable_entity()); proto->set_active_item(this->active_item); proto->set_commands(this->commands); shared::net::set_angles(proto->mutable_viewangles(), this->viewangles); shared::net::set_vec3(proto->mutable_velocity(), this->velocity); } public: const decltype(commands)& get_commands() const noexcept { return this->commands; } decltype(commands)& get_mutable_commands() noexcept { return this->commands; } const decltype(viewangles)& get_angles() const noexcept { return this->viewangles; } decltype(viewangles)& get_mutable_angles() noexcept { return this->viewangles; } const decltype(velocity)& get_velocity() const noexcept { return this->velocity; } decltype(velocity)& get_mutable_velocity() noexcept { return this->velocity; } const decltype(active_item)& get_active_item() const noexcept { return this->active_item; } decltype(active_item)& get_mutable_active_item() noexcept { return this->active_item; } public: bool operator==(const animate&) const noexcept = default; }; } // namespace shared #endif