2022-08-31 16:43:15 +02:00
|
|
|
extends Spatial
|
2022-08-25 15:33:44 +02:00
|
|
|
|
|
|
|
onready var is_mouse_over = false
|
2022-08-31 16:43:15 +02:00
|
|
|
onready var mesh = $Mesh
|
2022-08-25 15:33:44 +02:00
|
|
|
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
|
2022-08-31 16:43:15 +02:00
|
|
|
old_material_override = mesh.material_override
|
2022-08-25 15:33:44 +02:00
|
|
|
|
2022-08-31 16:43:15 +02:00
|
|
|
var material = mesh.get_surface_material(0)
|
2022-08-25 15:33:44 +02:00
|
|
|
var cloned_material = material.duplicate()
|
|
|
|
cloned_material.albedo_color = Color (1, 0, 0)
|
2022-08-31 16:43:15 +02:00
|
|
|
mesh.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
|
2022-08-31 16:43:15 +02:00
|
|
|
mesh.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)
|