public static Queue <BlockMod> MakeTree(Vector3 position, int minTrunkHeight, int maxTrunkHeight) { Queue <BlockMod> queue = new Queue <BlockMod>(); int height = (int)(maxTrunkHeight * Terrian.TreeGeneration(new Vector2(position.x, position.z), 250f, 3f)); if (height < minTrunkHeight) { height = minTrunkHeight; } for (int i = 1; i < height; i++) { queue.Enqueue(new BlockMod(new Vector3(position.x, position.y + i, position.z), 6)); } for (int x = -2; x < 3; x++) { for (int y = 0; y < 5; y++) { for (int z = -2; z < 3; z++) { queue.Enqueue(new BlockMod(new Vector3(position.x + x, position.y + height + y, position.z + z), 11)); } } } return(queue); }
public static Queue <BlockMod> MakeCacti(Vector3 position, int minTrunkHeight, int maxTrunkHeight) { Queue <BlockMod> queue = new Queue <BlockMod>(); int height = (int)(maxTrunkHeight * Terrian.TreeGeneration(new Vector2(position.x, position.z), 23456f, 2f)); if (height < minTrunkHeight) { height = minTrunkHeight; } for (int i = 1; i <= height; i++) { queue.Enqueue(new BlockMod(new Vector3(position.x, position.y + i, position.z), 12)); } return(queue); }
public byte GetBlock(Vector3 pos) { // IMMUTABLE PASS int yPos = Mathf.FloorToInt(pos.y); if (!IsBlockInWorld(pos)) { return(0); } // if (yPos == -200) // { // return 1; // } // BIOME SELECTION PASS float sumOfHeights = 0f; int count = 0; float strongestWeight = 0f; int strongestBiomeIndex = 0; for (int i = 0; i < biomes.Length; i++) { float weight = Terrian.GenerateHeight(new Vector2(pos.x, pos.z), solidGroundHeight, biomes[i].terrainHeight, biomes[i].terrainOffset, biomes[i].terrainSmooth, biomes[i].terrainOctaves, biomes[i].terrainScale); // Keep track of which weight is strongest. if (weight > strongestWeight) { strongestWeight = weight; strongestBiomeIndex = i; } // Get the height of the terrain (for the current biome) and multiply it by its weight. float height = biomes[i].terrainHeight * Terrian.GenerateHeight(new Vector2(pos.x, pos.z), solidGroundHeight, biomes[i].terrainHeight, biomes[i].terrainOffset, biomes[i].terrainSmooth, biomes[i].terrainOctaves, biomes[i].terrainScale) * weight; // If the height value is greater 0 add it to the sum of heights. if (height > 0) { sumOfHeights += height; count++; } // Set biome to the one with the strongest weight. } Biomes biome = biomes[strongestBiomeIndex]; // Get the average of the heights. sumOfHeights /= count; // BASIC TERRAIN PASS int terrainHeight = Mathf.FloorToInt(sumOfHeights + solidGroundHeight); byte blockValue; if (yPos == terrainHeight) { blockValue = 3; //Grass } else if (yPos < terrainHeight && yPos > terrainHeight - 4) { blockValue = 5; // Dirt } else if (yPos > terrainHeight) { return(0); // Air } else { blockValue = 2; //Stone } // ORE TERRAIN PASS if (blockValue == 2) { foreach (Lode lode in biome.lodes) { if (yPos > lode.minHeight && yPos < lode.maxHeight) { if (Terrian.FBM3D(pos.x, pos.y, pos.z, lode.offset, lode.smooth, (int)lode.octaves, lode.persistance, lode.threshold)) { blockValue = lode.BlockID; } } } } //TREE TERRAIN PASS if (yPos == terrainHeight && biome.placeMajorFlora) { if (Terrian.TreeGeneration(new Vector2(pos.x, pos.z), 0, biome.majorFloraZoneScale) > biome.majorFloraZoneThreshold) { if (Terrian.TreeGeneration(new Vector2(pos.x, pos.z), 0, biome.majorFloraPlacementScale) > biome.majorFloraPlacementThreshold) { modifications.Enqueue(Structure.GenerateMajorFlora(biome.majorFloraIndex, pos, biome.minMajorFloraHeight, biome.maxMajorFloraHeight)); } } } return(blockValue); }