private static Voxel GenerateVoxel(Slice slice, int x, int z) { byte constituentAmount = 10; // Stone int stoneHeight = Mathf.FloorToInt(Instance.stoneBaseHeight); stoneHeight += GetNoise(x, 0, z, Instance.stoneMountainFrequency, Mathf.FloorToInt(Instance.stoneMountainHeight)); if (stoneHeight < Instance.stoneMinHeight) { stoneHeight = Mathf.FloorToInt(Instance.stoneMinHeight); } stoneHeight += GetNoise(x, 0, z, Instance.stoneBaseNoise, Mathf.FloorToInt(Instance.stoneBaseNoiseHeight)); // Dirt int dirtHeight = stoneHeight + Mathf.FloorToInt(Instance.dirtBaseHeight); dirtHeight += GetNoise(x, 100, z, Instance.dirtNoise, Mathf.FloorToInt(instance.dirtNoiseHeight)); int y = slice.Y - Map.YOffset; Voxel voxel = new Voxel(slice, x - slice.X, z - slice.Z); int caveChance = GetNoise(x, y, z, Instance.caveFrequency, 100); if (y <= stoneHeight && Instance.caveSize < caveChance) { voxel.AddConstituent(GameData.GetConstituent("stone", "stone"), constituentAmount); } else if (y <= dirtHeight && Instance.caveSize < caveChance) { voxel.AddConstituent(GameData.GetConstituent("dirt", "dirt"), constituentAmount); } return(voxel); }