From dcd030c6ed41e080846d1d50cf82e1055ae48edd Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Fri, 15 Sep 2017 20:46:56 +0500 Subject: 2017-09-15 --- src/World.hpp | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'src/World.hpp') 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 #include #include +#include #include @@ -17,9 +18,9 @@ class World { int dimension = 0; - std::map sections; + std::map> sections; - Section ParseSection(StreamInput *data, Vector position); + Section ParseSection(StreamInput *data, Vector position); std::vector entities; @@ -27,14 +28,16 @@ class World { std::vector sectionsList; - void UpdateSectionList(); + std::mutex sectionsListMutex; + + void UpdateSectionsList(); public: - World(); + World(); - ~World(); + ~World(); - void ParseChunkData(std::shared_ptr packet); + void ParseChunkData(std::shared_ptr packet); void ParseChunkData(std::shared_ptr packet); @@ -42,13 +45,13 @@ public: void ParseChunkData(std::shared_ptr packet); - bool isPlayerCollides(double X, double Y, double Z); + bool isPlayerCollides(double X, double Y, double Z); - const std::vector& GetSectionsList(); + std::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 -- cgit v1.2.3