"Infinite walls", converting old InputTypes in saved subs to new ones

This commit is contained in:
Regalis
2015-10-29 00:59:00 +02:00
parent 948285f6ab
commit dc4b502248
16 changed files with 277 additions and 91 deletions
+1
View File
@@ -95,6 +95,7 @@
<Compile Include="Source\Items\Components\Signal\SignalCheckComponent.cs" /> <Compile Include="Source\Items\Components\Signal\SignalCheckComponent.cs" />
<Compile Include="Source\Items\Components\ItemLabel.cs" /> <Compile Include="Source\Items\Components\ItemLabel.cs" />
<Compile Include="Source\Items\FixRequirement.cs" /> <Compile Include="Source\Items\FixRequirement.cs" />
<Compile Include="Source\Map\Levels\WrappingWall.cs" />
<Compile Include="Source\Map\Lights\LightSource.cs" /> <Compile Include="Source\Map\Lights\LightSource.cs" />
<Compile Include="Source\Map\LocationType.cs" /> <Compile Include="Source\Map\LocationType.cs" />
<Compile Include="Source\Map\SubmarineHull.cs" /> <Compile Include="Source\Map\SubmarineHull.cs" />
@@ -232,7 +232,7 @@ namespace Barotrauma
File = ToolBox.GetAttributeString(element, "file", ""); File = ToolBox.GetAttributeString(element, "file", "");
Salary = ToolBox.GetAttributeInt(element, "salary", 1000); Salary = ToolBox.GetAttributeInt(element, "salary", 1000);
HeadSpriteId = ToolBox.GetAttributeInt(element, "headspriteid", 1); headSpriteId = ToolBox.GetAttributeInt(element, "headspriteid", 1);
StartItemsGiven = ToolBox.GetAttributeBool(element, "startitemsgiven", false); StartItemsGiven = ToolBox.GetAttributeBool(element, "startitemsgiven", false);
pickedItems = new List<ushort>(); pickedItems = new List<ushort>();
+1 -1
View File
@@ -79,7 +79,7 @@ namespace Barotrauma
public static Job Random() 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); return new Job(prefab);
} }
@@ -182,7 +182,9 @@ namespace Barotrauma.Items.Components
try 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) catch (Exception e)
{ {
@@ -193,7 +195,9 @@ namespace Barotrauma.Items.Components
try 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) catch (Exception e)
{ {
@@ -68,7 +68,7 @@ namespace Barotrauma.Items.Components
var particle = GameMain.ParticleManager.CreateParticle("spark", pt.item.Position, var particle = GameMain.ParticleManager.CreateParticle("spark", pt.item.Position,
baseVel + Rand.Vector(100.0f), 0.0f); 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);
} }
} }
} }
+68 -78
View File
@@ -33,6 +33,8 @@ namespace Barotrauma
public const int GridCellWidth = 2000; public const int GridCellWidth = 2000;
private List<VoronoiCell>[,] cellGrid; private List<VoronoiCell>[,] cellGrid;
private WrappingWall[,] wrappingWalls;
private float shaftHeight; private float shaftHeight;
//List<Body> bodies; //List<Body> bodies;
@@ -41,7 +43,7 @@ namespace Barotrauma
private static BasicEffect basicEffect; private static BasicEffect basicEffect;
private VertexPositionTexture[] vertices; private VertexPositionTexture[] vertices;
private VertexBuffer vertexBuffer; //private VertexBuffer vertexBuffer;
private Vector2 startPosition; private Vector2 startPosition;
private Vector2 endPosition; private Vector2 endPosition;
@@ -156,16 +158,14 @@ namespace Barotrauma
bodies = new List<Body>(); bodies = new List<Body>();
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 x = siteInterval / 2; x < borders.Width; x += siteInterval)
{ {
for (int y = siteInterval / 2; y < borders.Height; y += siteInterval) for (int y = siteInterval / 2; y < borders.Height; y += siteInterval)
{ {
Vector2 site = new Vector2( Vector2 site = new Vector2(x, y) + Rand.Vector(siteVariance, false);
x + (float)(rand.NextDouble() - 0.5) * siteVariance,
y + (float)(rand.NextDouble() - 0.5) * siteVariance);
if (mirror) site.X = borders.Width - site.X; if (mirror) site.X = borders.Width - site.X;
@@ -232,8 +232,8 @@ namespace Barotrauma
List<Vector2> pathNodes = new List<Vector2>(); List<Vector2> pathNodes = new List<Vector2>();
startPosition = new Vector2((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.Next((int)minWidth * 2, borders.Height - (int)minWidth * 2)); 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(new Vector2(startPosition.X, borders.Height));
pathNodes.Add(startPosition); pathNodes.Add(startPosition);
@@ -245,13 +245,12 @@ namespace Barotrauma
pathNodes.Reverse(); pathNodes.Reverse();
} }
List<VoronoiCell> pathCells = GeneratePath(rand, List<VoronoiCell> pathCells = GeneratePath(pathNodes, cells, pathBorders, minWidth, 0.3f, mirror, true);
pathNodes, cells, pathBorders, minWidth, 0.3f, mirror, true);
//place some enemy spawnpoints at random points in the path //place some enemy spawnpoints at random points in the path
for (int i = 0; i <3 ; i++ ) 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 wayPoint = new WayPoint(new Rectangle((int)position.X, (int)position.Y, 10, 10));
wayPoint.MoveWithLevel = true; wayPoint.MoveWithLevel = true;
wayPoint.SpawnType = SpawnType.Enemy; wayPoint.SpawnType = SpawnType.Enemy;
@@ -261,22 +260,22 @@ namespace Barotrauma
endPosition = pathCells[pathCells.Count - 1].Center; endPosition = pathCells[pathCells.Count - 1].Center;
//generate a couple of random paths //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( //pathBorders = new Rectangle(
//borders.X + siteInterval * 2, borders.Y - siteInterval * 2, //borders.X + siteInterval * 2, borders.Y - siteInterval * 2,
//borders.Right - siteInterval * 2, borders.Y + borders.Height - 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 x = pathBorders.X + Rand.Range(0, pathBorders.Right - pathBorders.X, false);
float y = pathBorders.Y + (float)rand.NextDouble() * (pathBorders.Bottom - pathBorders.Y); float y = pathBorders.Y + Rand.Range(0,pathBorders.Bottom - pathBorders.Y, false);
if (mirror) x = borders.Width - x; if (mirror) x = borders.Width - x;
Vector2 end = new Vector2(x, y); Vector2 end = new Vector2(x, y);
var newPathCells = GeneratePath(rand, new List<Vector2> { start, end }, cells, pathBorders, 0.0f, 0.8f, mirror); var newPathCells = GeneratePath(new List<Vector2> { start, end }, cells, pathBorders, 0.0f, 0.8f, mirror);
for (int n = 0; n < newPathCells.Count-5; n += 3) for (int n = 0; n < newPathCells.Count-5; n += 3)
{ {
@@ -321,26 +320,29 @@ namespace Barotrauma
startPosition.Y = borders.Height; startPosition.Y = borders.Height;
endPosition.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) vertices = GeneratePolygons(cells, pathCells);
// {
// int cellIndex = FindCellIndex(new Vector2(tunnelStart.X + minWidth * 0.5f * n, tunnelStart.Y), 3);
// foreach (GraphEdge ge in cells[cellIndex].edges) wrappingWalls = new WrappingWall[2, 2];
// {
// 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;
// }
// }
//}
//startPosition.Y += shaftHeight; for (int side = 0; side < 2; side++)
//endPosition.Y += shaftHeight; {
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));
GeneratePolygons(cells, pathCells); wrappingWalls[side, i].Vertices = GeneratePolygons(wrappingWalls[side, i].Cells, new List<VoronoiCell>());
}
}
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) foreach (VoronoiCell cell in cells)
{ {
@@ -357,8 +359,8 @@ namespace Barotrauma
Debug.WriteLine("Generatelevel: " + sw2.ElapsedMilliseconds + " ms"); Debug.WriteLine("Generatelevel: " + sw2.ElapsedMilliseconds + " ms");
sw2.Restart(); sw2.Restart();
vertexBuffer = new VertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly); //vertexBuffer = new VertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
vertexBuffer.SetData(vertices); //vertexBuffer.SetData(vertices);
if (mirror) if (mirror)
{ {
@@ -370,7 +372,7 @@ namespace Barotrauma
Debug.WriteLine("Generated a map with " + sites.Count + " sites in " + sw.ElapsedMilliseconds + " ms"); Debug.WriteLine("Generated a map with " + sites.Count + " sites in " + sw.ElapsedMilliseconds + " ms");
} }
private List<VoronoiCell> GeneratePath(Random rand, List<Vector2> points, List<VoronoiCell> cells, Microsoft.Xna.Framework.Rectangle limits, float minWidth, float wanderAmount = 0.3f, bool mirror=false, bool placeWaypoints=false) private List<VoronoiCell> GeneratePath(List<Vector2> points, List<VoronoiCell> cells, Microsoft.Xna.Framework.Rectangle limits, float minWidth, float wanderAmount = 0.3f, bool mirror=false, bool placeWaypoints=false)
{ {
Stopwatch sw2 = new Stopwatch(); Stopwatch sw2 = new Stopwatch();
sw2.Start(); sw2.Start();
@@ -390,15 +392,14 @@ namespace Barotrauma
VoronoiCell currentCell = targetCells[0]; VoronoiCell currentCell = targetCells[0];
pathCells.Add(currentCell); pathCells.Add(currentCell);
int currentTargetIndex = 1; int currentTargetIndex = 1;
do do
{ {
int edgeIndex = 0; int edgeIndex = 0;
//steer towards target //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++) for (int i = 0; i < currentCell.edges.Count; i++)
{ {
@@ -420,11 +421,11 @@ int currentTargetIndex = 1;
} }
if (allowedEdges.Count==0) if (allowedEdges.Count==0)
{ {
edgeIndex = rand.Next() % currentCell.edges.Count; edgeIndex = Rand.Int(currentCell.edges.Count, false);
} }
else else
{ {
edgeIndex = rand.Next() % allowedEdges.Count; edgeIndex = Rand.Int(allowedEdges.Count, false);
if (mirror && edgeIndex > 0) edgeIndex = allowedEdges.Count - edgeIndex; if (mirror && edgeIndex > 0) edgeIndex = allowedEdges.Count - edgeIndex;
edgeIndex = currentCell.edges.IndexOf(allowedEdges[edgeIndex]); edgeIndex = currentCell.edges.IndexOf(allowedEdges[edgeIndex]);
} }
@@ -534,6 +535,7 @@ int currentTargetIndex = 1;
return tooCloseCells; return tooCloseCells;
} }
/// <summary> /// <summary>
/// remove all cells except those that are adjacent to the empty cells /// remove all cells except those that are adjacent to the empty cells
/// </summary> /// </summary>
@@ -580,12 +582,11 @@ int currentTargetIndex = 1;
} }
} }
return cells.IndexOf(closestCell); return cells.IndexOf(closestCell);
} }
private void GeneratePolygons(List<VoronoiCell> cells, List<VoronoiCell> emptyCells)
private VertexPositionTexture[] GeneratePolygons(List<VoronoiCell> cells, List<VoronoiCell> emptyCells)
{ {
List<VertexPositionTexture> verticeList = new List<VertexPositionTexture>(); List<VertexPositionTexture> verticeList = new List<VertexPositionTexture>();
//bodies = new List<Body>(); //bodies = new List<Body>();
@@ -606,7 +607,7 @@ int currentTargetIndex = 1;
if (!tempVertices.Contains(ge.point2)) tempVertices.Add(ge.point2); if (!tempVertices.Contains(ge.point2)) tempVertices.Add(ge.point2);
VoronoiCell adjacentCell = ge.AdjacentCell(cell); VoronoiCell adjacentCell = ge.AdjacentCell(cell);
if (!emptyCells.Contains(adjacentCell)) continue; if (adjacentCell!=null && !emptyCells.Contains(adjacentCell)) continue;
ge.isSolid = true; ge.isSolid = true;
@@ -680,7 +681,7 @@ int currentTargetIndex = 1;
bodies.Add(shaftBody); bodies.Add(shaftBody);
} }
vertices = verticeList.ToArray(); return verticeList.ToArray();
} }
public void SetPosition(Vector2 pos) public void SetPosition(Vector2 pos)
@@ -715,6 +716,8 @@ int currentTargetIndex = 1;
item.SetTransform(item.SimPosition+amount, item.body.Rotation); item.SetTransform(item.SimPosition+amount, item.body.Rotation);
} }
} }
//WrappingWall.UpdateWallShift(Position, wrappingWalls);
} }
Vector2 prevVelocity; Vector2 prevVelocity;
@@ -748,6 +751,8 @@ int currentTargetIndex = 1;
AtEndPosition = Vector2.Distance(endPosition, -Position) < ExitDistance; AtEndPosition = Vector2.Distance(endPosition, -Position) < ExitDistance;
prevVelocity = simVelocity; prevVelocity = simVelocity;
WrappingWall.UpdateWallShift(-Position, wrappingWalls);
} }
public static void AfterWorldStep() public static void AfterWorldStep()
@@ -803,37 +808,6 @@ int currentTargetIndex = 1;
System.Diagnostics.Debug.WriteLine("pos: " + Position); 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) public void Draw(SpriteBatch spriteBatch)
{ {
Vector2 pos = endPosition; Vector2 pos = endPosition;
@@ -937,6 +911,22 @@ int currentTargetIndex = 1;
graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap; graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
graphicsDevice.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, vertices, 0, (int)Math.Floor(vertices.Length / 3.0f)); graphicsDevice.DrawUserPrimitives<VertexPositionTexture>(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<VertexPositionTexture>(PrimitiveType.TriangleList,
wrappingWalls[side, i].Vertices, 0, (int)Math.Floor(wrappingWalls[side, i].Vertices.Length / 3.0f));
}
}
} }
private void Unload() private void Unload()
@@ -961,8 +951,8 @@ int currentTargetIndex = 1;
bodies.Clear(); bodies.Clear();
bodies = null; bodies = null;
vertexBuffer.Dispose(); //vertexBuffer.Dispose();
vertexBuffer = null; //vertexBuffer = null;
} }
} }
@@ -79,6 +79,11 @@ namespace Voronoi2
public Point coord; public Point coord;
public int sitenbr; public int sitenbr;
public void SetPoint(Vector2 point)
{
coord.setPoint(point.X, point.Y);
}
public Site () public Site ()
{ {
coord = new Point(); coord = new Point();
@@ -130,6 +135,32 @@ namespace Voronoi2
get { return new Vector2((float)site.coord.x, (float)site.coord.y); } get { return new Vector2((float)site.coord.x, (float)site.coord.y); }
} }
public VoronoiCell(Vector2[] vertices)
{
edges = new List<GraphEdge>();
bodyVertices = new List<Vector2>();
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) public VoronoiCell(Site site)
{ {
edges = new List<GraphEdge>(); edges = new List<GraphEdge>();
@@ -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<VoronoiCell> cells;
public Vector2 Offset
{
get { return offset; }
}
public List<VoronoiCell> Cells
{
get { return cells; }
}
public WrappingWall(List<VoronoiCell> pathCells, List<VoronoiCell> mapCells, float maxY, int dir = -1)
{
cells = new List<VoronoiCell>();
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<Vector2> bottomVertices = new List<Vector2>();
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;
}
}
}
+1 -1
View File
@@ -118,7 +118,7 @@ namespace Barotrauma
Vector2[] points = new Vector2[] { edge.point1, edge.point2 }; Vector2[] points = new Vector2[] { edge.point1, edge.point2 };
int positionIndex = Rand.Int(1,false); int positionIndex = Rand.Int(1, false);
Vector2 position = points[positionIndex]; Vector2 position = points[positionIndex];
if (newLocations[1 - i] != null && newLocations[1 - i].MapPosition == position) position = points[1 - positionIndex]; if (newLocations[1 - i] != null && newLocations[1 - i].MapPosition == position) position = points[1 - positionIndex];
+1 -1
View File
@@ -223,8 +223,8 @@ namespace Barotrauma.Networking
connectedClients.Find(c => c.character != null && !c.character.IsDead)==null && connectedClients.Find(c => c.character != null && !c.character.IsDead)==null &&
(myCharacter == null || myCharacter.IsDead)) (myCharacter == null || myCharacter.IsDead))
{ {
EndButtonHit(null, null);
AutoRestartTimer = 20.0f; AutoRestartTimer = 20.0f;
EndButtonHit(null, null);
UpdateNetLobby(null,null); UpdateNetLobby(null,null);
return; return;
} }
+1 -1
View File
@@ -292,7 +292,7 @@ namespace Barotrauma
if (GameMain.GameSession != null && GameMain.GameSession.Level != null) if (GameMain.GameSession != null && GameMain.GameSession.Level != null)
{ {
GameMain.GameSession.Level.Render(graphics, cam); GameMain.GameSession.Level.Render(graphics, cam);
GameMain.GameSession.Level.SetObserverPosition(cam.WorldViewCenter); //GameMain.GameSession.Level.SetObserverPosition(cam.WorldViewCenter);
} }
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
+2 -2
View File
@@ -339,10 +339,10 @@ namespace Barotrauma
playerName.Text = characterInfo.Name; playerName.Text = characterInfo.Name;
playerName.OnEnterPressed += ChangeCharacterName; 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.UserData = -1;
toggleHead.OnClicked = ToggleHead; 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.UserData = 1;
toggleHead.OnClicked = ToggleHead; toggleHead.OnClicked = ToggleHead;
@@ -93,6 +93,9 @@ namespace Barotrauma.Networking
selectionTick.OnSelected = SwitchModeSelection; selectionTick.OnSelected = SwitchModeSelection;
selectionTick.UserData = (SelectionMode)i; 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) private bool SwitchSubSelection(GUITickBox tickBox)
+10
View File
@@ -312,6 +312,16 @@ namespace Barotrauma
return BitConverter.ToInt32(asciiBytes, 0); return BitConverter.ToInt32(asciiBytes, 0);
} }
/// <summary>
/// a method for changing inputtypes with old names to the new ones to ensure backwards compatibility with older subs
/// </summary>
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) public static string WrapText(string text, float lineLength, SpriteFont font)
{ {
Binary file not shown.