mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
Extend the network protocol with `C2SEntityCreateRequest` and `C2SEntityDestoryRequest` packets. Refactor entity managers to split public client-facing create/destroy methods that send requests over the network, from internal handlers that process received packets. Add utility functions for converting protobuf Vec3 to glm::vec3.
21 lines
550 B
C++
21 lines
550 B
C++
#pragma once
|
|
|
|
#include "Cubed/tools/cubed_concepts.hpp"
|
|
#include "common/vector3.pb.h"
|
|
#include "glm/ext/vector_float3.hpp"
|
|
namespace Cubed {
|
|
namespace Tools {
|
|
template <Ptr T> void set_net_pos(T ptr, const glm::vec3& pos) {
|
|
Vec3* p = ptr->mutable_pos();
|
|
p->set_x(pos.x);
|
|
p->set_y(pos.y);
|
|
p->set_z(pos.z);
|
|
}
|
|
inline glm::vec3 get_net_pos(const Vec3* p) {
|
|
return glm::vec3{p->x(), p->y(), p->z()};
|
|
}
|
|
inline glm::vec3 get_net_pos(const Vec3& p) {
|
|
return glm::vec3{p.x(), p.y(), p.z()};
|
|
}
|
|
} // namespace Tools
|
|
} // namespace Cubed
|