2012-06-14 13:06:06 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-04-03 06:57:01 +00:00
|
|
|
#include "../Defines.h"
|
2012-06-14 13:06:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// fwd:
|
|
|
|
class cIniFile;
|
2013-01-25 10:12:29 +00:00
|
|
|
class cChunkDesc;
|
2012-06-14 13:06:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-09-01 07:30:00 +00:00
|
|
|
/** The interface that all chunk generators must implement to provide the generated chunks.
|
|
|
|
Also a static factory that creates the descendants based on INI file settings.
|
|
|
|
The cChunkGeneratorThread uses this interface to generate chunks for a single world.
|
|
|
|
Ths calls to generate chunks are synchronous - they don't return until the chunk is fully generated. */
|
|
|
|
class cChunkGenerator
|
2012-06-14 13:06:06 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-09-01 07:30:00 +00:00
|
|
|
virtual ~cChunkGenerator() {} // Force a virtual destructor
|
2016-02-05 21:45:45 +00:00
|
|
|
|
2019-09-01 07:30:00 +00:00
|
|
|
/** Called to initialize the generator on server startup.
|
|
|
|
Descendants should call Super::Initialize() before initializing themselves. */
|
|
|
|
virtual void Initialize(cIniFile & a_IniFile);
|
2016-02-05 21:45:45 +00:00
|
|
|
|
2019-09-01 07:30:00 +00:00
|
|
|
/** Generates the biomes for the specified chunk.
|
|
|
|
Used by the world loader if biomes failed loading. */
|
2019-09-08 13:59:15 +00:00
|
|
|
virtual void GenerateBiomes(cChunkCoords a_ChunkCoords, cChunkDef::BiomeMap & a_BiomeMap) = 0;
|
2014-09-05 20:16:48 +00:00
|
|
|
|
2019-09-01 07:30:00 +00:00
|
|
|
/** Returns the biome at the specified coords.
|
|
|
|
Used by ChunkMap if an invalid chunk is queried for biome.
|
|
|
|
The default implementation uses GenerateBiomes(). */
|
|
|
|
virtual EMCSBiome GetBiomeAt(int a_BlockX, int a_BlockZ);
|
2016-02-05 21:45:45 +00:00
|
|
|
|
2019-09-01 07:30:00 +00:00
|
|
|
/** Does the actual chunk generation.
|
|
|
|
Descendants need to override this and generate into a_ChunkDesc. */
|
2019-09-08 13:59:15 +00:00
|
|
|
virtual void Generate(cChunkDesc & a_ChunkDesc) = 0;
|
2012-06-14 13:06:06 +00:00
|
|
|
|
2019-09-01 07:30:00 +00:00
|
|
|
/** Returns the seed that was read from the INI file. */
|
2012-06-14 13:06:06 +00:00
|
|
|
int GetSeed(void) const { return m_Seed; }
|
2016-02-05 21:45:45 +00:00
|
|
|
|
2019-09-01 07:30:00 +00:00
|
|
|
/** Creates and initializes the entire generator based on the settings in the INI file.
|
|
|
|
Initializes the generator, so that it can be used immediately after this call returns. */
|
|
|
|
static std::unique_ptr<cChunkGenerator> CreateFromIniFile(cIniFile & a_IniFile);
|
2014-12-10 21:35:16 +00:00
|
|
|
|
|
|
|
|
2019-09-01 07:30:00 +00:00
|
|
|
protected:
|
2014-12-10 21:35:16 +00:00
|
|
|
|
2019-09-01 07:30:00 +00:00
|
|
|
/** The main seed, read from the INI file, used for the entire generator. */
|
2012-06-14 13:06:06 +00:00
|
|
|
int m_Seed;
|
2019-09-01 19:47:03 +00:00
|
|
|
|
|
|
|
/** The dimension, read from the INI file. */
|
|
|
|
eDimension m_Dimension;
|
2012-06-14 13:06:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|