diff --git a/Subsurface/Content/Items/Diving/DivingSuit.png b/Subsurface/Content/Items/Diving/DivingSuit.png index 0bc10c521..25eff35ea 100644 Binary files a/Subsurface/Content/Items/Diving/DivingSuit.png and b/Subsurface/Content/Items/Diving/DivingSuit.png differ diff --git a/Subsurface/Content/Items/Diving/divinggear.xml b/Subsurface/Content/Items/Diving/divinggear.xml index 38f7b2f41..2b3e84607 100644 --- a/Subsurface/Content/Items/Diving/divinggear.xml +++ b/Subsurface/Content/Items/Diving/divinggear.xml @@ -68,14 +68,14 @@ fireproof="true" description="An atmospheric diving suit capable of withstanding the immense pressure under Europa's crust."> - + - + diff --git a/Subsurface/Source/Map/Levels/Level.cs b/Subsurface/Source/Map/Levels/Level.cs index 20683d075..5cd936d59 100644 --- a/Subsurface/Source/Map/Levels/Level.cs +++ b/Subsurface/Source/Map/Levels/Level.cs @@ -391,7 +391,7 @@ namespace Barotrauma { for (int y = 0; y < cellGrid.GetLength(1); y++) { - cellGrid[x, y] .Clear(); + cellGrid[x, y].Clear(); } } @@ -402,17 +402,10 @@ namespace Barotrauma if (x < 0 || y < 0 || x >= cellGrid.GetLength(0) || y >= cellGrid.GetLength(1)) continue; - cellGrid[x,y].Add(cell); + cellGrid[x, y].Add(cell); } - - - - - - - Vector2 ruinSize = new Vector2(Rand.Range(5000.0f, 8000.0f, false), Rand.Range(5000.0f, 8000.0f, false)); float ruinRadius = Math.Max(ruinSize.X, ruinSize.Y) * 0.5f; @@ -844,9 +837,9 @@ namespace Barotrauma List cells = new List(); - for (int x = startX; x < endX; x++) + for (int x = startX; x <= endX; x++) { - for (int y = startY; y < endY; y++) + for (int y = startY; y <= endY; y++) { foreach (VoronoiCell cell in cellGrid[x, y]) { diff --git a/Subsurface/Source/Map/Levels/Ruins/RuinGenerator.cs b/Subsurface/Source/Map/Levels/Ruins/RuinGenerator.cs index 7b5103efc..cf4c1e67f 100644 --- a/Subsurface/Source/Map/Levels/Ruins/RuinGenerator.cs +++ b/Subsurface/Source/Map/Levels/Ruins/RuinGenerator.cs @@ -256,37 +256,6 @@ namespace Barotrauma.RuinGeneration rooms.Remove(entranceRoom); - //var startCell = closestPathCell; - - //Rectangle startCellRect = new Rectangle( - // (int)startCell.edges.Min(e => Math.Min(e.point1.X, e.point2.X)), - // (int)startCell.edges.Min(e => Math.Min(e.point1.Y, e.point2.Y)), - // (int)startCell.edges.Max(e => Math.Max(e.point1.X, e.point2.X)), - // (int)startCell.edges.Max(e => Math.Max(e.point1.Y, e.point2.Y))); - - //startCellRect.Width = startCellRect.Width - startCellRect.X; - //startCellRect.Height = startCellRect.Height - startCellRect.Y; - - //int startX = Math.Min(entranceRoom.Rect.Center.X, startCellRect.Center.X); - //int endX = Math.Max(entranceRoom.Rect.Right, startCellRect.Right); - - //int startY = Math.Min(entranceRoom.Rect.Center.Y, startCellRect.Center.Y); - //int endY = Math.Max(entranceRoom.Rect.Bottom, startCellRect.Bottom); - - //if (entranceRoom.Rect.X > startCellRect.X && entranceRoom.Rect.Right < startCellRect.Right) - //{ - // corridors.Add(new Corridor(new Rectangle(entranceRoom.Rect.Center.X, startY, 128, endY - startY))); - //} - //else if (entranceRoom.Rect.Y > startCellRect.Y && entranceRoom.Rect.Bottom < startCellRect.Bottom) - //{ - // corridors.Add(new Corridor(new Rectangle(startX, entranceRoom.Rect.Center.Y, endX - startX, 128))); - //} - //else - //{ - // corridors.Add(new Corridor(new Rectangle(startX, entranceRoom.Rect.Center.Y, endX - startX, 128))); - // corridors.Add(new Corridor(new Rectangle(endX, startY, 128, endY - startY))); - //} - //--------------------------- foreach (BTRoom leaf in rooms) @@ -418,13 +387,32 @@ namespace Barotrauma.RuinGeneration foreach (Corridor corridor in corridors) { - var door = RuinStructure.GetRandom(corridor.IsHorizontal ? RuinStructureType.Door : RuinStructureType.Hatch, Alignment.Center); - if (door == null) continue; + var doorPrefab = RuinStructure.GetRandom(corridor.IsHorizontal ? RuinStructureType.Door : RuinStructureType.Hatch, Alignment.Center); + if (doorPrefab == null) continue; - var item = new Item(door.Prefab as ItemPrefab, corridor.Center - new Vector2(door.Prefab.sprite.size.X, -door.Prefab.sprite.size.Y)/2.0f, null); - item.MoveWithLevel = true; + //find all walls that are parallel to the corridor + var suitableWalls = corridor.IsHorizontal ? + corridor.Walls.FindAll(c => c.A.Y == c.B.Y) : corridor.Walls.FindAll(c => c.A.X == c.B.X); - item.GetComponent().IsOpen = Rand.Range(0.0f, 1.0f, false) < 0.8f; + if (!suitableWalls.Any()) continue; + + Vector2 doorPos = corridor.Center; + + //choose a random wall to place the door next to + var wall = suitableWalls[Rand.Int(suitableWalls.Count, false)]; + if (corridor.IsHorizontal) + { + doorPos.X = (wall.A.X + wall.B.X) / 2.0f; + } + else + { + doorPos.Y = (wall.A.Y + wall.B.Y) / 2.0f; + } + + var door = new Item(doorPrefab.Prefab as ItemPrefab, doorPos - new Vector2(doorPrefab.Prefab.sprite.size.X, -doorPrefab.Prefab.sprite.size.Y)/2.0f, null); + door.MoveWithLevel = true; + + door.GetComponent().IsOpen = Rand.Range(0.0f, 1.0f, false) < 0.8f; if (sensorPrefab == null || wirePrefab == null) continue; @@ -439,7 +427,7 @@ namespace Barotrauma.RuinGeneration var wire = new Item(wirePrefab, sensorRoom.Center, null).GetComponent(); wire.Item.MoveWithLevel = false; - var conn1 = item.Connections.Find(c => c.Name == "set_state"); + var conn1 = door.Connections.Find(c => c.Name == "set_state"); conn1.AddLink(0, wire); wire.Connect(conn1, false); diff --git a/Subsurface/Source/Map/Lights/LightManager.cs b/Subsurface/Source/Map/Lights/LightManager.cs index e47e52ac2..77d1ef731 100644 --- a/Subsurface/Source/Map/Lights/LightManager.cs +++ b/Subsurface/Source/Map/Lights/LightManager.cs @@ -71,7 +71,7 @@ namespace Barotrauma.Lights public void DrawLOS(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam, Effect effect) { - //if (!LosEnabled || ViewTarget==null) return; + if (!LosEnabled || ViewTarget==null) return; //Vector2 pos = ViewTarget.WorldPosition; diff --git a/Subsurface/Source/Screens/GameScreen.cs b/Subsurface/Source/Screens/GameScreen.cs index afa829ef8..7b535ff04 100644 --- a/Subsurface/Source/Screens/GameScreen.cs +++ b/Subsurface/Source/Screens/GameScreen.cs @@ -316,7 +316,10 @@ namespace Barotrauma GameMain.LightManager.DrawLightMap(spriteBatch, cam, blurEffect); - GameMain.LightManager.DrawLOS(graphics, spriteBatch, cam, blurEffect); + if (Character.Controlled != null) + { + GameMain.LightManager.DrawLOS(graphics, spriteBatch, cam, blurEffect); + } }