Dockingport gap linking fixes. Closes #551
- Dockingports force the hatch/door gaps to be connected to the hulls between the ports, because connecting them automatically may fail if the ports are positioned in a non-standard way. - Gaps don't recheck hulls in OnMapLoaded if rechecks have been disabled. - Item.UpdateHulls and Gap.UpdateHulls are not called when OnMapLoaded is called during ruin generation.
This commit is contained in:
@@ -62,6 +62,8 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
if (!GameMain.DebugDraw) return;
|
||||
|
||||
if (bodies != null)
|
||||
{
|
||||
for (int i = 0; i < bodies.Length; i++)
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace Barotrauma.Items.Components
|
||||
if (joint != null)
|
||||
{
|
||||
CreateJoint(joint is WeldJoint);
|
||||
LinkHullsToGap();
|
||||
LinkHullsToGaps();
|
||||
}
|
||||
else if (dockingTarget.joint != null)
|
||||
{
|
||||
@@ -132,7 +132,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
dockingTarget.CreateJoint(dockingTarget.joint is WeldJoint);
|
||||
}
|
||||
dockingTarget.LinkHullsToGap();
|
||||
dockingTarget.LinkHullsToGaps();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -435,7 +435,7 @@ namespace Barotrauma.Items.Components
|
||||
gap = new Gap(new Rectangle(hullRects[0].X, hullRects[0].Y+2, hullRects[0].Width, 4), false, subs[0]);
|
||||
}
|
||||
|
||||
LinkHullsToGap();
|
||||
LinkHullsToGaps();
|
||||
|
||||
hulls[0].ShouldBeSaved = false;
|
||||
hulls[1].ShouldBeSaved = false;
|
||||
@@ -457,7 +457,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
private void LinkHullsToGap()
|
||||
private void LinkHullsToGaps()
|
||||
{
|
||||
if (gap == null || hulls == null || hulls[0] == null || hulls[1] == null)
|
||||
{
|
||||
@@ -495,6 +495,35 @@ namespace Barotrauma.Items.Components
|
||||
gap.linkedTo.Add(hulls[0]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Gap gap = i == 0 ? door?.LinkedGap : dockingTarget?.door?.LinkedGap;
|
||||
if (gap == null || gap.linkedTo.Count == 2) continue;
|
||||
|
||||
if (IsHorizontal)
|
||||
{
|
||||
if (item.WorldPosition.X < dockingTarget.item.WorldPosition.X)
|
||||
{
|
||||
if (!gap.linkedTo.Contains(hulls[0])) gap.linkedTo.Add(hulls[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!gap.linkedTo.Contains(hulls[1])) gap.linkedTo.Add(hulls[1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.WorldPosition.Y < dockingTarget.item.WorldPosition.Y)
|
||||
{
|
||||
if (!gap.linkedTo.Contains(hulls[0])) gap.linkedTo.Add(hulls[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!gap.linkedTo.Contains(hulls[1])) gap.linkedTo.Add(hulls[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Undock()
|
||||
|
||||
@@ -641,7 +641,7 @@ namespace Barotrauma
|
||||
|
||||
public override void OnMapLoaded()
|
||||
{
|
||||
FindHulls();
|
||||
if (!DisableHullRechecks) FindHulls();
|
||||
}
|
||||
|
||||
public static void Load(XElement element, Submarine submarine)
|
||||
|
||||
@@ -391,8 +391,11 @@ namespace Barotrauma
|
||||
mapEntityList[i].OnMapLoaded();
|
||||
}
|
||||
|
||||
Item.UpdateHulls();
|
||||
Gap.UpdateHulls();
|
||||
if (sub != null)
|
||||
{
|
||||
Item.UpdateHulls();
|
||||
Gap.UpdateHulls();
|
||||
}
|
||||
|
||||
foreach (LinkedSubmarine linkedSub in linkedSubs)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user