]> git.lizzy.rs Git - dragonblocks3d.git/blob - src/map.hpp
New structure
[dragonblocks3d.git] / src / map.hpp
1 #pragma once
2
3 #include <map>
4 #include "chunk.hpp"
5 #include "gl.hpp"
6
7 #define DRAGONBLOCKS_MAP_SIZE 1000
8
9 namespace dragonblocks
10 {
11         class AsyncMgr;
12         class BlockDef;
13         class Block;
14         class Mapgen;
15         class Scene;
16         class ShaderProgram;
17         
18         class Map
19         {
20                 public:
21                 static glm::ivec3 getChunkPos(const glm::vec3 &);
22                 static glm::ivec3 getBlockPos(const glm::ivec3 &);
23                 static uint16_t getChunkPosHash(const glm::ivec3 &);
24                 
25                 const Block *getBlock(const glm::ivec3 &);
26                 const Block *getBlockRelativePos(Chunk *, const glm::ivec3 &);
27                 void setBlock(const glm::ivec3 &, BlockDef *);
28                 void createChunk(const glm::ivec3 &, const Chunk::Data &);
29                 void createChunk(const glm::ivec3 &);
30                 Chunk *getChunk(const glm::ivec3 &);
31                 void clear();
32                 
33                 Map(Mapgen *, AsyncMgr *, Scene *, ShaderProgram *);
34                 ~Map();
35                 
36                 private:
37                 std::map<uint16_t, Chunk*> chunks;
38                 Mapgen *mapgen;
39                 AsyncMgr *async_mgr;
40                 Scene *scene;
41                 ShaderProgram *shader_program;
42         };
43 }