public void GenerateWater(VoxelChunk chunk) { int waterHeight = (int)(SeaLevel * VoxelConstants.ChunkSizeY) + 1; var iceID = VoxelLibrary.GetVoxelType("Ice"); for (var x = 0; x < VoxelConstants.ChunkSizeX; ++x) { for (var z = 0; z < VoxelConstants.ChunkSizeZ; ++z) { var biome = GetBiomeAt(new Vector2(x, z) + new Vector2(chunk.Origin.X, chunk.Origin.Z)); var topVoxel = VoxelHelpers.FindFirstVoxelBelow(new VoxelHandle( chunk, new LocalVoxelCoordinate(x, VoxelConstants.ChunkSizeY - 1, z))); for (var y = 0; y <= waterHeight; ++y) { var vox = new VoxelHandle(chunk, new LocalVoxelCoordinate(x, y, z)); if (vox.IsEmpty && y > topVoxel.Coordinate.Y) { if (biome.WaterSurfaceIce && y == waterHeight) { vox.RawSetType(iceID); } else { vox.WaterCell = new WaterCell { Type = LiquidType.Water, WaterLevel = WaterManager.maxWaterLevel }; } } } Vector2 vec = new Vector2(x + chunk.Origin.X, z + chunk.Origin.Z) / WorldScale; if (topVoxel.Coordinate.Y < VoxelConstants.ChunkSizeY - 1 && Overworld.GetWater(Overworld.Map, vec) == Overworld.WaterType.Volcano) { var localCoord = topVoxel.Coordinate.GetLocalVoxelCoordinate(); topVoxel = new VoxelHandle(topVoxel.Chunk, new LocalVoxelCoordinate( localCoord.X, localCoord.Y + 1, localCoord.Z)); if (topVoxel.IsEmpty) { topVoxel.WaterCell = new WaterCell { Type = LiquidType.Lava, WaterLevel = WaterManager.maxWaterLevel }; } } } } }
public void GenerateWater(VoxelChunk chunk) { int waterHeight = (int)(SeaLevel * chunk.SizeY); Voxel voxel = chunk.MakeVoxel(0, 0, 0); for (int x = 0; x < chunk.SizeX; x++) { for (int z = 0; z < chunk.SizeZ; z++) { int h; for (int y = 0; y < waterHeight; y++) { h = chunk.GetFilledVoxelGridHeightAt(x, chunk.SizeY - 1, z); int index = chunk.Data.IndexAt(x, y, z); voxel.GridPosition = new Vector3(x, y, z); if (voxel.IsEmpty && y >= h) { chunk.Data.Water[index].WaterLevel = 255; chunk.Data.Water[index].Type = LiquidType.Water; } } Vector2 vec = new Vector2(x + chunk.Origin.X, z + chunk.Origin.Z) / PlayState.WorldScale; if (Overworld.GetWater(Overworld.Map, vec) != Overworld.WaterType.Volcano) { continue; } h = chunk.GetFilledVoxelGridHeightAt(x, chunk.SizeY - 1, z); if (h <= 0) { continue; } chunk.Data.Water[chunk.Data.IndexAt(x, h, z)].WaterLevel = 255; chunk.Data.Water[chunk.Data.IndexAt(x, h, z)].Type = LiquidType.Lava; /* * for (int y = h - 1; y >= 0; y--) * { * voxel.Chunk = chunk; * voxel.GridPosition = new Vector3(x, y, z); * chunk.Data.Water[voxel.Index].Type = LiquidType.None; * chunk.Data.Water[voxel.Index].WaterLevel = 0; * voxel.Type = VoxelLibrary.GetVoxelType("Stone"); * voxel.Chunk.NotifyTotalRebuild(!voxel.IsInterior); * } */ } } }
public void GenerateWater(VoxelChunk chunk) { int waterHeight = (int)(SeaLevel * chunk.SizeY); Voxel voxel = chunk.MakeVoxel(0, 0, 0); for (int x = 0; x < chunk.SizeX; x++) { for (int z = 0; z < chunk.SizeZ; z++) { int h; for (int y = 0; y <= waterHeight; y++) { h = chunk.GetFilledVoxelGridHeightAt(x, chunk.SizeY - 1, z); int index = chunk.Data.IndexAt(x, y, z); voxel.GridPosition = new Vector3(x, y, z); if (voxel.IsEmpty && y >= h) { chunk.Data.Water[index].WaterLevel = 8; chunk.Data.Water[index].Type = LiquidType.Water; } } Vector2 vec = new Vector2(x + chunk.Origin.X, z + chunk.Origin.Z) / PlayState.WorldScale; if (Overworld.GetWater(Overworld.Map, vec) != Overworld.WaterType.Volcano) { continue; } h = chunk.GetFilledVoxelGridHeightAt(x, chunk.SizeY - 1, z); if (h <= 0) { continue; } chunk.Data.Water[chunk.Data.IndexAt(x, h, z)].WaterLevel = 8; chunk.Data.Water[chunk.Data.IndexAt(x, h, z)].Type = LiquidType.Lava; } } }