#pragma once #include #include #include #include "Chunk.h" #include "Entity.h" class World; class Dimension : public virtual Framework::Model3DCollection { private: int id; float gravity; Framework::RCTrie* chunks; Framework::Array chunkList; Framework::RCArray* entities; Framework::Critical cs; void getAddrOf(Framework::Punkt cPos, char* addr) const; void getAddrOfWorld(Framework::Punkt wPos, char* addr) const; public: Dimension(); ~Dimension(); void forAll(std::function f) override; void render(std::function f) override; bool tick(std::function f, double time) override; void setId(int id); void api(char* message); Block* zBlock(Framework::Vec3 location); Block* getBlock(Framework::Vec3 location); void addEntity(Entity* entity); void setChunk(Chunk* chunk, Framework::Punkt center); bool hasChunck(int x, int y) const; Chunk* zChunk(Framework::Punkt wPos) const; void removeDistantChunks(Framework::Punkt wPos); void setBlock(Block* block); void removeBlock(Block* zBlock); Entity* zEntity(int id); Entity* getEntity(int id); void removeEntity(int id); int getId() const; float getGravity() const; inline static Framework::Vec3 chunkCoordinates( Framework::Vec3 worldLocation) { Framework::Vec3 result = worldLocation; result.x = result.x % CHUNK_SIZE; result.y = result.y % CHUNK_SIZE; if (result.x < 0) result.x += CHUNK_SIZE; if (result.y < 0) result.y += CHUNK_SIZE; return result; } };