public void CheckForLavaAndWater(DwarfTime gameTime, ChunkManager chunks) { BoundingBox expandedBoundingBox = LocParent.BoundingBox.Expand(0.5f); List <Voxel> voxels = chunks.GetVoxelsIntersecting(expandedBoundingBox); foreach (Voxel currentVoxel in voxels) { WaterCell cell = currentVoxel.Water; if (cell.WaterLevel == 0) { continue; } else if (cell.Type == LiquidType.Lava) { Heat += 100; } else if (cell.Type == LiquidType.Water) { Heat -= 100; Heat = Math.Max(0.0f, Heat); } } }
public static RoomTile[,] CreateFromRoom(Room room, ChunkManager chunks) { BoundingBox box0 = room.GetBoundingBox(); BoundingBox box = new BoundingBox(box0.Min + Vector3.Up, box0.Max + Vector3.Up); BoundingBox bigBox = new BoundingBox(box0.Min + Vector3.Up + new Vector3(-1, 0, -1), box0.Max + Vector3.Up + new Vector3(1, 0, 1)); int nr = Math.Max((int)(box.Max.X - box.Min.X), 1); int nc = Math.Max((int)(box.Max.Z - box.Min.Z), 1); RoomTile[,] toReturn = new RoomTile[nr + 2, nc + 2]; Dictionary <Point, Voxel> voxelDict = new Dictionary <Point, Voxel>(); List <Voxel> voxelsInRoom = chunks.GetVoxelsIntersecting(bigBox); foreach (Voxel vox in voxelsInRoom) { voxelDict[new Point((int)(vox.Position.X - box.Min.X) + 1, (int)(vox.Position.Z - box.Min.Z) + 1)] = vox; } for (int r = 0; r < nr + 2; r++) { for (int c = 0; c < nc + 2; c++) { toReturn[r, c] = RoomTile.Edge; } } foreach (KeyValuePair <Point, Voxel> voxPair in voxelDict) { Voxel vox = voxPair.Value; Point p = voxPair.Key; if (vox.IsEmpty && p.X > 0 && p.X < nr + 1 && p.Y > 0 && p.Y < nc + 1) { toReturn[p.X, p.Y] = RoomTile.Open; } else if (vox.TypeName != "empty") { toReturn[p.X, p.Y] = RoomTile.Wall; } } return(toReturn); }
public static RoomTile[,] CreateFromRoom(Room room, ChunkManager chunks) { BoundingBox box0 = room.GetBoundingBox(); BoundingBox box = new BoundingBox(box0.Min + Vector3.Up, box0.Max + Vector3.Up); BoundingBox bigBox = new BoundingBox(box0.Min + Vector3.Up + new Vector3(-1, 0, -1), box0.Max + Vector3.Up + new Vector3(1, 0, 1)); int nr = Math.Max((int) (box.Max.X - box.Min.X), 1); int nc = Math.Max((int) (box.Max.Z - box.Min.Z), 1); RoomTile[,] toReturn = new RoomTile[nr + 2, nc + 2]; Dictionary<Point, Voxel> voxelDict = new Dictionary<Point, Voxel>(); List<Voxel> voxelsInRoom = chunks.GetVoxelsIntersecting(bigBox); foreach(Voxel vox in voxelsInRoom) { voxelDict[new Point((int)(vox.Position.X - box.Min.X) + 1, (int)(vox.Position.Z - box.Min.Z) + 1)] = vox; } for(int r = 0; r < nr + 2; r++) { for(int c = 0; c < nc + 2; c++) { toReturn[r, c] = RoomTile.Edge; } } foreach(KeyValuePair<Point, Voxel> voxPair in voxelDict) { Voxel vox = voxPair.Value; Point p = voxPair.Key; if(vox.IsEmpty && p.X > 0 && p.X < nr + 1 && p.Y > 0 && p.Y < nc + 1) { toReturn[p.X, p.Y] = RoomTile.Open; } else if(vox.TypeName != "empty") { toReturn[p.X, p.Y] = RoomTile.Wall; } } return toReturn; }
public void CheckForLavaAndWater(DwarfTime gameTime, ChunkManager chunks) { BoundingBox expandedBoundingBox = LocParent.BoundingBox.Expand(0.5f); List<Voxel> voxels = chunks.GetVoxelsIntersecting(expandedBoundingBox); foreach(Voxel currentVoxel in voxels) { WaterCell cell = currentVoxel.Water; if (cell.WaterLevel == 0) continue; else if (cell.Type == LiquidType.Lava) { Heat += 100; } else if (cell.Type == LiquidType.Water) { Heat -= 100; Heat = Math.Max(0.0f, Heat); } } }