From dc4b50224873113344dedc11f361e7cd5ebb5601 Mon Sep 17 00:00:00 2001 From: Regalis Date: Thu, 29 Oct 2015 00:59:00 +0200 Subject: [PATCH] "Infinite walls", converting old InputTypes in saved subs to new ones --- Subsurface/Barotrauma.csproj | 1 + Subsurface/Source/Characters/CharacterInfo.cs | 2 +- Subsurface/Source/Characters/Jobs/Job.cs | 2 +- Subsurface/Source/GameMain.cs | 2 +- .../Source/Items/Components/ItemComponent.cs | 8 +- .../Items/Components/Power/PowerTransfer.cs | 2 +- Subsurface/Source/Map/Levels/Level.cs | 150 ++++++++---------- .../Source/Map/Levels/VoronoiElements.cs | 31 ++++ Subsurface/Source/Map/Levels/WrappingWall.cs | 147 +++++++++++++++++ Subsurface/Source/Map/Map.cs | 2 +- Subsurface/Source/Networking/GameServer.cs | 2 +- Subsurface/Source/Screens/GameScreen.cs | 2 +- Subsurface/Source/Screens/NetLobbyScreen.cs | 4 +- Subsurface/Source/Screens/NetLobbySettings.cs | 3 + Subsurface/Source/Utils/ToolBox.cs | 10 ++ Subsurface_Solution.v12.suo | Bin 779776 -> 759296 bytes 16 files changed, 277 insertions(+), 91 deletions(-) create mode 100644 Subsurface/Source/Map/Levels/WrappingWall.cs diff --git a/Subsurface/Barotrauma.csproj b/Subsurface/Barotrauma.csproj index 3fadc6abb..48b0a5c18 100644 --- a/Subsurface/Barotrauma.csproj +++ b/Subsurface/Barotrauma.csproj @@ -95,6 +95,7 @@ + diff --git a/Subsurface/Source/Characters/CharacterInfo.cs b/Subsurface/Source/Characters/CharacterInfo.cs index affe2a016..edbd7df7e 100644 --- a/Subsurface/Source/Characters/CharacterInfo.cs +++ b/Subsurface/Source/Characters/CharacterInfo.cs @@ -232,7 +232,7 @@ namespace Barotrauma File = ToolBox.GetAttributeString(element, "file", ""); Salary = ToolBox.GetAttributeInt(element, "salary", 1000); - HeadSpriteId = ToolBox.GetAttributeInt(element, "headspriteid", 1); + headSpriteId = ToolBox.GetAttributeInt(element, "headspriteid", 1); StartItemsGiven = ToolBox.GetAttributeBool(element, "startitemsgiven", false); pickedItems = new List(); diff --git a/Subsurface/Source/Characters/Jobs/Job.cs b/Subsurface/Source/Characters/Jobs/Job.cs index 14b238896..24aad1fd9 100644 --- a/Subsurface/Source/Characters/Jobs/Job.cs +++ b/Subsurface/Source/Characters/Jobs/Job.cs @@ -79,7 +79,7 @@ namespace Barotrauma public static Job Random() { - JobPrefab prefab = JobPrefab.List[Rand.Int(JobPrefab.List.Count-1, false)]; + JobPrefab prefab = JobPrefab.List[Rand.Int(JobPrefab.List.Count - 1, false)]; return new Job(prefab); } diff --git a/Subsurface/Source/GameMain.cs b/Subsurface/Source/GameMain.cs index 73f08e5f7..165acfe56 100644 --- a/Subsurface/Source/GameMain.cs +++ b/Subsurface/Source/GameMain.cs @@ -39,7 +39,7 @@ namespace Barotrauma public static EditCharacterScreen EditCharacterScreen; public static Lights.LightManager LightManager; - + public static ContentPackage SelectedPackage { get { return Config.SelectedContentPackage; } diff --git a/Subsurface/Source/Items/Components/ItemComponent.cs b/Subsurface/Source/Items/Components/ItemComponent.cs index 3a7cb8744..618cee02b 100644 --- a/Subsurface/Source/Items/Components/ItemComponent.cs +++ b/Subsurface/Source/Items/Components/ItemComponent.cs @@ -182,7 +182,9 @@ namespace Barotrauma.Items.Components try { - SelectKey = (InputType)Enum.Parse(typeof(InputType), ToolBox.GetAttributeString(element, "selectkey", "Select"), true); + string selectKeyStr = ToolBox.GetAttributeString(element, "selectkey", "Select"); + selectKeyStr = ToolBox.ConvertInputType(selectKeyStr); + SelectKey = (InputType)Enum.Parse(typeof(InputType), selectKeyStr, true); } catch (Exception e) { @@ -193,7 +195,9 @@ namespace Barotrauma.Items.Components try { - PickKey = (InputType)Enum.Parse(typeof(InputType), ToolBox.GetAttributeString(element, "selectkey", "Select"), true); + string pickKeyStr = ToolBox.GetAttributeString(element, "selectkey", "Select"); + pickKeyStr = ToolBox.ConvertInputType(pickKeyStr); + PickKey = (InputType)Enum.Parse(typeof(InputType),pickKeyStr, true); } catch (Exception e) { diff --git a/Subsurface/Source/Items/Components/Power/PowerTransfer.cs b/Subsurface/Source/Items/Components/Power/PowerTransfer.cs index 9c3ac914b..22fdcfc64 100644 --- a/Subsurface/Source/Items/Components/Power/PowerTransfer.cs +++ b/Subsurface/Source/Items/Components/Power/PowerTransfer.cs @@ -68,7 +68,7 @@ namespace Barotrauma.Items.Components var particle = GameMain.ParticleManager.CreateParticle("spark", pt.item.Position, baseVel + Rand.Vector(100.0f), 0.0f); - if (particle != null) particle.Size *= Rand.Range(0.5f,1.0f); + if (particle != null) particle.Size *= Rand.Range(0.5f, 1.0f); } } } diff --git a/Subsurface/Source/Map/Levels/Level.cs b/Subsurface/Source/Map/Levels/Level.cs index 0c01bc390..7e8eaeab6 100644 --- a/Subsurface/Source/Map/Levels/Level.cs +++ b/Subsurface/Source/Map/Levels/Level.cs @@ -33,6 +33,8 @@ namespace Barotrauma public const int GridCellWidth = 2000; private List[,] cellGrid; + private WrappingWall[,] wrappingWalls; + private float shaftHeight; //List bodies; @@ -41,7 +43,7 @@ namespace Barotrauma private static BasicEffect basicEffect; private VertexPositionTexture[] vertices; - private VertexBuffer vertexBuffer; + //private VertexBuffer vertexBuffer; private Vector2 startPosition; private Vector2 endPosition; @@ -156,16 +158,14 @@ namespace Barotrauma bodies = new List(); - Random rand = new Random(ToolBox.StringToInt(seed)); + Rand.SetSyncedSeed(ToolBox.StringToInt(seed)); - float siteVariance = siteInterval * 0.8f; + float siteVariance = siteInterval * 0.4f; for (int x = siteInterval / 2; x < borders.Width; x += siteInterval) { for (int y = siteInterval / 2; y < borders.Height; y += siteInterval) { - Vector2 site = new Vector2( - x + (float)(rand.NextDouble() - 0.5) * siteVariance, - y + (float)(rand.NextDouble() - 0.5) * siteVariance); + Vector2 site = new Vector2(x, y) + Rand.Vector(siteVariance, false); if (mirror) site.X = borders.Width - site.X; @@ -232,8 +232,8 @@ namespace Barotrauma List pathNodes = new List(); - startPosition = new Vector2((int)minWidth * 2, rand.Next((int)minWidth * 2, borders.Height - (int)minWidth * 2)); - endPosition = new Vector2(borders.Width - (int)minWidth * 2, rand.Next((int)minWidth * 2, borders.Height - (int)minWidth * 2)); + startPosition = new Vector2((int)minWidth * 2, Rand.Range((int)minWidth * 2, borders.Height - (int)minWidth * 2, false)); + endPosition = new Vector2(borders.Width - (int)minWidth * 2, Rand.Range((int)minWidth * 2, borders.Height - (int)minWidth * 2, false)); pathNodes.Add(new Vector2(startPosition.X, borders.Height)); pathNodes.Add(startPosition); @@ -245,13 +245,12 @@ namespace Barotrauma pathNodes.Reverse(); } - List pathCells = GeneratePath(rand, - pathNodes, cells, pathBorders, minWidth, 0.3f, mirror, true); + List pathCells = GeneratePath(pathNodes, cells, pathBorders, minWidth, 0.3f, mirror, true); //place some enemy spawnpoints at random points in the path for (int i = 0; i <3 ; i++ ) { - Vector2 position = pathCells[rand.Next((int)(pathCells.Count * 0.5f), pathCells.Count - 2)].Center; + Vector2 position = pathCells[Rand.Range((int)(pathCells.Count * 0.5f), pathCells.Count - 2, false)].Center; WayPoint wayPoint = new WayPoint(new Rectangle((int)position.X, (int)position.Y, 10, 10)); wayPoint.MoveWithLevel = true; wayPoint.SpawnType = SpawnType.Enemy; @@ -261,22 +260,22 @@ namespace Barotrauma endPosition = pathCells[pathCells.Count - 1].Center; //generate a couple of random paths - for (int i = 0; i <= rand.Next() % 3; i++) + for (int i = 0; i <= Rand.Range(1,4,false); i++) { //pathBorders = new Rectangle( //borders.X + siteInterval * 2, borders.Y - siteInterval * 2, //borders.Right - siteInterval * 2, borders.Y + borders.Height - siteInterval * 2); - Vector2 start = pathCells[rand.Next(1, pathCells.Count - 2)].Center; + Vector2 start = pathCells[Rand.Range(1, pathCells.Count - 2,false)].Center; - float x = pathBorders.X + (float)rand.NextDouble() * (pathBorders.Right - pathBorders.X); - float y = pathBorders.Y + (float)rand.NextDouble() * (pathBorders.Bottom - pathBorders.Y); + float x = pathBorders.X + Rand.Range(0, pathBorders.Right - pathBorders.X, false); + float y = pathBorders.Y + Rand.Range(0,pathBorders.Bottom - pathBorders.Y, false); if (mirror) x = borders.Width - x; Vector2 end = new Vector2(x, y); - var newPathCells = GeneratePath(rand, new List { start, end }, cells, pathBorders, 0.0f, 0.8f, mirror); + var newPathCells = GeneratePath(new List { start, end }, cells, pathBorders, 0.0f, 0.8f, mirror); for (int n = 0; n < newPathCells.Count-5; n += 3) { @@ -321,26 +320,29 @@ namespace Barotrauma startPosition.Y = borders.Height; endPosition.Y = borders.Height; - //for (int i = 0; i < 2; i++) - //{ - // Vector2 tunnelStart = (i == 0) ? startPosition : endPosition; - // for (int n = -1; n < 2; n += 2) - // { - // int cellIndex = FindCellIndex(new Vector2(tunnelStart.X + minWidth * 0.5f * n, tunnelStart.Y), 3); + vertices = GeneratePolygons(cells, pathCells); + + wrappingWalls = new WrappingWall[2, 2]; - // foreach (GraphEdge ge in cells[cellIndex].edges) - // { - // if (ge.point1.Y > cells[cellIndex].Center.Y) ge.point1.Y = borders.Height + shaftHeight; - // if (ge.point2.Y > cells[cellIndex].Center.Y) ge.point2.Y = borders.Height + shaftHeight; - // } - // } - //} + for (int side = 0; side < 2; side++) + { + for (int i = 0; i < 2; i++) + { + wrappingWalls[side, i] = new WrappingWall(pathCells, cells, borders.Height * 0.7f, + (side == 0 ? -1 : 1) * (i == 0 ? 1 : 2)); - //startPosition.Y += shaftHeight; - //endPosition.Y += shaftHeight; + wrappingWalls[side, i].Vertices = GeneratePolygons(wrappingWalls[side, i].Cells, new List()); + } - GeneratePolygons(cells, pathCells); + } + for (int side = 0; side < 2; side++) + { + for (int i = 0; i < 2; i++) + { + cells.AddRange(wrappingWalls[side, i].Cells); + } + } foreach (VoronoiCell cell in cells) { @@ -357,8 +359,8 @@ namespace Barotrauma Debug.WriteLine("Generatelevel: " + sw2.ElapsedMilliseconds + " ms"); sw2.Restart(); - vertexBuffer = new VertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly); - vertexBuffer.SetData(vertices); + //vertexBuffer = new VertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly); + //vertexBuffer.SetData(vertices); if (mirror) { @@ -370,7 +372,7 @@ namespace Barotrauma Debug.WriteLine("Generated a map with " + sites.Count + " sites in " + sw.ElapsedMilliseconds + " ms"); } - private List GeneratePath(Random rand, List points, List cells, Microsoft.Xna.Framework.Rectangle limits, float minWidth, float wanderAmount = 0.3f, bool mirror=false, bool placeWaypoints=false) + private List GeneratePath(List points, List cells, Microsoft.Xna.Framework.Rectangle limits, float minWidth, float wanderAmount = 0.3f, bool mirror=false, bool placeWaypoints=false) { Stopwatch sw2 = new Stopwatch(); sw2.Start(); @@ -390,15 +392,14 @@ namespace Barotrauma VoronoiCell currentCell = targetCells[0]; pathCells.Add(currentCell); -int currentTargetIndex = 1; - + int currentTargetIndex = 1; do { int edgeIndex = 0; //steer towards target - if (rand.NextDouble() > wanderAmount) + if (Rand.Range(0.0f, 1.0f, false) > wanderAmount) { for (int i = 0; i < currentCell.edges.Count; i++) { @@ -420,11 +421,11 @@ int currentTargetIndex = 1; } if (allowedEdges.Count==0) { - edgeIndex = rand.Next() % currentCell.edges.Count; + edgeIndex = Rand.Int(currentCell.edges.Count, false); } else { - edgeIndex = rand.Next() % allowedEdges.Count; + edgeIndex = Rand.Int(allowedEdges.Count, false); if (mirror && edgeIndex > 0) edgeIndex = allowedEdges.Count - edgeIndex; edgeIndex = currentCell.edges.IndexOf(allowedEdges[edgeIndex]); } @@ -534,6 +535,7 @@ int currentTargetIndex = 1; return tooCloseCells; } + /// /// remove all cells except those that are adjacent to the empty cells /// @@ -579,13 +581,12 @@ int currentTargetIndex = 1; } } } - - - + return cells.IndexOf(closestCell); } - private void GeneratePolygons(List cells, List emptyCells) + + private VertexPositionTexture[] GeneratePolygons(List cells, List emptyCells) { List verticeList = new List(); //bodies = new List(); @@ -606,7 +607,7 @@ int currentTargetIndex = 1; if (!tempVertices.Contains(ge.point2)) tempVertices.Add(ge.point2); VoronoiCell adjacentCell = ge.AdjacentCell(cell); - if (!emptyCells.Contains(adjacentCell)) continue; + if (adjacentCell!=null && !emptyCells.Contains(adjacentCell)) continue; ge.isSolid = true; @@ -680,7 +681,7 @@ int currentTargetIndex = 1; bodies.Add(shaftBody); } - vertices = verticeList.ToArray(); + return verticeList.ToArray(); } public void SetPosition(Vector2 pos) @@ -715,6 +716,8 @@ int currentTargetIndex = 1; item.SetTransform(item.SimPosition+amount, item.body.Rotation); } } + + //WrappingWall.UpdateWallShift(Position, wrappingWalls); } Vector2 prevVelocity; @@ -748,6 +751,8 @@ int currentTargetIndex = 1; AtEndPosition = Vector2.Distance(endPosition, -Position) < ExitDistance; prevVelocity = simVelocity; + + WrappingWall.UpdateWallShift(-Position, wrappingWalls); } public static void AfterWorldStep() @@ -802,38 +807,7 @@ int currentTargetIndex = 1; System.Diagnostics.Debug.WriteLine("pos: " + Position); } - - Vector2 observerPosition; - public void SetObserverPosition(Vector2 position) - { - //observerPosition = position - this.Position; - //int gridPosX = (int)Math.Floor(observerPosition.X / GridCellWidth); - //int gridPosY = (int)Math.Floor(observerPosition.Y / GridCellWidth); - //int searchOffset = 2; - - //int startX = Math.Max(gridPosX - searchOffset, 0); - //int endX = Math.Min(gridPosX + searchOffset, cellGrid.GetLength(0) - 1); - - //int startY = Math.Max(gridPosY - searchOffset, 0); - //int endY = Math.Min(gridPosY + searchOffset, cellGrid.GetLength(1) - 1); - - //for (int x = 0; x < cellGrid.GetLength(0); x++) - //{ - // for (int y = 0; y < cellGrid.GetLength(1); y++) - // { - // for (int i = 0; i < cellGrid[x, y].Count; i++) - // { - // //foreach (Body b in cellGrid[x, y][i].bodies) - // //{ - // if (cellGrid[x, y][i].body == null) continue; - // cellGrid[x, y][i].body.Enabled = true;// (x >= startX && x <= endX && y >= startY && y <= endY); - // //} - // } - // } - //} - } - - + public void Draw(SpriteBatch spriteBatch) { Vector2 pos = endPosition; @@ -937,6 +911,22 @@ int currentTargetIndex = 1; graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap; graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, (int)Math.Floor(vertices.Length / 3.0f)); + + + for (int side = 0; side < 2; side++) + { + for (int i = 0; i < 2; i++) + { + basicEffect.World = Matrix.CreateTranslation(new Vector3(Position + wrappingWalls[side, i].Offset, 0.0f)) * cam.ShaderTransform + * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f; + + basicEffect.CurrentTechnique.Passes[0].Apply(); + + graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, + wrappingWalls[side, i].Vertices, 0, (int)Math.Floor(wrappingWalls[side, i].Vertices.Length / 3.0f)); + + } + } } private void Unload() @@ -961,8 +951,8 @@ int currentTargetIndex = 1; bodies.Clear(); bodies = null; - vertexBuffer.Dispose(); - vertexBuffer = null; + //vertexBuffer.Dispose(); + //vertexBuffer = null; } } diff --git a/Subsurface/Source/Map/Levels/VoronoiElements.cs b/Subsurface/Source/Map/Levels/VoronoiElements.cs index 5b96a33fe..af7980910 100644 --- a/Subsurface/Source/Map/Levels/VoronoiElements.cs +++ b/Subsurface/Source/Map/Levels/VoronoiElements.cs @@ -78,6 +78,11 @@ namespace Voronoi2 { public Point coord; public int sitenbr; + + public void SetPoint(Vector2 point) + { + coord.setPoint(point.X, point.Y); + } public Site () { @@ -130,6 +135,32 @@ namespace Voronoi2 get { return new Vector2((float)site.coord.x, (float)site.coord.y); } } + public VoronoiCell(Vector2[] vertices) + { + edges = new List(); + bodyVertices = new List(); + + Vector2 midPoint = Vector2.Zero; + foreach (Vector2 vertex in vertices) + { + midPoint += vertex; + } + midPoint /= vertices.Length; + + + for (int i = 1; i < vertices.Length; i++ ) + { + GraphEdge ge = new GraphEdge(); + ge.point1 = vertices[i-1]; + ge.point2 = vertices[i]; + + edges.Add(ge); + } + + site = new Site(); + site.SetPoint(midPoint); + } + public VoronoiCell(Site site) { edges = new List(); diff --git a/Subsurface/Source/Map/Levels/WrappingWall.cs b/Subsurface/Source/Map/Levels/WrappingWall.cs new file mode 100644 index 000000000..d7050abc5 --- /dev/null +++ b/Subsurface/Source/Map/Levels/WrappingWall.cs @@ -0,0 +1,147 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using Voronoi2; + +namespace Barotrauma +{ + class WrappingWall + { + + const float wallWidth = 10000.0f; + + public VertexPositionTexture[] Vertices; + + private Vector2 midPos; + private int slot; + + private Vector2 offset; + + private List cells; + + public Vector2 Offset + { + get { return offset; } + } + + public List Cells + { + get { return cells; } + } + + public WrappingWall(List pathCells, List mapCells, float maxY, int dir = -1) + { + cells = new List(); + + VoronoiCell lowestPathCell = null; + foreach (VoronoiCell pathCell in pathCells) + { + if (lowestPathCell == null || pathCell.Center.Y < lowestPathCell.Center.Y) + { + lowestPathCell = pathCell; + } + } + + float bottomY = Math.Max(lowestPathCell.Center.Y, maxY); + + VoronoiCell edgeCell = null; + foreach (VoronoiCell cell in mapCells) + { + if (cell.Center.Y > bottomY) continue; + if (edgeCell == null + || (dir < 0 && cell.Center.X < edgeCell.Center.X) + || (dir > 0 && cell.Center.X > edgeCell.Center.X)) + { + edgeCell = cell; + } + } + + Vector2 wallSectionSize = new Vector2(2000.0f, 2000.0f); + Vector2 startPos = (dir < 0) ? + edgeCell.Center + Vector2.UnitX * wallWidth * dir : + edgeCell.Center + wallWidth * Vector2.UnitX * (dir - 1); + + midPos = startPos + Vector2.UnitX * wallWidth/2; + + List bottomVertices = new List(); + + for (float x = 0; x <= wallWidth; x += wallSectionSize.X) + { + Vector2 center = new Vector2(startPos.X + x, edgeCell.Center.Y); + float distFromCenter = Math.Abs(x - wallWidth / 2); + float distFromEdge = wallWidth / 2 - distFromCenter; + float normalizedDist = distFromEdge / (wallWidth / 2); + + float variance = 1000.0f * normalizedDist; + bottomVertices.Add(center + new Vector2(Rand.Range(-variance, variance, false), Rand.Range(-variance, variance, false)*5.0f)); + } + + for (int i = 1; i < bottomVertices.Count; i++) + { + Vector2[] vertices = new Vector2[4]; + vertices[0] = bottomVertices[i]; + vertices[1] = bottomVertices[i - 1]; + vertices[2] = vertices[1] + Vector2.UnitY * wallSectionSize.Y; + vertices[3] = vertices[0] + Vector2.UnitY * wallSectionSize.Y; + + VoronoiCell wallCell = new VoronoiCell(vertices); + cells.Add(wallCell); + } + + //for (float x = 0; x<=wallWidth; x+=wallSectionSize.X) + //{ + // Vector2 center = new Vector2(startPos.X+x, edgeCell.Center.Y); + + // Vector2[] vertices = new Vector2[4]; + // vertices[0] = center - wallSectionSize / 2; + // vertices[2] = center + wallSectionSize / 2; + // vertices[1] = new Vector2(vertices[2].X, vertices[0].Y); + // vertices[3] = new Vector2(vertices[0].X, vertices[2].Y); + + // VoronoiCell wallCell = new VoronoiCell(vertices); + // wallCells.Add(wallCell); + //} + + } + + + public static void UpdateWallShift(Vector2 pos, WrappingWall[,] walls) + { + if (pos.X < walls[0, 1].midPos.X && walls[0,0].midPos.X > pos.X) + { + walls[0, 0].Shift(-2); + + var temp = walls[0, 0]; + walls[0, 0] = walls[0, 1]; + walls[0, 1] = temp; + } + else if (pos.X > walls[0, 0].midPos.X && walls[0,1].midPos.X < pos.X && walls[0,1].slot<0) + { + walls[0, 1].Shift(2); + + var temp = walls[0, 0]; + walls[0, 0] = walls[0, 1]; + walls[0, 1] = temp; + } + } + + public void Shift(int amount) + { + slot += amount; + + Vector2 moveAmount = Vector2.UnitX * wallWidth * amount; + foreach (VoronoiCell cell in cells) + { + cell.body.SetTransform(cell.body.Position + moveAmount, 0.0f); + } + + midPos += moveAmount; + offset += moveAmount; + + } + } +} diff --git a/Subsurface/Source/Map/Map.cs b/Subsurface/Source/Map/Map.cs index f23ab45c2..1871beac9 100644 --- a/Subsurface/Source/Map/Map.cs +++ b/Subsurface/Source/Map/Map.cs @@ -118,7 +118,7 @@ namespace Barotrauma Vector2[] points = new Vector2[] { edge.point1, edge.point2 }; - int positionIndex = Rand.Int(1,false); + int positionIndex = Rand.Int(1, false); Vector2 position = points[positionIndex]; if (newLocations[1 - i] != null && newLocations[1 - i].MapPosition == position) position = points[1 - positionIndex]; diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs index a93011746..4f5918815 100644 --- a/Subsurface/Source/Networking/GameServer.cs +++ b/Subsurface/Source/Networking/GameServer.cs @@ -223,8 +223,8 @@ namespace Barotrauma.Networking connectedClients.Find(c => c.character != null && !c.character.IsDead)==null && (myCharacter == null || myCharacter.IsDead)) { - EndButtonHit(null, null); AutoRestartTimer = 20.0f; + EndButtonHit(null, null); UpdateNetLobby(null,null); return; } diff --git a/Subsurface/Source/Screens/GameScreen.cs b/Subsurface/Source/Screens/GameScreen.cs index 102f35380..fb6c3acf0 100644 --- a/Subsurface/Source/Screens/GameScreen.cs +++ b/Subsurface/Source/Screens/GameScreen.cs @@ -292,7 +292,7 @@ namespace Barotrauma if (GameMain.GameSession != null && GameMain.GameSession.Level != null) { GameMain.GameSession.Level.Render(graphics, cam); - GameMain.GameSession.Level.SetObserverPosition(cam.WorldViewCenter); + //GameMain.GameSession.Level.SetObserverPosition(cam.WorldViewCenter); } //---------------------------------------------------------------------------------------- diff --git a/Subsurface/Source/Screens/NetLobbyScreen.cs b/Subsurface/Source/Screens/NetLobbyScreen.cs index aa7ac5d7a..c20f4216b 100644 --- a/Subsurface/Source/Screens/NetLobbyScreen.cs +++ b/Subsurface/Source/Screens/NetLobbyScreen.cs @@ -339,10 +339,10 @@ namespace Barotrauma playerName.Text = characterInfo.Name; playerName.OnEnterPressed += ChangeCharacterName; - GUIButton toggleHead = new GUIButton(new Rectangle(00, 50, 20, 20), "<", GUI.Style, myPlayerFrame); + GUIButton toggleHead = new GUIButton(new Rectangle(0, 50, 20, 20), "<", GUI.Style, myPlayerFrame); toggleHead.UserData = -1; toggleHead.OnClicked = ToggleHead; - toggleHead = new GUIButton(new Rectangle(40, 50, 20, 20), ">", GUI.Style, myPlayerFrame); + toggleHead = new GUIButton(new Rectangle(60, 50, 20, 20), ">", GUI.Style, myPlayerFrame); toggleHead.UserData = 1; toggleHead.OnClicked = ToggleHead; diff --git a/Subsurface/Source/Screens/NetLobbySettings.cs b/Subsurface/Source/Screens/NetLobbySettings.cs index 85b954910..91b21bff6 100644 --- a/Subsurface/Source/Screens/NetLobbySettings.cs +++ b/Subsurface/Source/Screens/NetLobbySettings.cs @@ -93,6 +93,9 @@ namespace Barotrauma.Networking selectionTick.OnSelected = SwitchModeSelection; selectionTick.UserData = (SelectionMode)i; } + + var closeButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Close", Alignment.BottomRight, GUI.Style, innerFrame); + closeButton.OnClicked = ToggleSettingsFrame; } private bool SwitchSubSelection(GUITickBox tickBox) diff --git a/Subsurface/Source/Utils/ToolBox.cs b/Subsurface/Source/Utils/ToolBox.cs index fffb718f4..ea76459eb 100644 --- a/Subsurface/Source/Utils/ToolBox.cs +++ b/Subsurface/Source/Utils/ToolBox.cs @@ -312,6 +312,16 @@ namespace Barotrauma return BitConverter.ToInt32(asciiBytes, 0); } + /// + /// a method for changing inputtypes with old names to the new ones to ensure backwards compatibility with older subs + /// + public static string ConvertInputType(string inputType) + { + if (inputType == "ActionHit" || inputType == "Action") return "Use"; + if (inputType == "SecondarHit" || inputType == "Secondary") return "Aim"; + + return inputType; + } public static string WrapText(string text, float lineLength, SpriteFont font) { diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index 5dd7e7f11fe3dcb46a7f41ee92b1afd0602ce7d0..90718df328817d612e3d26a759198da25cfd1401 100644 GIT binary patch delta 5101 zcmc(i33QZImdES9_f=}iRtecjNKq7(@FZepz6B}}F$Fj(;1W1_>Z%Gp#UW|~j$ zt&QBS&lO9ly6zj1OwQYQtngD(JsD`=JIGFue`5#vcNBZj`BpvKj@E`7lpnEtq&~m;Ff;byvXd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