Dungeon simulation changes
This commit is contained in:
@@ -71,7 +71,11 @@ public class DungeonGeneratorV2
|
||||
|
||||
// Always place entrance first
|
||||
var entrance = await PlaceRoomAsync(layout, rooms, RoomType.Entrance, 5, 5);
|
||||
if (entrance != null) rooms.Add(entrance);
|
||||
if (entrance != null)
|
||||
{
|
||||
rooms.Add(entrance);
|
||||
Console.WriteLine($"[DungeonGenV2] Placed entrance room: {entrance.TemplateName ?? "fallback"} at ({entrance.X},{entrance.Y})");
|
||||
}
|
||||
|
||||
// Place other rooms
|
||||
while (rooms.Count < roomCount && attempts < maxAttempts)
|
||||
@@ -92,9 +96,12 @@ public class DungeonGeneratorV2
|
||||
if (newRoom != null)
|
||||
{
|
||||
rooms.Add(newRoom);
|
||||
Console.WriteLine($"[DungeonGenV2] Placed {type} room: {newRoom.TemplateName ?? "fallback"} at ({newRoom.X},{newRoom.Y})");
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine($"[DungeonGenV2] Placed {rooms.Count}/{roomCount} rooms after {attempts} attempts");
|
||||
|
||||
// Ensure we have an exit/boss room
|
||||
var bossRoom = rooms.FirstOrDefault(r => r.Type == RoomType.Boss);
|
||||
if (bossRoom == null && rooms.Count > 1)
|
||||
@@ -107,14 +114,17 @@ public class DungeonGeneratorV2
|
||||
var entranceRoom = rooms.FirstOrDefault(r => r.Type == RoomType.Entrance) ?? rooms[0];
|
||||
rooms = rooms.OrderBy(r => Distance(entranceRoom, r)).ToList();
|
||||
|
||||
// Connect rooms with corridors
|
||||
// Connect rooms with corridors - entrance MUST be connected
|
||||
var connected = new HashSet<int> { 0 };
|
||||
Console.WriteLine($"[DungeonGenV2] Connecting {rooms.Count} rooms...");
|
||||
|
||||
for (int i = 1; i < rooms.Count; i++)
|
||||
{
|
||||
// Find closest connected room
|
||||
int closestIdx = connected.OrderBy(c => Distance(rooms[c], rooms[i])).First();
|
||||
await ConnectRoomsAsync(layout, rooms[closestIdx], rooms[i]);
|
||||
connected.Add(i);
|
||||
Console.WriteLine($"[DungeonGenV2] Connected room {i} ({rooms[i].Type}) to room {closestIdx}");
|
||||
}
|
||||
|
||||
// Add some extra connections for loops
|
||||
|
||||
Reference in New Issue
Block a user