diff options
Diffstat (limited to '')
-rw-r--r-- | src/World.hpp | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/World.hpp b/src/World.hpp index 89c40d4..6b8b5d1 100644 --- a/src/World.hpp +++ b/src/World.hpp @@ -3,6 +3,7 @@ #include <map> #include <bitset> #include <queue> +#include <memory> #include <easylogging++.h> @@ -17,9 +18,9 @@ class World { int dimension = 0; - std::map<Vector, Section> sections; + std::map<Vector, std::unique_ptr<Section>> sections; - Section ParseSection(StreamInput *data, Vector position); + Section ParseSection(StreamInput *data, Vector position); std::vector<Entity> entities; @@ -27,14 +28,16 @@ class World { std::vector<Vector> sectionsList; - void UpdateSectionList(); + std::mutex sectionsListMutex; + + void UpdateSectionsList(); public: - World(); + World(); - ~World(); + ~World(); - void ParseChunkData(std::shared_ptr<PacketChunkData> packet); + void ParseChunkData(std::shared_ptr<PacketChunkData> packet); void ParseChunkData(std::shared_ptr<PacketBlockChange> packet); @@ -42,13 +45,13 @@ public: void ParseChunkData(std::shared_ptr<PacketUnloadChunk> packet); - bool isPlayerCollides(double X, double Y, double Z); + bool isPlayerCollides(double X, double Y, double Z); - const std::vector<Vector>& GetSectionsList(); + std::vector<Vector> GetSectionsList(); - const Section* GetSection(Vector sectionPos); + const Section &GetSection(Vector sectionPos); - glm::vec3 Raycast(glm::vec3 position, glm::vec3 direction, float maxLength = 1000.0f, float minPrecision = 0.01f); + glm::vec3 Raycast(glm::vec3 position, glm::vec3 direction, float maxLength = 1000.0f, float minPrecision = 0.01f); void UpdatePhysics(float delta); @@ -59,4 +62,14 @@ public: void AddEntity(Entity entity); void DeleteEntity(unsigned int EntityId); + + BlockId GetBlockId(Vector pos); + + void SetBlockId(Vector pos, BlockId block); + + void SetBlockLight(Vector pos, unsigned char light); + + void SetBlockSkyLight(Vector pos, unsigned char light); + + Section *GetSectionPtr(Vector position); };
\ No newline at end of file |