2024-09-09 17:46:51 +00:00
|
|
|
extends TileMap
|
|
|
|
|
|
|
|
var GridSize = 16
|
|
|
|
var Dic = {}
|
2024-09-09 17:55:23 +00:00
|
|
|
var Building_Mode: bool = false
|
2024-09-09 17:46:51 +00:00
|
|
|
|
|
|
|
func _ready():
|
|
|
|
for x in GridSize:
|
|
|
|
for y in GridSize:
|
|
|
|
Dic[str(Vector2(x,y))] = {
|
2024-09-09 17:55:23 +00:00
|
|
|
#"Type": "Ground",
|
2024-09-09 17:46:51 +00:00
|
|
|
"Placed": false
|
|
|
|
}
|
|
|
|
set_cell(0, Vector2(x, y), 0, Vector2i(0,0), 0)
|
|
|
|
|
|
|
|
func _process(delta):
|
2024-09-09 17:55:23 +00:00
|
|
|
if (Input.is_action_just_pressed("rclick")):
|
|
|
|
Building_Mode = !Building_Mode
|
|
|
|
for x in GridSize:
|
|
|
|
for y in GridSize:
|
|
|
|
if !Dic[str(Vector2(x,y))].get("Placed"):
|
|
|
|
erase_cell(1, Vector2(x,y))
|
2024-09-09 17:46:51 +00:00
|
|
|
|
2024-09-09 17:55:23 +00:00
|
|
|
if Building_Mode:
|
|
|
|
var tile = local_to_map(get_global_mouse_position())
|
|
|
|
|
|
|
|
for x in GridSize:
|
|
|
|
for y in GridSize:
|
|
|
|
if !Dic[str(Vector2(x,y))].get("Placed"):
|
|
|
|
erase_cell(1, Vector2(x,y))
|
|
|
|
|
|
|
|
if Dic.has(str(tile)):
|
|
|
|
set_cell(1, tile, 1, Vector2i(0,0), 0)
|
2024-09-09 17:46:51 +00:00
|
|
|
|
2024-09-09 17:55:23 +00:00
|
|
|
if Input.is_action_just_pressed("lclick"):
|
|
|
|
Dic[str(tile)]["Placed"] = true
|
|
|
|
|
|
|
|
|
|
|
|
func _on_mouse_handler_clicked():
|
|
|
|
pass # Replace with function body.
|
|
|
|
|
|
|
|
|
|
|
|
func _on_mouse_handler_rclicked():
|
|
|
|
pass # Replace with function body.
|