#pragma once #include "Common.h" #include "nbt/NBT.h" #include "Chunk.h" #include "Palette.h" #include "../Lockable.h" #include #include #include namespace Feather { struct LevelData { int32_t spawnX, spawnY, spawnZ; }; class World { public: // Min and max build height, inclusive static constexpr int MIN_BUILD_HEIGHT = 0, MAX_BUILD_HEIGHT = 255; public: World(std::string name); void PrepareSpawn(); // global palette of all block states // TODO: move this to ChunkSection static const GlobalPalette GLOBAL_PALETTE; Chunk* GetChunk(ChunkPos pos); bool SetBlock(const BlockPos& pos, const BlockState& state); LevelData GetLevelData() const { return m_levelData; } inline bool IsOutsideBuildHeight(BlockPos pos) { return IsOutsideBuildHeight(pos.y); } inline bool IsOutsideBuildHeight(int y) { return y < MIN_BUILD_HEIGHT || y > MAX_BUILD_HEIGHT; } private: std::unique_ptr LoadChunk(ChunkPos pos); LockableMap> m_chunks; LevelData m_levelData; // TODO nuke this shit std::string m_name; }; }