Improved level generation algorithm, fixed invisible hulls, turret projectile fix, fabricators work in mp
This commit is contained in:
@@ -176,7 +176,7 @@ namespace Barotrauma
|
||||
Vector2 start = connection.Locations[0].MapPosition;
|
||||
Vector2 end = connection.Locations[1].MapPosition;
|
||||
int generations = (int)(Math.Sqrt(Vector2.Distance(start, end) / 10.0f));
|
||||
connection.CrackSegments = GenerateCrack(start, end, generations);
|
||||
connection.CrackSegments = MathUtils.GenerateJaggedLine(start, end, generations, 5.0f);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -200,39 +200,6 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private List<Vector2[]> GenerateCrack(Vector2 start, Vector2 end, int generations)
|
||||
{
|
||||
List<Vector2[]> segments = new List<Vector2[]>();
|
||||
|
||||
segments.Add(new Vector2[] {start, end});
|
||||
|
||||
float offsetAmount = 5.0f;
|
||||
|
||||
for (int n = 0; n < generations; n++)
|
||||
{
|
||||
for (int i = 0; i < segments.Count; i++)
|
||||
{
|
||||
Vector2 startSegment = segments[i][0];
|
||||
Vector2 endSegment = segments[i][1];
|
||||
|
||||
segments.RemoveAt(i);
|
||||
|
||||
Vector2 midPoint = (startSegment + endSegment) / 2.0f;
|
||||
|
||||
Vector2 normal = Vector2.Normalize(endSegment - startSegment);
|
||||
normal = new Vector2(-normal.Y, normal.X);
|
||||
midPoint += normal * Rand.Range(-offsetAmount, offsetAmount, false);
|
||||
|
||||
segments.Insert(i, new Vector2[] { startSegment, midPoint });
|
||||
segments.Insert(i+1, new Vector2[] { midPoint, endSegment });
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return segments;
|
||||
}
|
||||
|
||||
public void MoveToNextLocation()
|
||||
{
|
||||
currentLocation = selectedLocation;
|
||||
|
||||
Reference in New Issue
Block a user