diff --git a/src/RustToDust.Core/TerrainField.cs b/src/RustToDust.Core/TerrainField.cs index e21383b..8dc8f68 100644 --- a/src/RustToDust.Core/TerrainField.cs +++ b/src/RustToDust.Core/TerrainField.cs @@ -136,21 +136,17 @@ namespace RustToDust.Core Dynamic: false)); } - // 3. Sweeping desert dune ridges (~20 ridges + 2 dry-wash troughs), kept clear of cover boxes & center plaza + // 3. Sweeping desert dune ridges (~20 ridges + 2 dry-wash troughs), kept clear of cover box pads int duneCount = 0; int attempts = 0; - while (duneCount < 20 && attempts < 300) + while (duneCount < 20 && attempts < 360) { attempts++; - float x = (float)(rng.NextDouble() * 320.0 - 160.0); - float z = (float)(rng.NextDouble() * 320.0 - 160.0); - float radiusX = 14f + (float)rng.NextDouble() * 12f; - float radiusZ = 26f + (float)rng.NextDouble() * 24f; + float x = (float)(rng.NextDouble() * 300.0 - 150.0); + float z = (float)(rng.NextDouble() * 300.0 - 150.0); + float radiusX = 12f + (float)rng.NextDouble() * 11f; + float radiusZ = 24f + (float)rng.NextDouble() * 22f; - if (OverlapsProtectedPads(x, z, MathF.Max(radiusX, radiusZ) * 0.95f, coverBoxes)) - { - continue; - } if (MathF.Abs(field.SampleHeight(x, z)) > 1.8f) { continue; @@ -162,7 +158,7 @@ namespace RustToDust.Core : 1.6f + (float)rng.NextDouble() * 2.0f; float rot = (float)(rng.NextDouble() * MathF.PI); - field.AddBrush(new TerrainBrush( + var candidate = new TerrainBrush( Id: 0, Kind: TerrainBrushKind.DuneRidge, X: x, @@ -176,14 +172,21 @@ namespace RustToDust.Core AlbedoR: dryWash ? 0.58f : 0.78f, AlbedoG: dryWash ? 0.41f : 0.56f, AlbedoB: dryWash ? 0.27f : 0.34f, - Dynamic: false)); + Dynamic: false); + + if (!IsBrushClearOfCover(in candidate, coverBoxes)) + { + continue; + } + + field.AddBrush(candidate); duneCount++; } // 4. Terraced rust-mesa hills (~7 mesas), mainly mid/outer desert away from spawns & cover int mesaCount = 0; attempts = 0; - while (mesaCount < 7 && attempts < 160) + while (mesaCount < 7 && attempts < 200) { attempts++; float angle = (float)(rng.NextDouble() * MathF.Tau); @@ -193,14 +196,13 @@ namespace RustToDust.Core float rx = 14f + (float)rng.NextDouble() * 10f; float rz = 13f + (float)rng.NextDouble() * 10f; - if (OverlapsProtectedPads(x, z, MathF.Max(rx, rz) + 6f, coverBoxes) || - OverlapsSpawnRing(x, z, MathF.Max(rx, rz) + 5f) || + if (OverlapsSpawnRing(x, z, MathF.Max(rx, rz) + 5f) || MathF.Abs(field.SampleHeight(x, z)) > 1.6f) { continue; } - field.AddBrush(new TerrainBrush( + var candidate = new TerrainBrush( Id: 0, Kind: TerrainBrushKind.Mesa, X: x, @@ -214,7 +216,14 @@ namespace RustToDust.Core AlbedoR: 0.48f, AlbedoG: 0.25f, AlbedoB: 0.17f, - Dynamic: false)); + Dynamic: false); + + if (!IsBrushClearOfCover(in candidate, coverBoxes)) + { + continue; + } + + field.AddBrush(candidate); mesaCount++; } @@ -538,26 +547,22 @@ namespace RustToDust.Core tz = Math.Clamp((int)MathF.Floor(nz), 0, TileGridCount - 1); } - private static bool OverlapsProtectedPads(float x, float z, float radius, IReadOnlyList coverBoxes) + private static bool IsBrushClearOfCover(in TerrainBrush candidate, IReadOnlyList coverBoxes) { - // Keep center plaza clear - if (x * x + z * z < (radius + 20f) * (radius + 20f)) + if (MathF.Abs(EvaluateBrushHeight(in candidate, 0f, 0f)) > 0.35f) { - return true; + return false; } for (int i = 0; i < coverBoxes.Count; i++) { var c = coverBoxes[i]; - float dx = x - c.X; - float dz = z - c.Z; - float minDist = radius + MathF.Max(c.HalfX, c.HalfZ) + 9f; - if (dx * dx + dz * dz < minDist * minDist) + if (MathF.Abs(EvaluateBrushHeight(in candidate, c.X, c.Z)) > 0.35f) { - return true; + return false; } } - return false; + return true; } private static bool OverlapsSpawnRing(float x, float z, float radius)