55 lines
1.2 KiB
C++
55 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include "Common.h"
|
|
#include "nbt/NBT.h"
|
|
#include "Chunk.h"
|
|
#include "Palette.h"
|
|
#include "../Lockable.h"
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <map>
|
|
|
|
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<BlockState> 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<Chunk> LoadChunk(ChunkPos pos);
|
|
|
|
LockableMap<ChunkPos, std::unique_ptr<Chunk>> m_chunks;
|
|
|
|
LevelData m_levelData;
|
|
|
|
// TODO nuke this shit
|
|
std::string m_name;
|
|
};
|
|
}
|