Cleanup
This commit is contained in:
@@ -247,9 +247,6 @@ namespace Barotrauma
|
|||||||
//make sure the cells are in the same order regardless of whether the level is mirrored or not
|
//make sure the cells are in the same order regardless of whether the level is mirrored or not
|
||||||
cells.Sort((c1, c2) => { return level.Mirrored ? Math.Sign(c1.Center.X - c2.Center.X) : -Math.Sign(c1.Center.X - c2.Center.X); });
|
cells.Sort((c1, c2) => { return level.Mirrored ? Math.Sign(c1.Center.X - c2.Center.X) : -Math.Sign(c1.Center.X - c2.Center.X); });
|
||||||
|
|
||||||
/*System.Diagnostics.Debug.WriteLine("FindSpritePosition - prefab: "+System.IO.Path.GetFileNameWithoutExtension(prefab.Sprite.FilePath)+" cells: "+cells.Count+" spawnpos: "+ prefab.SpawnPos+" randompos: "+ randomPos);
|
|
||||||
System.Diagnostics.Debug.WriteLine(string.Join(", ",cells.Select(c => level.cells.IndexOf(c))));*/
|
|
||||||
|
|
||||||
if (cells.Any())
|
if (cells.Any())
|
||||||
{
|
{
|
||||||
VoronoiCell cell = cells[Rand.Int(cells.Count, Rand.RandSync.Server)];
|
VoronoiCell cell = cells[Rand.Int(cells.Count, Rand.RandSync.Server)];
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ namespace Barotrauma
|
|||||||
return new Level(seed, Rand.Range(30.0f, 80.0f, Rand.RandSync.Server), LevelGenerationParams.GetRandom(seed));
|
return new Level(seed, Rand.Range(30.0f, 80.0f, Rand.RandSync.Server), LevelGenerationParams.GetRandom(seed));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Generate(bool mirror = false)
|
public void Generate(bool mirror = true)
|
||||||
{
|
{
|
||||||
Mirrored = mirror;
|
Mirrored = mirror;
|
||||||
|
|
||||||
@@ -390,7 +390,6 @@ namespace Barotrauma
|
|||||||
pathCells.AddRange(newPathCells);
|
pathCells.AddRange(newPathCells);
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.WriteLine("path: " + sw2.ElapsedMilliseconds + " ms");
|
|
||||||
sw2.Restart();
|
sw2.Restart();
|
||||||
|
|
||||||
|
|
||||||
@@ -398,12 +397,10 @@ namespace Barotrauma
|
|||||||
// remove unnecessary cells and create some holes at the bottom of the level
|
// remove unnecessary cells and create some holes at the bottom of the level
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
System.Diagnostics.Debug.WriteLine("cellcount before cleaning: " + cells.Count);
|
|
||||||
cells = CleanCells(pathCells);
|
cells = CleanCells(pathCells);
|
||||||
pathCells.AddRange(CreateBottomHoles(generationParams.BottomHoleProbability, new Rectangle(
|
pathCells.AddRange(CreateBottomHoles(generationParams.BottomHoleProbability, new Rectangle(
|
||||||
(int)(borders.Width * 0.2f), 0,
|
(int)(borders.Width * 0.2f), 0,
|
||||||
(int)(borders.Width * 0.6f), (int)(borders.Height * 0.8f))));
|
(int)(borders.Width * 0.6f), (int)(borders.Height * 0.8f))));
|
||||||
System.Diagnostics.Debug.WriteLine("cellcount after bottom holes: " + cells.Count);
|
|
||||||
|
|
||||||
foreach (VoronoiCell cell in cells)
|
foreach (VoronoiCell cell in cells)
|
||||||
{
|
{
|
||||||
@@ -415,7 +412,6 @@ namespace Barotrauma
|
|||||||
// initialize the cells that are still left and insert them into the cell grid
|
// initialize the cells that are still left and insert them into the cell grid
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
System.Diagnostics.Debug.WriteLine("pathcells before init: " + cells.Count);
|
|
||||||
foreach (VoronoiCell cell in pathCells)
|
foreach (VoronoiCell cell in pathCells)
|
||||||
{
|
{
|
||||||
cell.edges.ForEach(e => e.OutsideLevel = false);
|
cell.edges.ForEach(e => e.OutsideLevel = false);
|
||||||
@@ -436,8 +432,6 @@ namespace Barotrauma
|
|||||||
// mirror if needed
|
// mirror if needed
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
System.Diagnostics.Debug.WriteLine("cellcount: "+cells.Count);
|
|
||||||
System.Diagnostics.Debug.WriteLine("pathcellcount: " + pathCells.Count);
|
|
||||||
if (mirror)
|
if (mirror)
|
||||||
{
|
{
|
||||||
HashSet<GraphEdge> mirroredEdges = new HashSet<GraphEdge>();
|
HashSet<GraphEdge> mirroredEdges = new HashSet<GraphEdge>();
|
||||||
@@ -508,13 +502,9 @@ namespace Barotrauma
|
|||||||
ruins = new List<Ruin>();
|
ruins = new List<Ruin>();
|
||||||
for (int i = 0; i < generationParams.RuinCount; i++)
|
for (int i = 0; i < generationParams.RuinCount; i++)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.WriteLine("Generating ruin "+i+" *******************************************");
|
|
||||||
GenerateRuin(mainPath, mirror);
|
GenerateRuin(mainPath, mirror);
|
||||||
}
|
}
|
||||||
|
|
||||||
int testSync = Rand.Int(1000, Rand.RandSync.Server);
|
|
||||||
System.Diagnostics.Debug.WriteLine("TESTSYNC: " + testSync + " ---------------------------------------------",Color.White);
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// generate the bodies and rendered triangles of the cells
|
// generate the bodies and rendered triangles of the cells
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
@@ -898,19 +888,12 @@ namespace Barotrauma
|
|||||||
Vector2 ruinSize = new Vector2(Rand.Range(5000.0f, 8000.0f, Rand.RandSync.Server), Rand.Range(5000.0f, 8000.0f, Rand.RandSync.Server));
|
Vector2 ruinSize = new Vector2(Rand.Range(5000.0f, 8000.0f, Rand.RandSync.Server), Rand.Range(5000.0f, 8000.0f, Rand.RandSync.Server));
|
||||||
float ruinRadius = Math.Max(ruinSize.X, ruinSize.Y) * 0.5f;
|
float ruinRadius = Math.Max(ruinSize.X, ruinSize.Y) * 0.5f;
|
||||||
|
|
||||||
System.Diagnostics.Debug.WriteLine("Cell count " + cells.Count);
|
|
||||||
for (int i = 0; i<cells.Count && i < 100; i++)
|
|
||||||
{
|
|
||||||
System.Diagnostics.Debug.WriteLine(" " + i + ": " + cells[i].Center);
|
|
||||||
}
|
|
||||||
int cellIndex = Rand.Int(cells.Count, Rand.RandSync.Server);
|
int cellIndex = Rand.Int(cells.Count, Rand.RandSync.Server);
|
||||||
System.Diagnostics.Debug.WriteLine("Cell index " + cellIndex);
|
|
||||||
Vector2 ruinPos = cells[cellIndex].Center;
|
Vector2 ruinPos = cells[cellIndex].Center;
|
||||||
|
|
||||||
//50% chance of placing the ruins at a cave
|
//50% chance of placing the ruins at a cave
|
||||||
if (Rand.Range(0.0f, 1.0f, Rand.RandSync.Server) < 0.5f)
|
if (Rand.Range(0.0f, 1.0f, Rand.RandSync.Server) < 0.5f)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.WriteLine("Placing at cave");
|
|
||||||
TryGetInterestingPosition(true, PositionType.Cave, 0.0f, out ruinPos);
|
TryGetInterestingPosition(true, PositionType.Cave, 0.0f, out ruinPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -920,8 +903,6 @@ namespace Barotrauma
|
|||||||
float minDist = ruinRadius * 2.0f;
|
float minDist = ruinRadius * 2.0f;
|
||||||
float minDistSqr = minDist * minDist;
|
float minDistSqr = minDist * minDist;
|
||||||
|
|
||||||
System.Diagnostics.Debug.WriteLine("Initial ruin pos "+ruinPos);
|
|
||||||
|
|
||||||
int iter = 0;
|
int iter = 0;
|
||||||
while (mainPath.Any(p => Vector2.DistanceSquared(ruinPos, p.Center) < minDistSqr))
|
while (mainPath.Any(p => Vector2.DistanceSquared(ruinPos, p.Center) < minDistSqr))
|
||||||
{
|
{
|
||||||
@@ -946,8 +927,6 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
ruinPos = weighedPathPos;
|
ruinPos = weighedPathPos;
|
||||||
System.Diagnostics.Debug.WriteLine(iter+": " + ruinPos);
|
|
||||||
|
|
||||||
if (iter > 10000) break;
|
if (iter > 10000) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -963,15 +942,9 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.Diagnostics.Debug.WriteLine("Final ruin pos: " + ruinPos);
|
|
||||||
int testSync = Rand.Int(1000, Rand.RandSync.Server);
|
|
||||||
System.Diagnostics.Debug.WriteLine("TESTSYNC2: " + testSync + " ---------------------------------------------", Color.White);
|
|
||||||
var ruin = new Ruin(closestPathCell, cells, new Rectangle(MathUtils.ToPoint(ruinPos - ruinSize * 0.5f), MathUtils.ToPoint(ruinSize)), mirror);
|
var ruin = new Ruin(closestPathCell, cells, new Rectangle(MathUtils.ToPoint(ruinPos - ruinSize * 0.5f), MathUtils.ToPoint(ruinSize)), mirror);
|
||||||
ruins.Add(ruin);
|
ruins.Add(ruin);
|
||||||
|
|
||||||
testSync = Rand.Int(1000, Rand.RandSync.Server);
|
|
||||||
System.Diagnostics.Debug.WriteLine("TESTSYNC3: " + testSync + " ---------------------------------------------", Color.White);
|
|
||||||
|
|
||||||
ruin.RuinShapes.Sort((shape1, shape2) => shape2.DistanceFromEntrance.CompareTo(shape1.DistanceFromEntrance));
|
ruin.RuinShapes.Sort((shape1, shape2) => shape2.DistanceFromEntrance.CompareTo(shape1.DistanceFromEntrance));
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user