#pragma once

#include "Universe.hpp"
#include "../../core/server_handle.hpp"

namespace world::client {
    /// Whole universe container in client with in-memory server
    class LocalUniverse final: public Universe {
    public:
        LocalUniverse(server_handle *const handle, const std::string& contouring);
        ~LocalUniverse();

        void update(voxel_pos pos, float deltaTime) override;
        void emit(const action::packet &) override;

        ray_result raycast(const geometry::Ray &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 handle->running; }

        size_t getPlayerId() const override { return PLAYER_ENTITY_ID.index; }

    protected:
        server_handle *const handle;

        chunk_pos last_chunk = chunk_pos(INT_MAX);
    };
}