12345678910111213141516171819202122232425262728293031323334353637383940 |
- #include "AddChunkUpdate.h"
- #include "Chunk.h"
- #include "Constants.h"
- #include "Dimension.h"
- AddChunkUpdate::AddChunkUpdate( Chunk* chunk )
- : WorldUpdate( AddChunkUpdateType::ID, chunk->getDimensionId(), Framework::Vec3<int>( chunk->getCenter().x - CHUNK_SIZE / 2, chunk->getCenter().y - CHUNK_SIZE / 2, 0 ), Framework::Vec3<int>( chunk->getCenter().x + CHUNK_SIZE / 2 - 1, chunk->getCenter().y + CHUNK_SIZE / 2 - 1, WORLD_HEIGHT - 1 ) ),
- chunk( chunk )
- {}
- AddChunkUpdate::~AddChunkUpdate()
- {
- chunk->release();
- }
- void AddChunkUpdate::onUpdate( Dimension* zDimension )
- {
- zDimension->setChunk( dynamic_cast<Chunk*>(chunk->getThis()), chunk->getCenter() );
- }
- void AddChunkUpdate::write( Framework::StreamWriter* zWriter )
- {
- int dimensionID = chunk->getDimensionId();
- zWriter->schreibe( (char*)&dimensionID, 4 );
- Framework::Punkt center = chunk->getCenter();
- zWriter->schreibe( (char*)¢er.x, 4 );
- zWriter->schreibe( (char*)¢er.y, 4 );
- chunk->save( zWriter, StreamTarget::CLIENT );
- }
- Chunk* AddChunkUpdate::zChunk() const
- {
- return chunk;
- }
- AddChunkUpdateType::AddChunkUpdateType()
- : WorldUpdateType( ID )
- {}
|