Build 0.21.6.0 (1.0 pre-patch)

This commit is contained in:
Regalis11
2023-01-31 18:08:26 +02:00
parent e1c04bc31d
commit cf9ecd35b3
231 changed files with 4479 additions and 2276 deletions
@@ -860,6 +860,7 @@ namespace Barotrauma
(endPath != null && GetDistToTunnel(cell.Center, endPath) < minMainPathWidth) ||
(endHole != null && GetDistToTunnel(cell.Center, endHole) < minMainPathWidth)) { continue; }
if (cell.Edges.Any(e => e.AdjacentCell(cell)?.CellType != CellType.Path || e.NextToCave)) { continue; }
if (PositionsOfInterest.Any(p => cell.IsPointInside(p.Position.ToVector2()))) { continue; }
potentialIslands.Add(cell);
}
for (int i = 0; i < GenerationParams.IslandCount; i++)
@@ -1099,6 +1100,7 @@ namespace Barotrauma
caveCells.AddRange(cave.Tunnels.SelectMany(t => t.Cells));
foreach (var caveCell in caveCells)
{
if (PositionsOfInterest.Any(p => caveCell.IsPointInside(p.Position.ToVector2()))) { continue; }
if (Rand.Range(0.0f, 1.0f, Rand.RandSync.ServerAndClient) < destructibleWallRatio * cave.CaveGenerationParams.DestructibleWallRatio)
{
var chunk = CreateIceChunk(caveCell.Edges, caveCell.Center, health: 50.0f);
@@ -3176,7 +3178,7 @@ namespace Barotrauma
TryGetInterestingPosition(true, spawnPosType, minDistFromSubs, out Vector2 startPos, filter);
Vector2 offset = Rand.Vector(Rand.Range(0.0f, randomSpread, Rand.RandSync.ServerAndClient), Rand.RandSync.ServerAndClient);
if (!cells.Any(c => c.IsPointInside(startPos + offset)))
if (!IsPositionInsideWall(startPos + offset))
{
startPos += offset;
}
@@ -3232,10 +3234,9 @@ namespace Barotrauma
{
suitablePositions.RemoveAll(p => !filter(p));
}
//avoid floating ice chunks on the main path
if (positionType.HasFlag(PositionType.MainPath) || positionType.HasFlag(PositionType.SidePath))
{
suitablePositions.RemoveAll(p => ExtraWalls.Any(w => w.Cells.Any(c => c.IsPointInside(p.Position.ToVector2()))));
suitablePositions.RemoveAll(p => IsPositionInsideWall(p.Position.ToVector2()));
}
if (!suitablePositions.Any())
{
@@ -3288,10 +3289,16 @@ namespace Barotrauma
return false;
}
position = farEnoughPositions[Rand.Int(farEnoughPositions.Count, (useSyncedRand ? Rand.RandSync.ServerAndClient : Rand.RandSync.Unsynced))].Position;
position = farEnoughPositions[Rand.Int(farEnoughPositions.Count, useSyncedRand ? Rand.RandSync.ServerAndClient : Rand.RandSync.Unsynced)].Position;
return true;
}
public bool IsPositionInsideWall(Vector2 worldPosition)
{
var closestCell = GetClosestCell(worldPosition);
return closestCell != null && closestCell.IsPointInside(worldPosition);
}
public void Update(float deltaTime, Camera cam)
{
LevelObjectManager.Update(deltaTime);
@@ -3334,14 +3341,13 @@ namespace Barotrauma
public Vector2 GetBottomPosition(float xPosition)
{
int index = (int)Math.Floor(xPosition / Size.X * (bottomPositions.Count - 1));
float interval = Size.X / (bottomPositions.Count - 1);
int index = (int)Math.Floor(xPosition / interval);
if (index < 0 || index >= bottomPositions.Count - 1) { return new Vector2(xPosition, BottomPos); }
float t = (xPosition - bottomPositions[index].X) / (bottomPositions[index + 1].X - bottomPositions[index].X);
//t can go slightly outside the 0-1 due to rounding, safe to ignore
Debug.Assert(t <= 1.001f && t >= -0.001f);
float t = (xPosition - bottomPositions[index].X) / interval;
t = MathHelper.Clamp(t, 0.0f, 1.0f);
float yPos = MathHelper.Lerp(bottomPositions[index].Y, bottomPositions[index + 1].Y, t);
return new Vector2(xPosition, yPos);
@@ -112,10 +112,9 @@ namespace Barotrauma
(int)MathUtils.Round(generationParams.Height, Level.GridCellSize));
}
public LevelData(XElement element, float? forceDifficulty = null)
public LevelData(XElement element, float? forceDifficulty = null, bool clampDifficultyToBiome = false)
{
Seed = element.GetAttributeString("seed", "");
Difficulty = forceDifficulty ?? element.GetAttributeFloat("difficulty", 0.0f);
Size = element.GetAttributePoint("size", new Point(1000));
Enum.TryParse(element.GetAttributeString("type", "LocationConnection"), out Type);
@@ -131,10 +130,7 @@ namespace Barotrauma
{
DebugConsole.ThrowError($"Error while loading a level. Could not find level generation params with the ID \"{generationParamsId}\".");
GenerationParams = LevelGenerationParams.LevelParams.FirstOrDefault(l => l.Type == Type);
if (GenerationParams == null)
{
GenerationParams = LevelGenerationParams.LevelParams.First();
}
GenerationParams ??= LevelGenerationParams.LevelParams.First();
}
InitialDepth = element.GetAttributeInt("initialdepth", GenerationParams.InitialDepthMin);
@@ -147,10 +143,16 @@ namespace Barotrauma
Biome = Biome.Prefabs.First();
}
string[] prefabNames = element.GetAttributeStringArray("eventhistory", new string[] { });
Difficulty = forceDifficulty ?? element.GetAttributeFloat("difficulty", 0.0f);
if (clampDifficultyToBiome)
{
Difficulty = MathHelper.Clamp(Difficulty, Biome.MinDifficulty, Biome.AdjustedMaxDifficulty);
}
string[] prefabNames = element.GetAttributeStringArray("eventhistory", Array.Empty<string>());
EventHistory.AddRange(EventPrefab.Prefabs.Where(p => prefabNames.Any(n => p.Identifier == n)));
string[] nonRepeatablePrefabNames = element.GetAttributeStringArray("nonrepeatableevents", new string[] { });
string[] nonRepeatablePrefabNames = element.GetAttributeStringArray("nonrepeatableevents", Array.Empty<string>());
NonRepeatableEvents.AddRange(EventPrefab.Prefabs.Where(p => nonRepeatablePrefabNames.Any(n => p.Identifier == n)));
EventsExhausted = element.GetAttributeBool(nameof(EventsExhausted).ToLower(), false);