class_name TileMarker extends Node2D ## Outlines the tile under the mouse: green when the figure can reach it, ## red when it is too far away. const REACHABLE_COLOR := Color(0.4, 1.0, 0.4) const UNREACHABLE_COLOR := Color(1.0, 0.4, 0.4) var tile := Vector2i(-1, -1) var in_reach := false ## Moves the outline to `new_tile`. Redraws only when something changed. func show_tile(new_tile: Vector2i, reachable: bool) -> void: if new_tile == tile and reachable == in_reach: return tile = new_tile in_reach = reachable queue_redraw() func _draw() -> void: var size := GridMotion.TILE_SIZE var color := REACHABLE_COLOR if in_reach else UNREACHABLE_COLOR draw_rect(Rect2(Vector2(tile) * size, Vector2(size, size)), color, false, 1.0)