2020-08-07 05:48:54 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Common.h"
|
2020-08-13 04:15:51 +01:00
|
|
|
#include "nbt/NBT.h"
|
|
|
|
#include "Chunk.h"
|
2020-08-13 04:10:44 +01:00
|
|
|
#include "Palette.h"
|
2020-08-13 18:06:28 +01:00
|
|
|
#include "../Lockable.h"
|
2020-08-13 04:10:44 +01:00
|
|
|
|
2020-08-07 05:48:54 +01:00
|
|
|
#include <cstdint>
|
|
|
|
#include <string>
|
2020-08-13 18:06:28 +01:00
|
|
|
#include <map>
|
2020-08-07 05:48:54 +01:00
|
|
|
|
|
|
|
namespace Feather
|
|
|
|
{
|
2020-08-13 18:06:28 +01:00
|
|
|
struct LevelData
|
|
|
|
{
|
|
|
|
int32_t spawnX, spawnY, spawnZ;
|
|
|
|
};
|
|
|
|
|
2020-08-07 05:48:54 +01:00
|
|
|
class World
|
|
|
|
{
|
2020-11-05 00:32:44 +00:00
|
|
|
public:
|
|
|
|
// Min and max build height, inclusive
|
|
|
|
static constexpr int MIN_BUILD_HEIGHT = 0, MAX_BUILD_HEIGHT = 255;
|
|
|
|
|
2020-08-07 05:48:54 +01:00
|
|
|
public:
|
2020-08-13 18:06:28 +01:00
|
|
|
World(std::string name);
|
|
|
|
|
2020-08-14 02:41:05 +01:00
|
|
|
void PrepareSpawn();
|
|
|
|
|
2020-08-13 04:10:44 +01:00
|
|
|
// global palette of all block states
|
|
|
|
static const GlobalPalette<BlockState> GLOBAL_PALETTE;
|
2020-08-13 04:15:51 +01:00
|
|
|
|
2020-08-13 18:06:28 +01:00
|
|
|
Chunk* GetChunk(ChunkPos pos);
|
2020-08-13 04:15:51 +01:00
|
|
|
|
2020-11-05 00:32:44 +00:00
|
|
|
bool SetBlock(const BlockPos& pos, const BlockState& state);
|
|
|
|
|
2020-08-13 18:06:28 +01:00
|
|
|
LevelData GetLevelData() const { return m_levelData; }
|
2020-08-07 05:48:54 +01:00
|
|
|
|
2020-11-05 00:32:44 +00:00
|
|
|
inline bool IsOutsideBuildHeight(BlockPos pos) { return IsOutsideBuildHeight(pos.y); }
|
|
|
|
inline bool IsOutsideBuildHeight(int y) { return y < MIN_BUILD_HEIGHT || y > MAX_BUILD_HEIGHT; }
|
|
|
|
|
2020-08-13 18:06:28 +01:00
|
|
|
private:
|
|
|
|
std::unique_ptr<Chunk> LoadChunk(ChunkPos pos);
|
|
|
|
|
2020-11-05 00:32:44 +00:00
|
|
|
LockableMap<ChunkPos, std::unique_ptr<Chunk>> m_chunks;
|
2020-08-13 18:06:28 +01:00
|
|
|
|
|
|
|
LevelData m_levelData;
|
|
|
|
|
|
|
|
// TODO nuke this shit
|
|
|
|
std::string m_name;
|
2020-08-07 05:48:54 +01:00
|
|
|
};
|
2020-11-05 00:32:44 +00:00
|
|
|
}
|