summaryrefslogtreecommitdiffstats
path: root/src/Generating/EndGen.h
blob: c2278c1e1aec0129b822098eff40606f50ccfd63 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

// EndGen.h

// Declares the cEndGen class representing the generator for the End, both as a HeightGen and CompositionGen





#pragma once

#include "ComposableGenerator.h"
#include "../Noise/Noise.h"





class cEndGen :
	public cTerrainHeightGen,
	public cTerrainCompositionGen
{
public:
	cEndGen(int a_Seed);
	
protected:

	/// Seed for the noise
	int m_Seed;
	
	/// The Perlin noise used for generating
	cPerlinNoise m_Perlin;

	// XYZ size of the "island", in blocks:
	int m_IslandSizeX;
	int m_IslandSizeY;
	int m_IslandSizeZ;
	
	// XYZ Frequencies of the noise functions:
	NOISE_DATATYPE m_FrequencyX;
	NOISE_DATATYPE m_FrequencyY;
	NOISE_DATATYPE m_FrequencyZ;
	
	// Minimum and maximum chunk coords for chunks inside the island area. Chunks outside won't get calculated at all
	int m_MinChunkX, m_MaxChunkX;
	int m_MinChunkZ, m_MaxChunkZ;
	
	// Noise array for the last chunk (in the noise range)
	int m_LastChunkX;
	int m_LastChunkZ;
	NOISE_DATATYPE m_NoiseArray[17 * 17 * 257];  // x + 17 * z + 17 * 17 * y
	
	/// Unless the LastChunk coords are equal to coords given, prepares the internal state (noise array)
	void PrepareState(int a_ChunkX, int a_ChunkZ);
	
	/// Generates the m_NoiseArray array for the current chunk
	void GenerateNoiseArray(void);
	
	/// Returns true if the chunk is outside of the island's dimensions
	bool IsChunkOutsideRange(int a_ChunkX, int a_ChunkZ);
		
	// cTerrainHeightGen overrides:
	virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override;

	// cTerrainCompositionGen overrides:
	virtual void ComposeTerrain(cChunkDesc & a_ChunkDesc) override;
	virtual void InitializeCompoGen(cIniFile & a_IniFile) override;
} ;