summaryrefslogtreecommitdiff
path: root/Game/States/Build/build_grid.gd
blob: 67c962e4ef2ec8b6aacc7e7427279965d74dd3e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
extends Node2D


@onready var camera: Camera = get_viewport().get_camera_2d()


func _ready() -> void:
	camera.zoomed.connect(func(_zoom):
		queue_redraw()
	)


func _draw():
	var area = Client.current_stage.map.get_used_rect()
	var cell_size = Client.current_stage.map.tile_set.tile_size
	var offset = area.position
	for row in range(0, area.size.y + 1):
		draw_line(
			Vector2(offset.x * cell_size.x, offset.y * cell_size.y + row * cell_size.y),
			Vector2(offset.x * cell_size.x + area.size.x * cell_size.x, offset.y * cell_size.y + row * cell_size.y),
			Color(1, 1, 1, 0.25),
			1.0 / camera.zoom.x
		)
	for column in range(0, area.size.x + 1):
		draw_line(
			Vector2(offset.x * cell_size.x + column * cell_size.x, offset.y * cell_size.y),
			Vector2(offset.x * cell_size.x + column * cell_size.x, offset.y * cell_size.y + area.size.y * cell_size.y),
			Color(1, 1, 1, 0.25),
			1.0 / camera.zoom.x
		)