Refine wall resolver to reduce corner misclassification
- Require cardinal floor adjacency for wall-cell eligibility (remove diagonal-only wall placements) - Limit 8-direction priority override to corner/diagonal buckets only - Keep cardinal-first flow while preventing broad bucket overreach on corner candidates
This commit is contained in:
@@ -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<int> { 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<string> 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;
|
||||
|
||||
Reference in New Issue
Block a user