mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user