Docking port fixes again. Closes #551
- Non-saveable entities aren't removed from the linkedTo-list during saving, because that causes gaps to become unlinked with the hulls between docking ports when starting a campaign round. - Hull rechecks are disabled on docking port gaps, because moving linked subs into place may cause the gaps to become unlinked if they're positioned in a certain way (for example in some subs the hulls between the docking ports end up inside the gap). - Dockingports only connect the waypoints linked to their gap to each other, instead of every waypoint that happens to be inside the gap.
This commit is contained in:
@@ -135,13 +135,21 @@ namespace Barotrauma
|
||||
{
|
||||
base.Move(amount);
|
||||
|
||||
FindHulls();
|
||||
if (!DisableHullRechecks) FindHulls();
|
||||
}
|
||||
|
||||
public static void UpdateHulls()
|
||||
{
|
||||
foreach (Gap g in GapList)
|
||||
{
|
||||
for (int i = g.linkedTo.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (g.linkedTo[i].Removed)
|
||||
{
|
||||
g.linkedTo.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (g.DisableHullRechecks) continue;
|
||||
g.FindHulls();
|
||||
}
|
||||
|
||||
@@ -261,22 +261,16 @@ namespace Barotrauma
|
||||
if (saveElement.Attribute("pos") != null) saveElement.Attribute("pos").Remove();
|
||||
saveElement.Add(new XAttribute("pos", XMLExtensions.Vector2ToString(Position - Submarine.HiddenSubPosition)));
|
||||
|
||||
|
||||
|
||||
var linkedPort = linkedTo.FirstOrDefault(lt => (lt is Item) && ((Item)lt).GetComponent<DockingPort>() != null);
|
||||
if (linkedPort != null)
|
||||
{
|
||||
if (saveElement.Attribute("linkedto") != null) saveElement.Attribute("linkedto").Remove();
|
||||
|
||||
saveElement.Add(new XAttribute("linkedto", linkedPort.ID));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
saveElement = new XElement("LinkedSubmarine");
|
||||
|
||||
|
||||
sub.SaveToXElement(saveElement);
|
||||
}
|
||||
|
||||
|
||||
@@ -1250,16 +1250,7 @@ namespace Barotrauma
|
||||
element.Add(new XAttribute("recommendedcrewsizemax", RecommendedCrewSizeMax));
|
||||
element.Add(new XAttribute("recommendedcrewexperience", RecommendedCrewExperience ?? ""));
|
||||
element.Add(new XAttribute("compatiblecontentpackages", string.Join(", ", CompatibleContentPackages)));
|
||||
|
||||
foreach (MapEntity e in MapEntity.mapEntityList)
|
||||
{
|
||||
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.Submarine != this || !e.ShouldBeSaved) continue;
|
||||
|
||||
@@ -636,6 +636,7 @@ namespace Barotrauma
|
||||
int i = 0;
|
||||
foreach (MapEntity e in linkedTo)
|
||||
{
|
||||
if (!e.ShouldBeSaved) continue;
|
||||
element.Add(new XAttribute("linkedto" + i, e.ID));
|
||||
i += 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user