2022-08-25 15:33:44 +02:00
|
|
|
extends MeshInstance
|
|
|
|
|
|
|
|
onready var is_mouse_over = false
|
|
|
|
var old_material_override = Material.new()
|
|
|
|
|
2022-08-25 17:06:26 +02:00
|
|
|
signal tile_selected
|
2022-08-25 23:40:19 +02:00
|
|
|
signal tile_mouse_entered
|
|
|
|
|
2022-08-25 17:06:26 +02:00
|
|
|
|
2022-08-25 15:33:44 +02:00
|
|
|
func _on_Area_mouse_entered():
|
|
|
|
is_mouse_over = true
|
|
|
|
old_material_override = material_override
|
|
|
|
|
|
|
|
var material = self.get_surface_material(0)
|
|
|
|
var cloned_material = material.duplicate()
|
|
|
|
cloned_material.albedo_color = Color (1, 0, 0)
|
|
|
|
self.material_override = cloned_material
|
2022-08-25 23:40:19 +02:00
|
|
|
emit_signal("tile_mouse_entered", self)
|
2022-08-25 15:33:44 +02:00
|
|
|
|
2022-08-25 17:06:26 +02:00
|
|
|
|
2022-08-25 15:33:44 +02:00
|
|
|
func _on_Area_mouse_exited():
|
|
|
|
is_mouse_over = false
|
|
|
|
self.material_override = old_material_override
|
2022-08-25 17:06:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
func _on_Area_input_event(camera, event, position, normal, shape_idx):
|
|
|
|
if is_mouse_over and event is InputEventMouseButton:
|
|
|
|
if event.button_index == 1 and event.pressed:
|
|
|
|
emit_signal("tile_selected", self)
|