#pragma once #include #include #include #include #include #include "Block.h" #include "DoLaterHandler.h" #include "Tickable.h" class Chunk : public virtual Framework::ReferenceCounter, public Tickable { private: int dimensionId; Framework::Punkt location; Block** blocks; Chunk* zNeighbours[4]; unsigned short* blockIds; Framework::Either zBlockNeighbor( Framework::Vec3 location); bool added; Framework::Critical cs; Framework::Array observers; Framework::Array lightSources; Framework::Array tickSources; unsigned char* lightData; bool currentlyLoading; void addLightSource(int index); void removeLightSource(int index); void sendLightToClient(Framework::StreamWriter* zWriter); void broadcastLightData(int index, bool foreground); public: Chunk(Framework::Punkt location, int dimensionId); Chunk(Framework::Punkt location, int dimensionId, Framework::StreamReader* zReader); ~Chunk(); void tick(TickQueue* zQueue) override; void postTick() override; void notifyObservers(NetworkMessage* msg); void addObserver(Entity* zEntity, DoLaterHandler& laterHandler); void removeObserver(Entity* zEntity); void api(Framework::StreamReader* zRequest, Entity* zSource, DoLaterHandler& laterHandler); void initializeLightning(); Framework::Either zBlockAt( Framework::Vec3 cLocation) const; const Block* zBlockConst(Framework::Vec3 location) const; void instantiateBlock(Framework::Vec3 location); void generateBlock(Framework::Vec3 location); void putBlockAt(Framework::Vec3 location, Block* block); void putBlockTypeAt(Framework::Vec3 location, int type); void setNeighbor(Direction dir, Chunk* zChunk); void load(Framework::StreamReader* zReader); void save(Framework::StreamWriter* zWriter); void sendToClient(Framework::StreamWriter* zWriter); void removeUnusedBlocks(); int getDimensionId() const; void onLoaded(); void onUnloaded(); Framework::Punkt getCenter() const; Framework::Vec3 getMin() const; Framework::Vec3 getMax() const; void prepareRemove(); void setAdded(); bool hasObservers() const; unsigned char* getLightData(Framework::Vec3 location) const; void setLightData( Framework::Vec3 location, unsigned char* data, bool foreground); };