Submarine position syncing fix:
The position correction logic only moved the submarine that's being synced and the subs docked directly to it, but not the subs docked to the docked subs. This caused severe physics issues with some specific subs, for example mirrored HSE Kullervo Carriers tended to get launched downwards at a game-breaking speed.
This commit is contained in:
@@ -306,10 +306,13 @@ namespace Barotrauma
|
||||
Rectangle dockedBorders = Borders;
|
||||
dockedBorders.Y -= dockedBorders.Height;
|
||||
|
||||
foreach (Submarine dockedSub in DockedTo)
|
||||
var connectedSubs = GetConnectedSubs();
|
||||
|
||||
foreach (Submarine dockedSub in connectedSubs)
|
||||
{
|
||||
Vector2 diff = dockedSub.Submarine == this ? dockedSub.WorldPosition : dockedSub.WorldPosition - WorldPosition;
|
||||
|
||||
if (dockedSub == this) continue;
|
||||
|
||||
Vector2 diff = dockedSub.Submarine == this ? dockedSub.WorldPosition : dockedSub.WorldPosition - WorldPosition;
|
||||
|
||||
Rectangle dockedSubBorders = dockedSub.Borders;
|
||||
dockedSubBorders.Y -= dockedSubBorders.Height;
|
||||
@@ -322,6 +325,29 @@ namespace Barotrauma
|
||||
return dockedBorders;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of all submarines that are connected to this one via docking ports.
|
||||
/// </summary>
|
||||
public List<Submarine> GetConnectedSubs()
|
||||
{
|
||||
List<Submarine> connectedSubs = new List<Submarine>();
|
||||
connectedSubs.Add(this);
|
||||
GetConnectedSubsRecursive(connectedSubs);
|
||||
|
||||
return connectedSubs;
|
||||
}
|
||||
|
||||
private void GetConnectedSubsRecursive(List<Submarine> subs)
|
||||
{
|
||||
foreach (Submarine dockedSub in DockedTo)
|
||||
{
|
||||
if (subs.Contains(dockedSub)) continue;
|
||||
|
||||
subs.Add(dockedSub);
|
||||
dockedSub.GetConnectedSubsRecursive(subs);
|
||||
}
|
||||
}
|
||||
|
||||
public Vector2 FindSpawnPos(Vector2 spawnPos)
|
||||
{
|
||||
Rectangle dockedBorders = GetDockedBorders();
|
||||
|
||||
Reference in New Issue
Block a user