12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #pragma once
- #include "Block.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<Entity*> views;
- public:
- Chunk( Framework::Punkt location, int dimensionId );
- Chunk( Framework::Punkt location, int dimensionId, Framework::StreamReader* zReader );
- ~Chunk();
- void api( Framework::StreamReader* zRequest, NetworkResponse* zResponse );
- 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, StreamTarget target );
- void removeUnusedBlocks();
- int getDimensionId() const;
- Framework::Punkt getCenter() const;
- Framework::Vec3<int> getMin() const;
- Framework::Vec3<int> getMax() const;
- void prepareRemove();
- void setAdded();
- void addView( Entity* zEntity );
- void removeView( Entity* zEntity );
- bool hasView( Entity* zEntity );
- bool hasViews() const;
- };
|