summaryrefslogtreecommitdiffstats
path: root/src/World.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/World.hpp')
-rw-r--r--src/World.hpp35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/World.hpp b/src/World.hpp
index 165e73d..6c9a615 100644
--- a/src/World.hpp
+++ b/src/World.hpp
@@ -11,8 +11,8 @@
#include "Entity.hpp"
#include "Block.hpp"
#include "Vector.hpp"
+#include "Section.hpp"
-class Section;
class PacketChunkData;
class PacketBlockChange;
class PacketMultiBlockChange;
@@ -28,24 +28,17 @@ struct RaycastResult {
class World {
int dimension = 0;
- std::map<Vector, std::unique_ptr<Section>> sections;
+ std::map<Vector, std::shared_ptr<Section>> sections;
Section ParseSection(StreamInput *data, Vector position);
std::list<Entity> entities;
- std::mutex entitiesMutex;
-
std::vector<Vector> sectionsList;
- std::mutex sectionsListMutex;
-
void UpdateSectionsList();
public:
- World();
-
- ~World();
void ParseChunkData(std::shared_ptr<PacketChunkData> packet);
@@ -55,13 +48,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;
- const Section &GetSection(Vector sectionPos);
+ const Section &GetSection(Vector sectionPos) const;
- RaycastResult Raycast(glm::vec3 position, glm::vec3 direction);
+ RaycastResult Raycast(glm::vec3 position, glm::vec3 direction) const;
void UpdatePhysics(float delta);
@@ -69,13 +62,15 @@ public:
Entity* GetEntityPtr(unsigned int EntityId);
- std::vector<unsigned int> GetEntitiesList();
+ const Entity& GetEntity(unsigned int EntityId) const;
+
+ std::vector<unsigned int> GetEntitiesList() const;
void AddEntity(Entity entity);
void DeleteEntity(unsigned int EntityId);
- BlockId GetBlockId(Vector pos);
+ BlockId GetBlockId(Vector pos) const;
void SetBlockId(Vector pos, BlockId block);
@@ -83,13 +78,13 @@ public:
void SetBlockSkyLight(Vector pos, unsigned char light);
- Section *GetSectionPtr(Vector position);
+ const Section *GetSectionPtr(Vector position) const;
- unsigned char GetBlockLight(Vector pos);
+ unsigned char GetBlockLight(Vector pos) const;
- unsigned char GetBlockLight(const Vector &blockPos, const Section *section, const Section *xp, const Section *xn, const Section *yp, const Section *yn, const Section *zp, const Section *zn);
+ unsigned char GetBlockLight(const Vector &blockPos, const Section *section, const Section *xp, const Section *xn, const Section *yp, const Section *yn, const Section *zp, const Section *zn) const;
- unsigned char GetBlockSkyLight(Vector pos);
+ unsigned char GetBlockSkyLight(Vector pos) const;
- unsigned char GetBlockSkyLight(const Vector &blockPos, const Section *section, const Section *xp, const Section *xn, const Section *yp, const Section *yn, const Section *zp, const Section *zn);
+ unsigned char GetBlockSkyLight(const Vector &blockPos, const Section *section, const Section *xp, const Section *xn, const Section *yp, const Section *yn, const Section *zp, const Section *zn) const;
}; \ No newline at end of file