Enhance vault scene functionality and user interaction. Updated control instructions for room selection, implemented mode switching for building and demolishing, and refined input handling for mouse events. Added visual selection feedback for rooms and improved ghost placement logic. Updated HUD interactions to reflect new selection mechanics.
This commit is contained in:
@@ -24,6 +24,7 @@ const EMPTY_FILL := Color("#ffffff", 0.02)
|
||||
const EMPTY_LINE := Color("#ffffff", 0.06)
|
||||
const GHOST_OK := Color("#2ee6c5")
|
||||
const GHOST_BAD := Color("#f2704a")
|
||||
const SELECTION := Color("#ffffff")
|
||||
|
||||
const MARGIN := 1200.0
|
||||
const SKY_HEIGHT := 900.0
|
||||
@@ -36,6 +37,8 @@ var grid: VaultGrid
|
||||
var _ghost_kind := ""
|
||||
var _ghost_cell := Vector2i(-1, -1)
|
||||
var _demolish := false
|
||||
## Якорная ячейка выделенной комнаты; (-1, -1) — ничего не выделено.
|
||||
var _selected_cell := Vector2i(-1, -1)
|
||||
var _pebbles: Array[Dictionary] = []
|
||||
|
||||
|
||||
@@ -54,6 +57,15 @@ func set_ghost(kind: String, cell: Vector2i, demolish: bool) -> void:
|
||||
queue_redraw()
|
||||
|
||||
|
||||
## Выделенная комната задаётся ячейкой, а не индексом: индексы съезжают
|
||||
## при сносе, а ячейка остаётся собой.
|
||||
func set_selection(cell: Vector2i) -> void:
|
||||
if cell == _selected_cell:
|
||||
return
|
||||
_selected_cell = cell
|
||||
queue_redraw()
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
if grid == null:
|
||||
return
|
||||
@@ -65,6 +77,7 @@ func _draw() -> void:
|
||||
_draw_floor_numbers()
|
||||
for room: Dictionary in grid.rooms:
|
||||
_draw_room(room)
|
||||
_draw_selection()
|
||||
_draw_ghost()
|
||||
|
||||
|
||||
@@ -216,7 +229,34 @@ func _draw_equipment(inner: Rect2, accent: Color, width: int) -> void:
|
||||
draw_rect(Rect2(machine.position + Vector2(6.0, 6.0), Vector2(22.0, 4.0)), glow)
|
||||
|
||||
|
||||
# --- Строительство ----------------------------------------------------------
|
||||
# --- Выделение и строительство ----------------------------------------------
|
||||
|
||||
## Рамка с уголками вокруг выбранной комнаты. Уголки нужны, чтобы выделение
|
||||
## читалось поверх любой заливки — тонкой линии на пёстром фоне мало.
|
||||
func _draw_selection() -> void:
|
||||
if _selected_cell.x < 0:
|
||||
return
|
||||
var index := grid.room_index_at(_selected_cell.y, _selected_cell.x)
|
||||
if index < 0:
|
||||
return
|
||||
|
||||
var rect := VaultGrid.room_rect(grid.rooms[index]).grow(-2.0)
|
||||
draw_rect(rect, Color(SELECTION, 0.08))
|
||||
draw_rect(rect, Color(SELECTION, 0.75), false, 2.0)
|
||||
|
||||
var arm := 20.0
|
||||
var corners := [
|
||||
[rect.position, Vector2(1.0, 1.0)],
|
||||
[Vector2(rect.end.x, rect.position.y), Vector2(-1.0, 1.0)],
|
||||
[rect.end, Vector2(-1.0, -1.0)],
|
||||
[Vector2(rect.position.x, rect.end.y), Vector2(1.0, -1.0)],
|
||||
]
|
||||
for entry: Array in corners:
|
||||
var point: Vector2 = entry[0]
|
||||
var direction: Vector2 = entry[1]
|
||||
draw_line(point, point + Vector2(arm * direction.x, 0.0), SELECTION, 4.0)
|
||||
draw_line(point, point + Vector2(0.0, arm * direction.y), SELECTION, 4.0)
|
||||
|
||||
|
||||
func _draw_ghost() -> void:
|
||||
if _ghost_cell.x < 0:
|
||||
|
||||
Reference in New Issue
Block a user