summaryrefslogtreecommitdiffstats
path: root/source/cWorldGenerator.h
blob: 157f93d8367693cd58d131ed4d28f397d0d33c63 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

#pragma once





#include "ChunkDef.h"
#include "MersenneTwister.h"





// fwd:
class cWorld;





class cWorldGenerator
{
public:
	cWorldGenerator(cWorld * a_World);
	~cWorldGenerator();

	virtual void GenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, BLOCKTYPE * a_BlockData, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities);
	
	virtual void PostGenerateChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ);  // Called when the chunk has been already generated and set valid

protected:

	cWorld * m_World;
	
	// Thread-unsafe:
	MTRand r1;
	
	void GenerateOre(char a_OreType, int a_MaxHeight, int a_NumNests, int a_NestSize, BLOCKTYPE * a_BlockData);

	static unsigned int MakeIndex(int x, int y, int z );

	virtual void GenerateTerrain(int a_ChunkX, int a_ChunkY, int a_ChunkZ, BLOCKTYPE * a_BlockData);
	
	virtual void GenerateFoliage(int a_ChunkX, int a_ChunkY, int a_ChunkZ);

	/// Checks if the chunk has all 8 neighbors valid, if so, foliage is generated on that chunk
	void CheckNeighbors(int a_ChunkX, int a_ChunkY, int a_ChunkZ);
};