1
0
Fork 0
cuberite-2a/src/ChunkDataCallback.h

71 lines
2.1 KiB
C
Raw Normal View History

2014-05-29 16:25:08 +00:00
// ChunkDataCallback.h
// Declares the cChunkDataCallback interface and several trivial descendants, for reading chunk data
2014-05-29 16:25:08 +00:00
#pragma once
2014-05-21 18:58:48 +00:00
#include "ChunkData.h"
2014-05-29 16:25:08 +00:00
/** Interface class used for getting data out of a chunk using the GetAllData() function.
Implementation must use the pointers immediately and NOT store any of them for later use
2015-07-31 14:49:10 +00:00
The virtual methods are called in the same order as they're declared here. */
class cChunkDataCallback abstract
{
public:
virtual ~cChunkDataCallback() {}
/** Called before any other callbacks to inform of the current coords
(only in processes where multiple chunks can be processed, such as cWorld::ForEachChunkInRect()).
2015-07-31 14:49:10 +00:00
If false is returned, the chunk is skipped. */
virtual bool Coords(int a_ChunkX, int a_ChunkZ) { UNUSED(a_ChunkX); UNUSED(a_ChunkZ); return true; }
2016-02-05 21:45:45 +00:00
2015-07-31 14:49:10 +00:00
/** Called once to let know if the chunk lighting is valid. Return value is ignored */
virtual void LightIsValid(bool a_IsLightValid) { UNUSED(a_IsLightValid); }
2016-02-05 21:45:45 +00:00
/** Called once to export block data. */
virtual void ChunkData(const ChunkBlockData & a_BlockData, const ChunkLightData & a_LightData) { UNUSED(a_BlockData); UNUSED(a_LightData); }
/** Called once to provide heightmap data. */
virtual void HeightMap(const cChunkDef::HeightMap & a_HeightMap) { UNUSED(a_HeightMap); }
/** Called once to provide biome data. */
virtual void BiomeMap(const cChunkDef::BiomeMap & a_BiomeMap) { UNUSED(a_BiomeMap); }
2016-02-05 21:45:45 +00:00
2015-07-31 14:49:10 +00:00
/** Called for each entity in the chunk */
virtual void Entity(cEntity * a_Entity) { UNUSED(a_Entity); }
2016-02-05 21:45:45 +00:00
2015-07-31 14:49:10 +00:00
/** Called for each blockentity in the chunk */
virtual void BlockEntity(cBlockEntity * a_Entity) { UNUSED(a_Entity); }
} ;
2014-05-29 16:25:08 +00:00
/** A simple implementation of the cChunkDataCallback interface that just copies the cChunkData */
class cChunkDataCopyCollector :
public cChunkDataCallback
{
public:
ChunkBlockData m_BlockData;
ChunkLightData m_LightData;
private:
virtual void ChunkData(const ChunkBlockData & a_BlockData, const ChunkLightData & a_LightData) override
{
m_BlockData.Assign(a_BlockData);
m_LightData.Assign(a_LightData);
}
};