Fixed docking ports creating duplicate hulls and gaps during loading
This commit is contained in:
@@ -419,8 +419,6 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
gap = new Gap(new Rectangle(hullRects[0].Right - 2, hullRects[0].Y, 4, hullRects[0].Height), true, subs[0]);
|
gap = new Gap(new Rectangle(hullRects[0].Right - 2, hullRects[0].Y, 4, hullRects[0].Height), true, subs[0]);
|
||||||
if (gapId != null) gap.ID = (ushort)gapId;
|
if (gapId != null) gap.ID = (ushort)gapId;
|
||||||
|
|
||||||
LinkHullsToGap();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -443,19 +441,20 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
gap = new Gap(new Rectangle(hullRects[0].X, hullRects[0].Y+2, hullRects[0].Width, 4), false, subs[0]);
|
gap = new Gap(new Rectangle(hullRects[0].X, hullRects[0].Y+2, hullRects[0].Width, 4), false, subs[0]);
|
||||||
if (gapId != null) gap.ID = (ushort)gapId;
|
if (gapId != null) gap.ID = (ushort)gapId;
|
||||||
|
|
||||||
LinkHullsToGap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
item.linkedTo.Add(hulls[0]);
|
LinkHullsToGap();
|
||||||
item.linkedTo.Add(hulls[1]);
|
|
||||||
|
|
||||||
hullIds[0] = hulls[0].ID;
|
hullIds[0] = hulls[0].ID;
|
||||||
hullIds[1] = hulls[1].ID;
|
hullIds[1] = hulls[1].ID;
|
||||||
|
hulls[0].ShouldBeSaved = false;
|
||||||
|
hulls[1].ShouldBeSaved = false;
|
||||||
|
item.linkedTo.Add(hulls[0]);
|
||||||
|
item.linkedTo.Add(hulls[1]);
|
||||||
|
|
||||||
gap.DisableHullRechecks = true;
|
gap.DisableHullRechecks = true;
|
||||||
|
gap.ShouldBeSaved = false;
|
||||||
gapId = gap.ID;
|
gapId = gap.ID;
|
||||||
|
|
||||||
item.linkedTo.Add(gap);
|
item.linkedTo.Add(gap);
|
||||||
|
|
||||||
foreach (Body body in bodies)
|
foreach (Body body in bodies)
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ namespace Barotrauma
|
|||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ShouldBeSaved = true;
|
||||||
|
|
||||||
//the position and dimensions of the entity
|
//the position and dimensions of the entity
|
||||||
protected Rectangle rect;
|
protected Rectangle rect;
|
||||||
|
|
||||||
@@ -45,7 +47,8 @@ namespace Barotrauma
|
|||||||
private static bool resizing;
|
private static bool resizing;
|
||||||
private int resizeDirX, resizeDirY;
|
private int resizeDirX, resizeDirY;
|
||||||
|
|
||||||
public virtual Rectangle Rect {
|
public virtual Rectangle Rect
|
||||||
|
{
|
||||||
get { return rect; }
|
get { return rect; }
|
||||||
set { rect = value; }
|
set { rect = value; }
|
||||||
}
|
}
|
||||||
@@ -353,15 +356,12 @@ namespace Barotrauma
|
|||||||
|
|
||||||
foreach (ushort i in e.linkedToID)
|
foreach (ushort i in e.linkedToID)
|
||||||
{
|
{
|
||||||
MapEntity linked = FindEntityByID(i) as MapEntity;
|
if (FindEntityByID(i) is MapEntity linked) e.linkedTo.Add(linked);
|
||||||
|
|
||||||
if (linked != null) e.linkedTo.Add(linked);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<LinkedSubmarine> linkedSubs = new List<LinkedSubmarine>();
|
List<LinkedSubmarine> linkedSubs = new List<LinkedSubmarine>();
|
||||||
|
for (int i = 0; i < mapEntityList.Count; i++)
|
||||||
for (int i = 0; i<mapEntityList.Count; i++)
|
|
||||||
{
|
{
|
||||||
if (mapEntityList[i].Submarine != sub) continue;
|
if (mapEntityList[i].Submarine != sub) continue;
|
||||||
|
|
||||||
|
|||||||
@@ -1232,7 +1232,16 @@ namespace Barotrauma
|
|||||||
|
|
||||||
foreach (MapEntity e in MapEntity.mapEntityList)
|
foreach (MapEntity e in MapEntity.mapEntityList)
|
||||||
{
|
{
|
||||||
if (e.MoveWithLevel || e.Submarine != this) continue;
|
if (e.linkedTo == null) continue;
|
||||||
|
for (int i = e.linkedTo.Count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if (!e.linkedTo[i].ShouldBeSaved) e.linkedTo.RemoveAt(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (MapEntity e in MapEntity.mapEntityList)
|
||||||
|
{
|
||||||
|
if (e.MoveWithLevel || e.Submarine != this || !e.ShouldBeSaved) continue;
|
||||||
e.Save(element);
|
e.Save(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user