extends Button


#@onready var tile_mesh_instance = $"SubViewportContainer/SubViewport/MeshInstance3D"
@onready var select_outline = $"select_outline"
@onready var sub_viewport = $"SubViewportContainer/SubViewport"

var element_class
var element_type
var element_scene

signal element_selected(element_type, button, element_class)

func set_element(_element_type):
	sub_viewport.add_child(_element_type)
	element_scene = sub_viewport.get_child(0)


func set_element_material(material, slot):
	element_scene.set_element_material(material, slot)


func _on_pressed():
	emit_signal("element_selected", element_type, self, element_class)


func _ready():
	set_as_selected(false)


func set_as_selected(value):
	select_outline.visible = value
	return self
