Files
idle/core/prestige/prestige_buff_connection_overlay.gd
2026-05-06 23:37:52 +02:00

45 lines
1.4 KiB
GDScript

## Draws bezier curves between connected PrestigeBuffGraphTile nodes in the graph panel.
## Store pairs of tile references before calling queue_redraw().
class_name PrestigeBuffConnectionOverlay
extends Control
## Pairs of [parent_tile, child_tile] to connect.
var _connections: Array = []
func _ready() -> void:
mouse_filter = Control.MOUSE_FILTER_IGNORE
## Replace all connections and redraw.
func set_connections(connections: Array) -> void:
_connections = connections
queue_redraw()
func _draw() -> void:
if _connections.is_empty():
return
for pair in _connections:
var parent_tile: Control = pair[0] as Control
var child_tile: Control = pair[1] as Control
if parent_tile == null or child_tile == null:
continue
var from_pos: Vector2 = _tile_bottom_center(parent_tile)
var to_pos: Vector2 = _tile_top_center(child_tile)
draw_line(from_pos, to_pos, Color(0.6, 0.6, 0.7, 0.6), 2.0)
func _tile_bottom_center(tile: Control) -> Vector2:
var rect: Rect2 = tile.get_global_rect()
var global_pos: Vector2 = Vector2(rect.position.x + rect.size.x * 0.5, rect.position.y + rect.size.y)
return get_global_transform().affine_inverse() * global_pos
func _tile_top_center(tile: Control) -> Vector2:
var rect: Rect2 = tile.get_global_rect()
var global_pos: Vector2 = Vector2(rect.position.x + rect.size.x * 0.5, rect.position.y)
return get_global_transform().affine_inverse() * global_pos