Esempio n. 1
0
cGridStructGen::cStructurePtr cUnderwaterBaseGen::CreateStructure(int a_OriginX, int a_OriginZ)
{
	// Generate the biomes for the chunk surrounding the origin:
	int ChunkX, ChunkZ;
	cChunkDef::BlockToChunk(a_OriginX, a_OriginZ, ChunkX, ChunkZ);
	cChunkDef::BiomeMap Biomes;
	m_BiomeGen.GenBiomes(ChunkX, ChunkZ, Biomes);

	// Check if all the biomes are ocean:
	// If just one is not, no base is created, because it's likely that an unfriendly biome is too close
	for (size_t i = 0; i < ARRAYCOUNT(Biomes); i++)
	{
		switch (Biomes[i])
		{
			case biOcean:
			case biDeepOcean:
			{
				// These biomes allow underwater bases
				break;
			}
			default:
			{
				// base-unfriendly biome, bail out with zero structure:
				return cStructurePtr();
			}
		}  // switch (Biomes[i])
	}  // for i - Biomes[]

	// Create a base based on the chosen prefabs:
	return cStructurePtr(new cUnderwaterBase(m_Seed, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize));
}
Esempio n. 2
0
cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ)
{
	// Generate the biomes for the chunk surrounding the origin:
	int ChunkX, ChunkZ;
	cChunkDef::BlockToChunk(a_OriginX, a_OriginZ, ChunkX, ChunkZ);
	cChunkDef::BiomeMap Biomes;
	m_BiomeGen->GenBiomes(ChunkX, ChunkZ, Biomes);

	// Get a list of pools that support each biome within the chunk:
	// If just one column's biome is not allowed, the pool is not used because it's likely that an unfriendly biome is too close
	auto availablePools = m_Pools;
	for (size_t i = 0; i < ARRAYCOUNT(Biomes); i++)
	{
		auto biome = Biomes[i];
		availablePools.erase(std::remove_if(availablePools.begin(), availablePools.end(),
			[biome](SharedPtr<cPrefabPiecePool> a_Pool)
			{
				return !a_Pool->IsBiomeAllowed(biome);
			}),
			availablePools.end()
		);
		// Bail out if no compatible pools left:
		if (availablePools.empty())
		{
			return cStructurePtr();
		}
	}

	// Pick one pool from the available pools:
	if (availablePools.empty())
	{
		return cStructurePtr();
	}
	auto rnd = m_Noise.IntNoise2DInt(a_OriginX, a_OriginZ) / 11;
	auto pool = availablePools[static_cast<size_t>(rnd) % availablePools.size()];
	rnd /= 137;

	// Choose density for the village, random between m_MinDensity and m_MaxDensity:
	int Density;
	if (pool->GetMaxDensity() > pool->GetMinDensity())
	{
		Density = pool->GetMinDensity() + rnd % (pool->GetMaxDensity() - pool->GetMinDensity());
	}
	else
	{
		Density = pool->GetMinDensity();
	}
	
	// Create a village based on the chosen prefabs:
	return cStructurePtr(new cVillage(m_Seed, a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize, Density, *pool.get(), m_HeightGen));
}
Esempio n. 3
0
cGridStructGen::cStructurePtr cRoughRavines::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ)
{
	// Pick a random value for each of the ravine's parameters:
	int Size = m_MinSize + (m_Noise.IntNoise2DInt(a_GridX, a_GridZ) / 7) % (m_MaxSize - m_MinSize);  // Random int from m_MinSize to m_MaxSize
	float CenterWidth         = m_Noise.IntNoise2DInRange(a_GridX + 10, a_GridZ, m_MinCenterWidth,         m_MaxCenterWidth);
	float Roughness           = m_Noise.IntNoise2DInRange(a_GridX + 20, a_GridZ, m_MinRoughness,           m_MaxRoughness);
	float FloorHeightEdge1    = m_Noise.IntNoise2DInRange(a_GridX + 30, a_GridZ, m_MinFloorHeightEdge,     m_MaxFloorHeightEdge);
	float FloorHeightEdge2    = m_Noise.IntNoise2DInRange(a_GridX + 40, a_GridZ, m_MinFloorHeightEdge,     m_MaxFloorHeightEdge);
	float FloorHeightCenter   = m_Noise.IntNoise2DInRange(a_GridX + 50, a_GridZ, m_MinFloorHeightCenter,   m_MaxFloorHeightCenter);
	float CeilingHeightEdge1  = m_Noise.IntNoise2DInRange(a_GridX + 60, a_GridZ, m_MinCeilingHeightEdge,   m_MaxCeilingHeightEdge);
	float CeilingHeightEdge2  = m_Noise.IntNoise2DInRange(a_GridX + 70, a_GridZ, m_MinCeilingHeightEdge,   m_MaxCeilingHeightEdge);
	float CeilingHeightCenter = m_Noise.IntNoise2DInRange(a_GridX + 80, a_GridZ, m_MinCeilingHeightCenter, m_MaxCeilingHeightCenter);
	
	// Create a ravine:
	return cStructurePtr(new cRoughRavine(
		m_Seed,
		Size, CenterWidth, Roughness,
		FloorHeightEdge1,   FloorHeightEdge2,   FloorHeightCenter,
		CeilingHeightEdge1, CeilingHeightEdge2, CeilingHeightCenter,
		a_GridX, a_GridZ, a_OriginX, a_OriginZ
	));
}
Esempio n. 4
0
cGridStructGen::cStructurePtr cStructGenWormNestCaves::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ)
{
	return cStructurePtr(new cCaveSystem(a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_MaxOffset, m_Size, m_Noise));
}
Esempio n. 5
0
cGridStructGen::cStructurePtr cStructGenRavines::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ)
{
	return cStructurePtr(new cRavine(a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_Size, m_Noise));
}
Esempio n. 6
0
cGridStructGen::cStructurePtr cTestRailsGen::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ)
{
	// Create a base based on the chosen prefabs:
	return cStructurePtr(new cTestRails(m_Seed, a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize));
}
Esempio n. 7
0
cGridStructGen::cStructurePtr cVillageGen::CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ)
{
	// Generate the biomes for the chunk surrounding the origin:
	int ChunkX, ChunkZ;
	cChunkDef::BlockToChunk(a_OriginX, a_OriginZ, ChunkX, ChunkZ);
	cChunkDef::BiomeMap Biomes;
	m_BiomeGen->GenBiomes(ChunkX, ChunkZ, Biomes);

	// Check if all the biomes are village-friendly:
	// If just one is not, no village is created, because it's likely that an unfriendly biome is too close
	cVillagePiecePool * VillagePrefabs = nullptr;
	BLOCKTYPE RoadBlock = E_BLOCK_GRAVEL;
	BLOCKTYPE WaterRoadBlock = E_BLOCK_PLANKS;
	int rnd = m_Noise.IntNoise2DInt(a_OriginX, a_OriginZ) / 11;
	cVillagePiecePool * PlainsVillage = g_PlainsVillagePools[rnd % ARRAYCOUNT(g_PlainsVillagePools)];
	cVillagePiecePool * DesertVillage = g_DesertVillagePools[rnd % ARRAYCOUNT(g_DesertVillagePools)];
	for (size_t i = 0; i < ARRAYCOUNT(Biomes); i++)
	{
		switch (Biomes[i])
		{
			case biDesert:
			case biDesertM:
			{
				// These biomes allow sand villages
				VillagePrefabs = DesertVillage;
				// RoadBlock = E_BLOCK_SANDSTONE;
				break;
			}
			case biPlains:
			case biSavanna:
			case biSavannaM:
			case biSunflowerPlains:
			{
				// These biomes allow plains-style villages
				VillagePrefabs = PlainsVillage;
				break;
			}
			default:
			{
				// Village-unfriendly biome, bail out with zero structure:
				return cStructurePtr();
			}
		}  // switch (Biomes[i])
	}  // for i - Biomes[]

	// Choose density for the village, random between m_MinDensity and m_MaxDensity:
	int Density;
	if (m_MaxDensity > m_MinDensity)
	{
		Density = m_MinDensity + rnd % (m_MaxDensity - m_MinDensity);
	}
	else
	{
		Density = m_MinDensity;
	}
	
	// Create a village based on the chosen prefabs:
	if (VillagePrefabs == nullptr)
	{
		return cStructurePtr();
	}
	return cStructurePtr(new cVillage(m_Seed, a_GridX, a_GridZ, a_OriginX, a_OriginZ, m_MaxDepth, m_MaxSize, Density, *VillagePrefabs, m_HeightGen, RoadBlock, WaterRoadBlock));
}
Esempio n. 8
0
cGridStructGen::cStructurePtr cNetherFortGen::CreateStructure(int a_OriginX, int a_OriginZ)
{
	return cStructurePtr(new cNetherFort(*this, a_OriginX, a_OriginZ, m_GridSizeX, m_MaxDepth, m_Seed));
}