- pasted entities are assigned to the main sub (-> entities copypasted from another sub are saved)

- fixed submarinebody attempting to generate a physics body for a sub with no walls if there are some other walls loaded
- MathUtils.GiftWrap doesn't throw an exception if passed an empty list of points
This commit is contained in:
Regalis
2017-03-15 23:59:23 +02:00
parent ede3f1c393
commit 40f5f352f5
3 changed files with 11 additions and 5 deletions
+5 -1
View File
@@ -464,7 +464,11 @@ namespace Barotrauma
Vector2 moveAmount = Submarine.VectorToWorldGrid(cam.WorldViewCenter - center); Vector2 moveAmount = Submarine.VectorToWorldGrid(cam.WorldViewCenter - center);
selectedList = new List<MapEntity>(clones); selectedList = new List<MapEntity>(clones);
selectedList.ForEach(c => c.Move(moveAmount)); foreach (MapEntity clone in selectedList)
{
clone.Move(moveAmount);
clone.Submarine = Submarine.MainSub;
}
} }
} }
+4 -4
View File
@@ -160,17 +160,17 @@ namespace Barotrauma
private List<Vector2> GenerateConvexHull() private List<Vector2> GenerateConvexHull()
{ {
if (!Structure.WallList.Any()) List<Structure> subWalls = Structure.WallList.FindAll(wall => wall.Submarine == submarine);
if (subWalls.Count == 0)
{ {
return new List<Vector2> { new Vector2(-1.0f, 1.0f), new Vector2(1.0f, 1.0f), new Vector2(0.0f, -1.0f) }; return new List<Vector2> { new Vector2(-1.0f, 1.0f), new Vector2(1.0f, 1.0f), new Vector2(0.0f, -1.0f) };
} }
List<Vector2> points = new List<Vector2>(); List<Vector2> points = new List<Vector2>();
foreach (Structure wall in Structure.WallList) foreach (Structure wall in subWalls)
{ {
if (wall.Submarine != submarine) continue;
points.Add(new Vector2(wall.Rect.X, wall.Rect.Y)); points.Add(new Vector2(wall.Rect.X, wall.Rect.Y));
points.Add(new Vector2(wall.Rect.X + wall.Rect.Width, wall.Rect.Y)); points.Add(new Vector2(wall.Rect.X + wall.Rect.Width, wall.Rect.Y));
points.Add(new Vector2(wall.Rect.X, wall.Rect.Y - wall.Rect.Height)); points.Add(new Vector2(wall.Rect.X, wall.Rect.Y - wall.Rect.Height));
+2
View File
@@ -381,6 +381,8 @@ namespace Barotrauma
public static List<Vector2> GiftWrap(List<Vector2> points) public static List<Vector2> GiftWrap(List<Vector2> points)
{ {
if (points.Count == 0) return points;
Vector2 leftMost = points[0]; Vector2 leftMost = points[0];
foreach (Vector2 point in points) foreach (Vector2 point in points)
{ {