v0.10.5.1

This commit is contained in:
Juan Pablo Arce
2020-09-22 11:31:56 -03:00
parent 44032d0ae0
commit 0002ad2c50
343 changed files with 12276 additions and 5023 deletions
@@ -202,16 +202,40 @@ namespace Barotrauma
foreach (var position in availablePositions)
{
Vector2 pos = position.Position.ToVector2();
float dist = Vector2.DistanceSquared(pos, GetReferenceSub().WorldPosition);
Submarine refSub = GetReferenceSub();
float dist = Vector2.DistanceSquared(pos, refSub.WorldPosition);
foreach (Submarine sub in Submarine.Loaded)
{
if (sub.Info.Type != SubmarineType.Player) { continue; }
float minDistToSub = GetMinDistanceToSub(sub);
if (dist > minDistToSub * minDistToSub && dist < closestDist)
if (dist < minDistToSub * minDistToSub) { continue; }
if (closestDist == float.PositiveInfinity)
{
closestDist = dist;
chosenPosition = position;
continue;
}
//chosen position behind the sub -> override with anything that's closer or to the right
if (chosenPosition.Position.X < refSub.WorldPosition.X)
{
if (dist < closestDist || pos.X > refSub.WorldPosition.X)
{
closestDist = dist;
chosenPosition = position;
}
}
//chosen position ahead of the sub -> only override with a position that's also ahead
else if (chosenPosition.Position.X > refSub.WorldPosition.X)
{
if (dist < closestDist && pos.X > refSub.WorldPosition.X)
{
closestDist = dist;
chosenPosition = position;
}
}
}
}
//only found a spawnpos that's very far from the sub, pick one that's closer