Best ways to handle and share information between nodes/scenes?

Godot Version

4.0

Introduction

Hello! I have a “mouse”-scene with variables (booleans): “clicked”, “released” and “held”, as well as a dictionary with selected Area2Ds as keys (with integers as values).

Question

How should I share this information in my code to the places that need said information?

Examples of interactions that I want to implement, that utilize “mouse”-information:

  • If I click and hold while the mouse is in a card’s Area2D, the card follows the mouse.

  • If I release a card, while in a hand’s Area2D, the card is given to the hand.

  • If I click a cell on a grid with no card selected, it should place a flag.


Should I just hard-code stuff like:

# Pseudo code:
if selected_card != null
	if held:
		selected_card.global_position = get_global_mouse_position()
	elif released:
		if selected_hand != null:
			selected_hand.add_to_hand(selected_card)
		else:
			selected_card.global_position = before_dragging_pos

elif cell != null:
	Grid.cell_clicked(cell),

…In a global script or in the “mouse”-script? Are there better, cleaner ways of doing this?

Thanks in advance! (Is this topic a bit too broad?)