Dungeon Revision6

This commit is contained in:
dingo
2025-12-29 15:02:29 -05:00
parent b156ec23c4
commit bc035c9967
+36 -17
View File
@@ -943,7 +943,7 @@ public class DungeonGeneratorV2
{
if (string.IsNullOrWhiteSpace(t.Tags)) return false;
return t.Tags
.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
.Any(s => s.Equals(tag, StringComparison.OrdinalIgnoreCase));
}
@@ -1018,19 +1018,22 @@ public class DungeonGeneratorV2
// Example: if the interior is to the NW (diagonal floor at NW), use corner_nw.
// If this is an *outside* corner (the two orthogonal sides away from the interior are void),
// prefer a corner variant that includes the "void" tag.
bool voidN = y > 0 && layout.Tiles[x, y - 1] == 0;
bool voidS = y < MapHeight - 1 && layout.Tiles[x, y + 1] == 0;
bool voidE = x < MapWidth - 1 && layout.Tiles[x + 1, y] == 0;
bool voidW = x > 0 && layout.Tiles[x - 1, y] == 0;
bool outsideN = IsOutsideAt(x, y - 1);
bool outsideS = IsOutsideAt(x, y + 1);
bool outsideE = IsOutsideAt(x + 1, y);
bool outsideW = IsOutsideAt(x - 1, y);
if (hasFloorNorth && hasFloorWest)
wallTile = PickCorner("corner_nw", preferVoid: (voidS && voidE));
wallTile = PickCorner("corner_nw", preferVoid: (outsideS && outsideE));
else if (hasFloorNorth && hasFloorEast)
wallTile = PickCorner("corner_ne", preferVoid: (voidS && voidW));
wallTile = PickCorner("corner_ne", preferVoid: (outsideS && outsideW));
else if (hasFloorSouth && hasFloorWest)
wallTile = PickCorner("corner_sw", preferVoid: (voidN && voidE));
wallTile = PickCorner("corner_sw", preferVoid: (outsideN && outsideE));
else if (hasFloorSouth && hasFloorEast)
wallTile = PickCorner("corner_se", preferVoid: (voidN && voidW));
wallTile = PickCorner("corner_se", preferVoid: (outsideN && outsideW));
else if (hasFloorSouth)
wallTile = wallNorth; // Wall is north of floor, so it's a north-facing wall
else if (hasFloorNorth)
@@ -1087,6 +1090,16 @@ public class DungeonGeneratorV2
return _tileDefinitions.TryGetValue(tid, out var td) && td.Type == TileType.Wall;
}
bool IsOutsideAt(int wx, int wy)
{
// "Outside"/"void" in your terminology: a tile that is NOT walkable and NOT a wall.
// This prevents treating floor as "void" while still recognizing unfilled space.
if (wx < 0 || wx >= MapWidth || wy < 0 || wy >= MapHeight) return true; // out of bounds counts as outside
if (layout.IsWalkable(wx, wy)) return false;
return !IsWallAt(wx, wy);
}
void PlaceWall(int wx, int wy, TileDefinition tdef)
{
layout.Tiles[wx, wy] = tdef.Id;
@@ -1139,10 +1152,13 @@ public class DungeonGeneratorV2
// connects the two bordering wall runs (this tileset uses the opposite naming compared to the
// earlier assumption, so NW<->SE and NE<->SW).
// Outside-void corners: if the two orthogonal tiles away from the interior are void, prefer "void" corner variants.
bool vN = layout.Tiles[x, y - 1] == 0;
bool vS = layout.Tiles[x, y + 1] == 0;
bool vE = layout.Tiles[x + 1, y] == 0;
bool vW = layout.Tiles[x - 1, y] == 0;
bool vN = IsOutsideAt(x, y - 1);
bool vS = IsOutsideAt(x, y + 1);
bool vE = IsOutsideAt(x + 1, y);
bool vW = IsOutsideAt(x - 1, y);
if (floorSE && (wallS || wallE)) PlaceWall(x, y, PickCorner("corner_se", preferVoid: (vN && vW)));
else if (floorSW && (wallS || wallW)) PlaceWall(x, y, PickCorner("corner_sw", preferVoid: (vN && vE)));
@@ -1179,10 +1195,13 @@ public class DungeonGeneratorV2
TileDefinition? replace = null;
// Choose connected outer corners using diagonal floor hints.
bool vN2 = layout.Tiles[x, y - 1] == 0;
bool vS2 = layout.Tiles[x, y + 1] == 0;
bool vE2 = layout.Tiles[x + 1, y] == 0;
bool vW2 = layout.Tiles[x - 1, y] == 0;
bool vN2 = IsOutsideAt(x, y - 1);
bool vS2 = IsOutsideAt(x, y + 1);
bool vE2 = IsOutsideAt(x + 1, y);
bool vW2 = IsOutsideAt(x - 1, y);
if (floorSE && !floorS && !floorE) replace = PickCorner("corner_se", preferVoid: (vN2 && vW2));
else if (floorSW && !floorS && !floorW) replace = PickCorner("corner_sw", preferVoid: (vN2 && vE2));