Faction Test v1.0.1.0

This commit is contained in:
Regalis11
2023-02-16 15:01:28 +02:00
parent caa5a2f762
commit 2c5a7923b0
309 changed files with 7502 additions and 4335 deletions
@@ -1700,14 +1700,22 @@ namespace Barotrauma
foreach (VoronoiCell cell in closeCells)
{
bool tooClose = false;
foreach (GraphEdge edge in cell.Edges)
{
if (Vector2.DistanceSquared(edge.Point1, position) < minDistSqr ||
Vector2.DistanceSquared(edge.Point2, position) < minDistSqr ||
MathUtils.LineSegmentToPointDistanceSquared(edge.Point1.ToPoint(), edge.Point2.ToPoint(), position.ToPoint()) < minDistSqr)
if (cell.IsPointInsideAABB(position, margin: minDistance))
{
tooClose = true;
}
else
{
foreach (GraphEdge edge in cell.Edges)
{
tooClose = true;
break;
if (Vector2.DistanceSquared(edge.Point1, position) < minDistSqr ||
Vector2.DistanceSquared(edge.Point2, position) < minDistSqr ||
MathUtils.LineSegmentToPointDistanceSquared(edge.Point1.ToPoint(), edge.Point2.ToPoint(), position.ToPoint()) < minDistSqr)
{
tooClose = true;
break;
}
}
}
if (tooClose) { tooCloseCells.Add(cell); }
@@ -3247,7 +3255,8 @@ namespace Barotrauma
{
suitablePositions.RemoveAll(p => !filter(p));
}
if (positionType.HasFlag(PositionType.MainPath) || positionType.HasFlag(PositionType.SidePath))
if (positionType.HasFlag(PositionType.MainPath) || positionType.HasFlag(PositionType.SidePath) || positionType.HasFlag(PositionType.Abyss) ||
positionType.HasFlag(PositionType.Cave) || positionType.HasFlag(PositionType.AbyssCave))
{
suitablePositions.RemoveAll(p => IsPositionInsideWall(p.Position.ToVector2()));
}
@@ -3412,8 +3421,7 @@ namespace Barotrauma
bool closeEnough = false;
foreach (VoronoiCell cell in wall.Cells)
{
if (Math.Abs(cell.Center.X - worldPos.X) < (searchDepth + 1) * GridCellSize &&
Math.Abs(cell.Center.Y - worldPos.Y) < (searchDepth + 1) * GridCellSize)
if (cell.IsPointInsideAABB(worldPos, margin: (searchDepth + 1) * GridCellSize / 2))
{
closeEnough = true;
break;
@@ -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,6 +143,12 @@ namespace Barotrauma
Biome = Biome.Prefabs.First();
}
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)).Select(p => p.Identifier));
@@ -67,7 +67,7 @@ namespace Barotrauma
set;
}
[Serialize(1.0f, IsPropertySaveable.Yes, "If there are multiple level generation parameters available for a level in a given biome, their commonness determines how likely it is for one to get selected."), Editable(MinValueFloat = 0, MaxValueFloat = 100)]
[Serialize(100.0f, IsPropertySaveable.Yes, "If there are multiple level generation parameters available for a level in a given biome, their commonness determines how likely it is for one to get selected."), Editable(MinValueFloat = 0, MaxValueFloat = 100)]
public float Commonness
{
get;