This commit is contained in:
@@ -3015,6 +3015,7 @@ namespace Barotrauma
|
||||
var selectedLocation = allValidLocations.FirstOrDefault(l =>
|
||||
Vector2.Distance(l.Edge.Point1, l.Edge.Point2) is float edgeLength &&
|
||||
!l.Edge.OutsideLevel &&
|
||||
((l.Edge.Cell1?.IsDestructible ?? false) || (l.Edge.Cell2?.IsDestructible ?? false)) &&
|
||||
requiredAmount <= (int)Math.Floor(edgeLength / ((1.0f - maxResourceOverlap) * prefab.Size.X)));
|
||||
|
||||
|
||||
@@ -3905,7 +3906,7 @@ namespace Barotrauma
|
||||
|
||||
private bool HasEndOutpost()
|
||||
{
|
||||
if (preSelectedStartOutpost != null) { return true; }
|
||||
if (preSelectedEndOutpost != null) { return true; }
|
||||
//don't create an end outpost for locations
|
||||
if (LevelData.Type == LevelData.LevelType.Outpost) { return false; }
|
||||
if (EndLocation != null && !EndLocation.Type.HasOutpost) { return false; }
|
||||
|
||||
@@ -906,11 +906,17 @@ namespace Barotrauma
|
||||
|
||||
public LocationType GetLocationType()
|
||||
{
|
||||
if (IsCriticallyRadiated() && LocationType.Prefabs[Type.ReplaceInRadiation] is { } newLocationType)
|
||||
if (IsCriticallyRadiated() && !Type.ReplaceInRadiation.IsEmpty)
|
||||
{
|
||||
return newLocationType;
|
||||
if (LocationType.Prefabs.TryGet(Type.ReplaceInRadiation, out LocationType newLocationType))
|
||||
{
|
||||
return newLocationType;
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.ThrowError($"Error when trying to get a new location type for an irradiated location - location type \"{newLocationType}\" not found.");
|
||||
}
|
||||
}
|
||||
|
||||
return Type;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Barotrauma
|
||||
private set;
|
||||
}
|
||||
|
||||
public string ReplaceInRadiation { get; }
|
||||
public Identifier ReplaceInRadiation { get; }
|
||||
|
||||
public Sprite Sprite { get; private set; }
|
||||
public Sprite RadiationSprite { get; }
|
||||
@@ -108,7 +108,7 @@ namespace Barotrauma
|
||||
|
||||
HideEntitySubcategories = element.GetAttributeStringArray("hideentitysubcategories", Array.Empty<string>()).ToList();
|
||||
|
||||
ReplaceInRadiation = element.GetAttributeString(nameof(ReplaceInRadiation).ToLower(), "");
|
||||
ReplaceInRadiation = element.GetAttributeIdentifier(nameof(ReplaceInRadiation), Identifier.Empty);
|
||||
|
||||
string teamStr = element.GetAttributeString("outpostteam", "FriendlyNPC");
|
||||
Enum.TryParse(teamStr, out OutpostTeam);
|
||||
|
||||
@@ -560,6 +560,42 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
//make sure the location at the right side of the gate between biomes isn't a dead-end
|
||||
//those may sometimes generate if all the connections of the right-side location lead to the previous biome
|
||||
//(i.e. a situation where the adjacent locations happen to be at the left side of the border of the biomes, see see Regalis11/Barotrauma#10047)
|
||||
for (int i = 0; i < Connections.Count; i++)
|
||||
{
|
||||
var connection = Connections[i];
|
||||
if (!connection.Locked) { continue; }
|
||||
var rightMostLocation =
|
||||
connection.Locations[0].MapPosition.X > connection.Locations[1].MapPosition.X ?
|
||||
connection.Locations[0] :
|
||||
connection.Locations[1];
|
||||
|
||||
//if there's only one connection (= the connection between biomes), create a new connection to the closest location to the right
|
||||
if (rightMostLocation.Connections.Count == 1)
|
||||
{
|
||||
Location closestLocation = null;
|
||||
float closestDist = float.PositiveInfinity;
|
||||
foreach (Location otherLocation in Locations)
|
||||
{
|
||||
if (otherLocation == rightMostLocation || otherLocation.MapPosition.X < rightMostLocation.MapPosition.X) { continue; }
|
||||
float dist = Vector2.DistanceSquared(rightMostLocation.MapPosition, otherLocation.MapPosition);
|
||||
if (dist < closestDist || closestLocation == null)
|
||||
{
|
||||
closestLocation = otherLocation;
|
||||
closestDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
var newConnection = new LocationConnection(rightMostLocation, closestLocation);
|
||||
rightMostLocation.Connections.Add(newConnection);
|
||||
closestLocation.Connections.Add(newConnection);
|
||||
Connections.Add(newConnection);
|
||||
GenerateLocationConnectionVisuals(newConnection);
|
||||
}
|
||||
}
|
||||
|
||||
//remove orphans
|
||||
Locations.RemoveAll(l => !Connections.Any(c => c.Locations.Contains(l)));
|
||||
|
||||
@@ -606,7 +642,9 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
partial void GenerateLocationConnectionVisuals();
|
||||
partial void GenerateAllLocationConnectionVisuals();
|
||||
|
||||
partial void GenerateLocationConnectionVisuals(LocationConnection connection);
|
||||
|
||||
private int GetZoneIndex(float xPos)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user