@icon("res://components/Cursor/mouse-pointer-2.svg") extends Base @onready var mouse_control = $"MouseControl" @onready var sprite_2d: Sprite2D = $MouseControl/Sprite2D const CURSOR_UI = preload("res://components/Cursor/cursor-ui.png") const CURSOR = preload("res://components/Cursor/cursor.png") var cursor_state = "normal" var rotation_tween func _ready() -> void: Persister.data_persisted.connect(_on_data_persisted) Triggerer.listen("fire", _on_fire) func _on_fire(_data): if cursor_state == "ui": return sprite_2d.scale = Vector2.ONE * 1.25 * 0.156 func _on_click(): var overlapping_areas = mouse_control.get_overlapping_areas() overlapping_areas.sort_custom(func(a, b): return a.z_index > b.z_index ) for area in overlapping_areas: if area.has_method("_on_clicked"): var current_node = area var hidden = false while current_node: if "modulate" in current_node: if current_node.modulate.a < 1: hidden = true break current_node = current_node.get_parent() if hidden: continue if not area._on_clicked(): break func _on_rclick(): var overlapping_areas = mouse_control.get_overlapping_areas() overlapping_areas.sort_custom(func(a, b): return a.z_index > b.z_index ) for area in overlapping_areas: if area.has_method("_on_rclicked"): var current_node = area var hidden = false while current_node: if "modulate" in current_node: if current_node.modulate.a < 1: hidden = true break current_node = current_node.get_parent() if hidden: continue if not area._on_rclicked(): break func _process(delta): if Input.is_action_just_pressed("lclick"): _on_click() if Input.is_action_just_pressed("rclick"): _on_rclick() Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN) mouse_control.position = mouse_control.get_global_mouse_position() func _on_mouse_control_area_entered(area): if area.has_method("_on_hovered"): area._on_hovered() func _on_mouse_control_area_exited(area): if area.has_method("_on_unhovered"): area._on_unhovered()