123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #pragma once
- #include "Block.h"
- #include "DoLaterHandler.h"
- #include <Vec3.h>
- #include <Array.h>
- #include <Datei.h>
- #include <Punkt.h>
- #include <Either.h>
- class Chunk : public virtual Framework::ReferenceCounter
- {
- private:
- int dimensionId;
- Framework::Punkt location;
- Block** blocks;
- Chunk* zNeighbours[4];
- unsigned short* blockIds;
- Framework::Either<Block*, int> zBlockNeighbor(Framework::Vec3<int> location);
- bool added;
- Framework::Critical cs;
- Framework::Array<int> observers;
- Framework::Array<int> lightSources;
- unsigned char* lightData;
- void addLightSource(int index);
- void removeLightSource(int index);
- void sendLightToClient(Framework::StreamWriter* zWriter);
- public:
- Chunk(Framework::Punkt location, int dimensionId);
- Chunk(Framework::Punkt location, int dimensionId, Framework::StreamReader* zReader);
- ~Chunk();
- 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<Block*, int> zBlockAt(Framework::Vec3<int> cLocation) const;
- const Block* zBlockConst(Framework::Vec3<int> location) const;
- void instantiateBlock(Framework::Vec3<int> location);
- void generateBlock(Framework::Vec3<int> location);
- void putBlockAt(Framework::Vec3<int> location, Block* block);
- void putBlockTypeAt(Framework::Vec3<int> 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;
- Framework::Punkt getCenter() const;
- Framework::Vec3<int> getMin() const;
- Framework::Vec3<int> getMax() const;
- void prepareRemove();
- void setAdded();
- bool hasObservers() const;
- unsigned char* getLightData(Framework::Vec3<int> location) const;
- void setLightData(Framework::Vec3<int> location, unsigned char* data, bool foreground);
- };
|