brackeys-12/BuildingLevel.gd

38 lines
877 B
GDScript3
Raw Normal View History

2024-09-14 22:01:46 +00:00
extends TileMapLayer
@export var building_spots: Array[Vector2i]
var building_data = {}
func _process(delta: float) -> void:
var tile = local_to_map(get_global_mouse_position())
var building_mode = Persister.get_value("building_mode")
for spot in building_spots:
if not building_data.has(spot):
erase_cell(spot)
if not building_mode:
return
if building_spots.has(tile):
2024-09-15 01:27:59 +00:00
set_cell(tile, 0, Vector2i(0,0), 0)
2024-09-14 22:01:46 +00:00
func place_building():
var tile = local_to_map(get_global_mouse_position())
if building_spots.has(tile):
Persister.persist_data("building_mode", false)
building_data[tile] = {
"key": Persister.get_value("building_key"),
}
Persister.persist_data("drag_mode", false)
func show_info_building():
var tile = local_to_map(get_global_mouse_position())
if building_data.has(tile):
Triggerer.trigger("show_info", building_data[tile])