Refactor vault camera and grid logic for improved zoom and positioning. Adjusted zoom step value, refined camera limits based on vault structure, and updated grid depth calculations. Enhanced drawing functions in vault view to include entrance visualization and corrected depth handling for pebbles and dirt rendering.
This commit is contained in:
@@ -5,7 +5,7 @@ extends Camera2D
|
||||
## Границы задаются встроенными limit_* по размеру убежища, поэтому вручную
|
||||
## позицию не зажимаем — движок делает это сам.
|
||||
|
||||
const ZOOM_STEP := 1.12
|
||||
const ZOOM_STEP := 1.2
|
||||
const MIN_ZOOM := 0.45
|
||||
const MAX_ZOOM := 2.2
|
||||
const KEY_PAN_SPEED := 900.0
|
||||
@@ -18,9 +18,12 @@ func _ready() -> void:
|
||||
var bounds := VaultGrid.bounds()
|
||||
limit_left = int(bounds.position.x - EDGE_MARGIN)
|
||||
limit_right = int(bounds.end.x + EDGE_MARGIN)
|
||||
limit_top = int(bounds.position.y - EDGE_MARGIN)
|
||||
# Сверху отмеряем от поверхности, а не от бункера: над землёй стоит будка
|
||||
# входа, и до неё нужно доезжать.
|
||||
limit_top = int(-EDGE_MARGIN)
|
||||
limit_bottom = int(bounds.end.y + EDGE_MARGIN)
|
||||
position = bounds.get_center()
|
||||
# Открываемся на верхних этажах — оттуда видно и вход, и застройку.
|
||||
position = Vector2(bounds.get_center().x, bounds.position.y + VaultGrid.CELL.y)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
@@ -39,11 +42,15 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
|
||||
func _handle_mouse_button(event: InputEventMouseButton) -> void:
|
||||
match event.button_index:
|
||||
# На один щелчок колеса Godot шлёт и нажатие, и отпускание. Без
|
||||
# проверки pressed шаг зума применялся бы дважды.
|
||||
MOUSE_BUTTON_WHEEL_UP:
|
||||
_zoom_by(ZOOM_STEP)
|
||||
if event.pressed:
|
||||
_zoom_by(ZOOM_STEP)
|
||||
get_viewport().set_input_as_handled()
|
||||
MOUSE_BUTTON_WHEEL_DOWN:
|
||||
_zoom_by(1.0 / ZOOM_STEP)
|
||||
if event.pressed:
|
||||
_zoom_by(1.0 / ZOOM_STEP)
|
||||
get_viewport().set_input_as_handled()
|
||||
MOUSE_BUTTON_RIGHT, MOUSE_BUTTON_MIDDLE:
|
||||
# Правая и средняя кнопки таскают вид; левая остаётся строительству.
|
||||
|
||||
Reference in New Issue
Block a user