feat(entity): add client-to-server entity creation and destruction requests

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.
This commit is contained in:
2026-07-30 15:53:09 +08:00
parent 826c6600d0
commit d6f304e6ca
13 changed files with 102 additions and 10 deletions

View File

@@ -5,6 +5,7 @@
#include "Cubed/tools/cubed_assert.hpp"
#include "Cubed/tools/log.hpp"
#include "Cubed/tools/math_tools.hpp"
#include "Cubed/tools/net_utils.hpp"
#include "Cubed/tools/uuid.hpp"
#include <nlohmann/json.hpp>
@@ -872,6 +873,14 @@ void ServerWorld::handle_block_change(const BlockChangeReq& req) {
}
}
void ServerWorld::handle_entity_create(C2SEntityCreateRequest& req) {
m_entity_manager.add_entity(req.name(), Tools::get_net_pos(req.pos()));
}
void ServerWorld::handle_entity_destory(C2SEntityDestoryRequest& req) {
m_entity_manager.destory(req.id());
}
int ServerWorld::rendering_distance() const {
return m_rendering_distance.load();
}