The size of the docked subs is taken into account when generating the level

This commit is contained in:
Regalis
2016-12-13 23:21:47 +02:00
parent 2ef7c2f996
commit a2f19a3b16
2 changed files with 30 additions and 2 deletions
+6 -2
View File
@@ -183,8 +183,12 @@ namespace Barotrauma
float avgValue = (backgroundColor.R + backgroundColor.G + backgroundColor.G) / 3;
GameMain.LightManager.AmbientLight = new Color(backgroundColor * (10.0f / avgValue), 1.0f);
float minWidth = Submarine.MainSub == null ? 0.0f : Math.Max(Submarine.MainSub.Borders.Width, Submarine.MainSub.Borders.Height);
minWidth = Math.Max(minWidth, 6500.0f);
float minWidth = 6500.0f;
if (Submarine.MainSub != null)
{
Rectangle dockedSubBorders = Submarine.MainSub.GetDockedBorders();
minWidth = Math.Max(minWidth, Math.Max(dockedSubBorders.Width, dockedSubBorders.Height));
}
startPosition = new Vector2(
Rand.Range(minWidth, minWidth * 2, false),
+24
View File
@@ -288,6 +288,30 @@ namespace Barotrauma
tags &= ~tag;
}
/// <summary>
/// Returns a rect that contains the borders of this sub and all subs docked to it
/// </summary>
public Rectangle GetDockedBorders()
{
Rectangle dockedBorders = Borders;
dockedBorders.Y -= dockedBorders.Height;
foreach (Submarine dockedSub in DockedTo)
{
Vector2 diff = dockedSub.Submarine == this ? dockedSub.WorldPosition : dockedSub.WorldPosition - WorldPosition;
Rectangle dockedSubBorders = dockedSub.Borders;
dockedSubBorders.Y -= dockedSubBorders.Height;
dockedSubBorders.Location += diff.ToPoint();
dockedBorders = Rectangle.Union(dockedBorders, dockedSubBorders);
}
dockedBorders.Y += dockedBorders.Height;
return dockedBorders;
}
//drawing ----------------------------------------------------
public static void CullEntities(Camera cam)