fix: guarantee minimum generated room count

This commit is contained in:
goose
2026-10-02 18:48:19 -04:00
parent 968ff489f9
commit ead07e1a67
2 changed files with 27 additions and 2 deletions
+16 -2
View File
@@ -44,8 +44,22 @@ static func _place_rooms(rng: DeterministicRng) -> Array[RoomState]:
placed = true
break
if not placed:
push_error("FloorGenerator could not place room %d" % room_index)
break
# The fixed 80x50 B2 map always supports this minimum-size fallback.
# Never return a partial layout after exhausting random placement attempts.
return _fallback_rooms()
return rooms
static func _fallback_rooms() -> Array[RoomState]:
var rooms: Array[RoomState] = []
var positions := [
Vector2i(3, 5), Vector2i(20, 5), Vector2i(37, 5), Vector2i(54, 5),
Vector2i(3, 20), Vector2i(20, 20), Vector2i(37, 20), Vector2i(54, 20),
]
for room_index in range(ROOM_COUNT):
rooms.append(RoomStateType.new(
StringName("room_%02d" % room_index),
Rect2i(positions[room_index], ROOM_MIN_SIZE)
))
return rooms
static func _random_room_bounds(rng: DeterministicRng) -> Rect2i: