extends Spatial class_name HexTile3D onready var is_mouse_over = false onready var mesh = $Mesh var old_material_override = Material.new() signal tile_selected signal tile_mouse_entered #var cube_coords = Vector3(0, 0, 0) setget set_cube_coords, get_cube_coords func set_tiletype(type): var GameTile = load("res://utils/GameTile.gd").new() var mesh = $Mesh if type == GameTile.TileType.Sand: mesh.set_surface_material(0, preload("res://materials/SandTile.tres")) elif type == GameTile.TileType.Grass: mesh.set_surface_material(0, preload("res://materials/GrassTile.tres")) else: mesh.set_surface_material(0, preload("res://materials/DeepGrassTile.tres")) func _on_Area_mouse_entered(): is_mouse_over = true old_material_override = mesh.material_override var material = mesh.get_surface_material(0) var cloned_material = material.duplicate() cloned_material.albedo_color = Color (1, 0, 0) mesh.material_override = cloned_material emit_signal("tile_mouse_entered", self) func _on_Area_mouse_exited(): is_mouse_over = false mesh.material_override = old_material_override 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)