public static void GenerateCaveVegetation(VoxelChunk chunk, int x, int y, int z, int caveHeight, BiomeData biome, Vector3 vec, WorldManager world, Perlin NoiseGenerator) { var vUnder = new VoxelHandle(chunk, new LocalVoxelCoordinate(x, y - 1, z)); var wayUnder = new VoxelHandle(chunk, new LocalVoxelCoordinate(x, y - caveHeight, z)); wayUnder.RawSetType(VoxelLibrary.GetVoxelType(biome.SoilLayer.VoxelType)); wayUnder.RawSetGrass(GrassLibrary.GetGrassType(biome.GrassDecal).ID); foreach (VegetationData veg in biome.Vegetation) { if (!MathFunctions.RandEvent(veg.SpawnProbability)) { continue; } if (NoiseGenerator.Noise(vec.X / veg.ClumpSize, veg.NoiseOffset, vec.Y / veg.ClumpSize) < veg.ClumpThreshold) { continue; } if (!vUnder.IsEmpty && vUnder.Type.Name == biome.SoilLayer.VoxelType) { vUnder.RawSetType(VoxelLibrary.GetVoxelType(biome.SoilLayer.VoxelType)); vUnder.RawSetGrass(0); float treeSize = MathFunctions.Rand() * veg.SizeVariance + veg.MeanSize; EntityFactory.DoLazy(() => { if (!GameSettings.Default.FogofWar) { GameComponent entity = EntityFactory.CreateEntity <GameComponent>(veg.Name, vUnder.WorldPosition + new Vector3(0.5f, 1.0f, 0.5f), Blackboard.Create("Scale", treeSize)); } else { world.ComponentManager.RootComponent.AddChild(new ExploredListener( world.ComponentManager, world.ChunkManager, vUnder) { EntityToSpawn = veg.Name, SpawnLocation = vUnder.WorldPosition + new Vector3(0.5f, 1.0f, 0.5f), BlackboardData = Blackboard.Create("Scale", treeSize) }); } }); } } foreach (FaunaData animal in biome.Fauna) { if (y <= 0 || !(MathFunctions.Random.NextDouble() < animal.SpawnProbability)) { continue; } FaunaData animal1 = animal; EntityFactory.DoLazy(() => { if (!GameSettings.Default.FogofWar) { var entity = EntityFactory.CreateEntity <GameComponent>(animal1.Name, wayUnder.WorldPosition + Vector3.Up * 1.5f); } else { world.ComponentManager.RootComponent.AddChild(new ExploredListener (world.ComponentManager, world.ChunkManager, new VoxelHandle(chunk, wayUnder.Coordinate.GetLocalVoxelCoordinate())) { EntityToSpawn = animal1.Name, SpawnLocation = wayUnder.WorldPosition + Vector3.Up * 1.5f }); } }); break; } }