(7ee8dbc11) v0.9.8.0
This commit is contained in:
@@ -310,6 +310,7 @@ namespace Barotrauma
|
||||
if (Submarine.MainSub != null)
|
||||
{
|
||||
Rectangle dockedSubBorders = Submarine.MainSub.GetDockedBorders();
|
||||
dockedSubBorders.Inflate(dockedSubBorders.Size.ToVector2() * 0.05f);
|
||||
minWidth = Math.Max(minWidth, Math.Max(dockedSubBorders.Width, dockedSubBorders.Height));
|
||||
minWidth = Math.Min(minWidth, maxWidth);
|
||||
}
|
||||
@@ -1622,7 +1623,7 @@ namespace Barotrauma
|
||||
EndOutpost = outpost;
|
||||
if (GameMain.GameSession?.EndLocation != null) { outpost.Name = GameMain.GameSession.EndLocation.Name; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsModeStartOutpostCompatible()
|
||||
|
||||
@@ -721,8 +721,10 @@ namespace Barotrauma.RuinGeneration
|
||||
|
||||
//doors create their own gaps, don't create an additional one if there's a door at this
|
||||
bool doorFound = false;
|
||||
foreach (Door door in doors)
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
var door = item.GetComponent<Door>();
|
||||
if (door == null) { continue; }
|
||||
if (Math.Abs(door.Item.WorldPosition.X - gapRect.Value.Center.X) < 5 &&
|
||||
Math.Abs(door.Item.WorldPosition.Y - gapRect.Value.Center.Y) < 5)
|
||||
{
|
||||
|
||||
@@ -105,15 +105,20 @@ namespace Barotrauma
|
||||
{
|
||||
LinkedSubmarine sl = new LinkedSubmarine(mainSub);
|
||||
sl.GenerateWallVertices(element);
|
||||
if (sl.wallVertices.Any())
|
||||
{
|
||||
sl.Rect = new Rectangle(
|
||||
(int)sl.wallVertices.Min(v => v.X + position.X),
|
||||
(int)sl.wallVertices.Max(v => v.Y + position.Y),
|
||||
(int)sl.wallVertices.Max(v => v.X + position.X),
|
||||
(int)sl.wallVertices.Min(v => v.Y + position.Y));
|
||||
|
||||
sl.Rect = new Rectangle(
|
||||
(int)sl.wallVertices.Min(v => v.X + position.X),
|
||||
(int)sl.wallVertices.Max(v => v.Y + position.Y),
|
||||
(int)sl.wallVertices.Max(v => v.X + position.X),
|
||||
(int)sl.wallVertices.Min(v => v.Y + position.Y));
|
||||
|
||||
sl.rect = new Rectangle((int)position.X, (int)position.Y, 1, 1);
|
||||
|
||||
sl.Rect = new Rectangle(sl.rect.X, sl.rect.Y, sl.rect.Width - sl.rect.X, sl.rect.Y - sl.rect.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
sl.Rect = new Rectangle((int)position.X, (int)position.Y, 10, 10);
|
||||
}
|
||||
return sl;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ namespace Barotrauma
|
||||
|
||||
protected string originalName;
|
||||
protected string identifier;
|
||||
protected ContentPackage contentPackage;
|
||||
|
||||
public Sprite sprite;
|
||||
|
||||
|
||||
@@ -77,7 +77,18 @@ namespace Barotrauma
|
||||
|
||||
private SubmarineBody subBody;
|
||||
|
||||
public readonly List<Submarine> DockedTo;
|
||||
public readonly Dictionary<Submarine, DockingPort> ConnectedDockingPorts;
|
||||
public IEnumerable<Submarine> DockedTo
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ConnectedDockingPorts == null) { yield break; }
|
||||
foreach (Submarine sub in ConnectedDockingPorts.Keys)
|
||||
{
|
||||
yield return sub;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Vector2 lastPickedPosition;
|
||||
private static float lastPickedFraction;
|
||||
@@ -442,7 +453,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
DockedTo = new List<Submarine>();
|
||||
ConnectedDockingPorts = new Dictionary<Submarine, DockingPort>();
|
||||
|
||||
FreeID();
|
||||
}
|
||||
@@ -561,27 +572,32 @@ namespace Barotrauma
|
||||
/// <summary>
|
||||
/// Returns a rect that contains the borders of this sub and all subs docked to it
|
||||
/// </summary>
|
||||
public Rectangle GetDockedBorders()
|
||||
public Rectangle GetDockedBorders(List<Submarine> checkd=null)
|
||||
{
|
||||
Rectangle dockedBorders = Borders;
|
||||
dockedBorders.Y -= dockedBorders.Height;
|
||||
if (checkd == null) { checkd = new List<Submarine>(); }
|
||||
checkd.Add(this);
|
||||
|
||||
var connectedSubs = GetConnectedSubs();
|
||||
Rectangle dockedBorders = Borders;
|
||||
|
||||
var connectedSubs = DockedTo.Where(s => !checkd.Contains(s) && !s.IsOutpost).ToList();
|
||||
|
||||
foreach (Submarine dockedSub in connectedSubs)
|
||||
{
|
||||
if (dockedSub == this) continue;
|
||||
//use docking ports instead of world position to determine
|
||||
//borders, as world position will not necessarily match where
|
||||
//the subs are supposed to go
|
||||
Vector2? expectedLocation = CalculateDockOffset(this, dockedSub);
|
||||
if (expectedLocation == null) { continue; }
|
||||
|
||||
Vector2 diff = dockedSub.Submarine == this ? dockedSub.WorldPosition : dockedSub.WorldPosition - WorldPosition;
|
||||
|
||||
Rectangle dockedSubBorders = dockedSub.Borders;
|
||||
dockedSubBorders.Y -= dockedSubBorders.Height;
|
||||
dockedSubBorders.Location += MathUtils.ToPoint(diff);
|
||||
Rectangle dockedSubBorders = dockedSub.GetDockedBorders(checkd);
|
||||
dockedSubBorders.Location += MathUtils.ToPoint(expectedLocation.Value);
|
||||
|
||||
dockedBorders.Y = -dockedBorders.Y;
|
||||
dockedSubBorders.Y = -dockedSubBorders.Y;
|
||||
dockedBorders = Rectangle.Union(dockedBorders, dockedSubBorders);
|
||||
dockedBorders.Y = -dockedBorders.Y;
|
||||
}
|
||||
|
||||
dockedBorders.Y += dockedBorders.Height;
|
||||
return dockedBorders;
|
||||
}
|
||||
|
||||
@@ -1131,25 +1147,37 @@ namespace Barotrauma
|
||||
prevPosition = position;
|
||||
}
|
||||
|
||||
public void SetPosition(Vector2 position)
|
||||
public void SetPosition(Vector2 position, List<Submarine> checkd=null)
|
||||
{
|
||||
if (!MathUtils.IsValid(position)) return;
|
||||
|
||||
|
||||
if (checkd == null) { checkd = new List<Submarine>(); }
|
||||
if (checkd.Contains(this)) { return; }
|
||||
|
||||
checkd.Add(this);
|
||||
|
||||
subBody.SetPosition(position);
|
||||
|
||||
foreach (Submarine sub in loaded)
|
||||
foreach (Submarine dockedSub in DockedTo)
|
||||
{
|
||||
if (sub != this && sub.Submarine == this)
|
||||
{
|
||||
sub.SetPosition(position + sub.WorldPosition);
|
||||
sub.Submarine = null;
|
||||
}
|
||||
Vector2? expectedLocation = CalculateDockOffset(this, dockedSub);
|
||||
if (expectedLocation == null) { continue; }
|
||||
|
||||
dockedSub.SetPosition(position + expectedLocation.Value, checkd);
|
||||
}
|
||||
//Level.Loaded.SetPosition(-position);
|
||||
//prevPosition = position;
|
||||
}
|
||||
|
||||
public static Vector2? CalculateDockOffset(Submarine sub, Submarine dockedSub)
|
||||
{
|
||||
Item myPort = sub.ConnectedDockingPorts.ContainsKey(dockedSub) ? sub.ConnectedDockingPorts[dockedSub].Item : null;
|
||||
if (myPort == null) { return null; }
|
||||
Item theirPort = dockedSub.ConnectedDockingPorts.ContainsKey(sub) ? dockedSub.ConnectedDockingPorts[sub].Item : null;
|
||||
if (theirPort == null) { return null; }
|
||||
return (myPort.Position - sub.HiddenSubPosition) - (theirPort.Position - dockedSub.HiddenSubPosition);
|
||||
}
|
||||
|
||||
public void Translate(Vector2 amount)
|
||||
{
|
||||
if (amount == Vector2.Zero || !MathUtils.IsValid(amount)) return;
|
||||
@@ -1733,7 +1761,7 @@ namespace Barotrauma
|
||||
if (MainSub == this) MainSub = null;
|
||||
if (MainSubs[1] == this) MainSubs[1] = null;
|
||||
|
||||
DockedTo?.Clear();
|
||||
ConnectedDockingPorts?.Clear();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
Reference in New Issue
Block a user