summaryrefslogtreecommitdiffstats
path: root/src/World.hpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-09-15 17:46:56 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-01-13 03:39:31 +0100
commitdcd030c6ed41e080846d1d50cf82e1055ae48edd (patch)
tree791bf81717a40273fcd6f72b06d3eb24c0c94b1a /src/World.hpp
parent2017-09-03 (diff)
downloadAltCraft-dcd030c6ed41e080846d1d50cf82e1055ae48edd.tar
AltCraft-dcd030c6ed41e080846d1d50cf82e1055ae48edd.tar.gz
AltCraft-dcd030c6ed41e080846d1d50cf82e1055ae48edd.tar.bz2
AltCraft-dcd030c6ed41e080846d1d50cf82e1055ae48edd.tar.lz
AltCraft-dcd030c6ed41e080846d1d50cf82e1055ae48edd.tar.xz
AltCraft-dcd030c6ed41e080846d1d50cf82e1055ae48edd.tar.zst
AltCraft-dcd030c6ed41e080846d1d50cf82e1055ae48edd.zip
Diffstat (limited to 'src/World.hpp')
-rw-r--r--src/World.hpp33
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