extends Node2D

var debug_areas := false

const ProbeElectricity := preload("res://Actors/Systems/Electricity/ElectricProbe.tscn")

onready var tilemaps := [ $tiles/base, $tiles/cables, $tiles/floor, $tiles/walls ]

onready var pois := $pois

func _ready():
	pass
	# Run autotile conversions and generate occlusions
	#$tiles/walls.run_conversions()

	# Electricity setup
	#make_electric_probes($tiles/cables, "Wire")

# Tileset related functions

func make_electric_probes(tilemap: TileMap, tile_name: String):
	var tile_id := tilemap.tile_set.find_tile_by_name(tile_name)
	for cell in tilemap.get_used_cells_by_id(tile_id):
		var coord := tilemap.map_to_world(cell)
		var probe := ProbeElectricity.instance()
		probe.position = coord
		tilemap.add_child(probe)

func get_pois(type_filter, class_filter) -> Array:
	var filtered := []
	for child in $pois.get_children():
		if type_filter != null and child.poitype != type_filter:
			continue
		if class_filter != null and child.poiclass != class_filter:
			continue
		filtered.append(child)
	return filtered
