feat: add final floor victory and deep generation scale

This commit is contained in:
goose
2026-10-04 10:32:11 -04:00
parent 6ded0f76ce
commit f65e9026c1
21 changed files with 330 additions and 57 deletions
+20 -2
View File
@@ -25,6 +25,10 @@ var _traps: Dictionary[Vector2i, Dictionary] = {}
var _shrines: Dictionary[Vector2i, Dictionary] = {}
var _quest_boards: Dictionary[Vector2i, Dictionary] = {}
var _ground_items: Dictionary[Vector2i, Array] = {}
# Deep generated floors can be hundreds of rooms wide. Rendering is bounded to
# the camera neighborhood rather than visiting every backing-map cell per draw.
var _viewport_center := Vector2i.ZERO
const VIEWPORT_RADIUS := Vector2i(24, 16)
func get_cell_rect(cell: Vector2i) -> Rect2:
return Rect2(Vector2(cell * TILE_SIZE), Vector2(TILE_SIZE))
@@ -33,6 +37,12 @@ func set_map(new_map: GridMapState) -> void:
map = new_map
queue_redraw()
func set_viewport_center(cell: Vector2i) -> void:
if _viewport_center == cell:
return
_viewport_center = cell
queue_redraw()
func set_visibility(visible_cells: Dictionary[Vector2i, bool], explored_cells: Dictionary[Vector2i, bool]) -> void:
_visible_cells = visible_cells.duplicate()
_explored_cells = explored_cells.duplicate()
@@ -74,8 +84,16 @@ func get_cell_render_color(cell: Vector2i) -> Color:
func _draw() -> void:
if map == null:
return
for y in range(map.size.y):
for x in range(map.size.x):
var first_cell := Vector2i(
maxi(0, _viewport_center.x - VIEWPORT_RADIUS.x),
maxi(0, _viewport_center.y - VIEWPORT_RADIUS.y)
)
var last_cell := Vector2i(
mini(map.size.x - 1, _viewport_center.x + VIEWPORT_RADIUS.x),
mini(map.size.y - 1, _viewport_center.y + VIEWPORT_RADIUS.y)
)
for y in range(first_cell.y, last_cell.y + 1):
for x in range(first_cell.x, last_cell.x + 1):
var cell := Vector2i(x, y)
var tile_rect := get_cell_rect(cell)
var color := get_cell_render_color(cell)