#pragma once #include "../Common/Sizes.hpp" #include "BiomeType.hpp" #include "BlockType.hpp" #include "../GFX/Mesh.hpp" namespace MC::World { class Chunk { public: static constexpr U32 Width = 16; static constexpr U32 Height = 128; Chunk(I64 x, I64 y) : m_blocks{Width * Height * Width, {BlockType::Air}}, m_position{(Real)x * Width, 0.0f, (Real)y * Width} {} struct BlockData { BlockData() : type(BlockType::Air) {} BlockData(BlockType t) : type(t), light{} {} BlockType type; U8 light; Bool empty() const { return type == BlockType::Air; } }; const BlockData& at(U32 x, U32 y, U32 z) const; BlockData& at(U32 x, U32 y, U32 z); Bool is_empty(U32 x, U32 y, U32 z) const; struct Details { Matrix landmass_values{}; Matrix hill_values{}; Matrix temperature_values{}; Matrix humidity_values{}; Matrix biome_values{}; }; void set_details(const Details& details) { m_details = details; } Details& details(){ return m_details; } Vector<3> position() const; static Bool is_valid_position(U32 x, U32 y, U32 z); private: static U64 pos(U32 x, U32 y, U32 z); Vector<3> m_position; std::vector m_blocks; Details m_details; }; }