#include #include #include #include #include #include #include #include #include void deerith::setup_base_protocols() { router_add_packet_processor(); router_add_packet_processor(); router_add_packet_processor(); router_add_packet_processor(); router_add_packet_processor(); router_add_packet_processor(); router_add_packet_processor(); router_add_packet_processor(); } template <> void deerith::process_packet(deerith::packet_sync_world_tick_t &packet, client_t *client) { deerith_trace("tick set to {}", packet.tick_id); set_tick(packet.tick_id); } template <> void deerith::process_packet(deerith::packet_create_player_entity_t &packet, client_t *client) { self_entity = create_entity(); add_component(self_entity); } template <> void deerith::process_packet(deerith::packet_create_entity_t &packet, client_t *client) { deerith_trace("creating entity with network id {}", packet.network_sync_id); entity_t entity; if (packet.is_self_client) { deerith_trace("creating self entity"); entity = self_entity; } else { entity = create_entity(); } component_network_id_t &entity_network_id = add_entity_network_with_id(entity, packet.network_sync_id); if (packet.add_entity_sync_coordinates) { deerith_trace("-> adding entity sync coordinates to entity"); component_sync_coordinates_t &sync_coords = add_component(entity); } } template <> void deerith::process_packet(deerith::packet_update_entities_coordinates_t &packet, client_t *client) { for (int i = 0; i < packet.entities_ids.size(); i++) { if (!exists_network_entity_with_id(packet.entities_ids[i])) { continue; } entity_t entity = get_network_entity_with_id(packet.entities_ids[i]); component_sync_coordinates_t &sync_coords = get_component(entity); packet.positions_to_update[i].recive(sync_coords.position); } } template <> void deerith::process_packet(deerith::packet_destroy_entity_t &packet, client_t *client) { deerith_trace("destroying entity : {}", packet.network_sync_id); entity_t specific_entity = get_network_entity_with_id(packet.network_sync_id); get_entity_registry().destroy(specific_entity); } template <> void deerith::process_packet(deerith::packet_voxel_data_definition_t &packet, client_t *client) { deerith_trace("recive voxel data definition with {} materials and {} types", packet.voxel_materials.size(), packet.voxel_types.size()); set_voxel_materials(packet.voxel_materials); set_voxel_types(packet.voxel_types); } template <> void deerith::process_packet(deerith::packet_surface_data_t &packet, client_t *client) { set_surface_height_raw_data(*packet.__surface_data, packet.surface_id); } template <> void deerith::process_packet(deerith::packet_cluster_data_t &packet, client_t *client) { set_cluster_voxel_type_id_raw_data(*packet.__cluster_data, packet.surface_id, packet.cluster_height_id); generate_cluster(packet.surface_id, packet.cluster_height_id); }