57 lines
1.8 KiB
C++
57 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include "Universe.hpp"
|
|
#include "../net/Client.hpp"
|
|
#include "../../core/utils/zctx.hpp"
|
|
|
|
namespace world::client {
|
|
class Area;
|
|
|
|
/// Whole universe container in network client
|
|
class DistantUniverse final: public Universe {
|
|
public:
|
|
DistantUniverse(const connection&, const options &, const std::string&);
|
|
~DistantUniverse();
|
|
|
|
void update(voxel_pos, float) override;
|
|
void emit(const action::packet &) override;
|
|
|
|
ray_result raycast(const geometry::Ray &) const override;
|
|
|
|
bool isAreaFree(const area_<voxel_pos> &pos, geometry::Shape shape, uint16_t radius) const override;
|
|
|
|
void getEntitiesModels(const std::function<void(size_t, const std::vector<glm::mat4>&)>&,
|
|
const std::optional<geometry::Frustum>& frustum, const glm::llvec3& offset, int density) override;
|
|
|
|
bool isRunning() const override { return peer.isRunning(); }
|
|
|
|
size_t getPlayerId() const override { return playerId; }
|
|
|
|
protected:
|
|
bool onPacket(const data::out_view&, net::PacketFlags);
|
|
|
|
/// Alive areas containing chunks
|
|
area_map areas;
|
|
|
|
/// Entities without generation
|
|
struct Entity {
|
|
Entity(glm::vec3 size, glm::vec3 scale): size(size), scale(scale) { }
|
|
glm::vec3 size;
|
|
glm::vec3 scale;
|
|
data::generational::view_vector<Universe::Entity::Instance> instances;
|
|
};
|
|
data::generational::view_vector<Entity> entities;
|
|
/// Player entity instance index
|
|
size_t playerId;
|
|
std::optional<zstd::read_dict_ctx> dict;
|
|
|
|
chunk_pos last_chunk = chunk_pos(INT_MAX);
|
|
bool mayQueryChunks = false;
|
|
uint64_t moveCounter = 0;
|
|
|
|
options options;
|
|
ushort serverDistance;
|
|
|
|
net::client::Client peer;
|
|
};
|
|
} |