diff --git a/Game/Dungeon/DungeonGeneratorVNext.cs b/Game/Dungeon/DungeonGeneratorVNext.cs index 9a9776d..3582374 100644 --- a/Game/Dungeon/DungeonGeneratorVNext.cs +++ b/Game/Dungeon/DungeonGeneratorVNext.cs @@ -523,7 +523,7 @@ public class DungeonGeneratorVNext for (int x = 0; x < layout.Width; x++) { if (layout.Walkable![x, y]) continue; - if (!HasAdjacentWalkable(layout, x, y)) continue; + if (!HasAdjacentCardinalWalkable(layout, x, y)) continue; wallCells.Add((x, y)); } } @@ -546,6 +546,7 @@ public class DungeonGeneratorVNext int mask8 = ComputeEightDirectionMask(layout, cell.X, cell.Y); string? specific8Bucket = ResolveEightDirectionBucketName(mask8); if (!string.IsNullOrEmpty(specific8Bucket) && + CornerPriorityEightBuckets.Contains(specific8Bucket) && tileContext.WallDefinitionsByCanonicalBucket.TryGetValue(specific8Bucket, out var defs8) && defs8.Count > 0) { @@ -798,21 +799,12 @@ public class DungeonGeneratorVNext }); } - private static bool HasAdjacentWalkable(DungeonLayoutV2 layout, int x, int y) + private static bool HasAdjacentCardinalWalkable(DungeonLayoutV2 layout, int x, int y) { - for (int oy = -1; oy <= 1; oy++) - { - for (int ox = -1; ox <= 1; ox++) - { - if (ox == 0 && oy == 0) continue; - int nx = x + ox; - int ny = y + oy; - if (nx < 0 || ny < 0 || nx >= layout.Width || ny >= layout.Height) continue; - if (layout.Walkable![nx, ny]) return true; - } - } - - return false; + return IsWalkable(layout, x, y - 1) || + IsWalkable(layout, x + 1, y) || + IsWalkable(layout, x, y + 1) || + IsWalkable(layout, x - 1, y); } private static int ComputeCardinalMask(DungeonLayoutV2 layout, int x, int y) @@ -917,6 +909,16 @@ public class DungeonGeneratorVNext new("WallFullEightDirections", new HashSet { 20, 228, 147, 116, 23, 22, 52, 21, 84, 18, 36, 19, 100, 151, 244, 150, 180, 229, 211, 245, 215, 117, 87, 101, 83, 82, 37, 53, 86, 213, 212, 149 }) }; + private static readonly HashSet CornerPriorityEightBuckets = new(StringComparer.OrdinalIgnoreCase) + { + "WallInnerCornerDownLeft", + "WallInnerCornerDownRight", + "WallDiagonalCornerDownLeft", + "WallDiagonalCornerDownRight", + "WallDiagonalCornerUpLeft", + "WallDiagonalCornerUpRight" + }; + private static float Distance(int x1, int y1, int x2, int y2) { int dx = x2 - x1;