KlownHero There are a couple of ways to deal with this.
Option 1: Use the class names in your match.
match detected.get_class():
"Sign": handle_sign(detected)
"Rock": handle_rock(detected)
Depending on the complexity you could simulate an interface.
Option 2: Give those objects a base class like for example Interactable that has a function interact() that the sub classes can overwrite.
var detected = interact_ray.get_collider()
if detected is Interactable:
detected.interact()
Option 3: Add a common function like for example handle_interaction() to those classes.
var detected = interact_ray.get_collider()
if "handle_interaction" in detected:
detected.handle_interaction()
But of course both options mean that you need to add whatever logic is necessary to handle with an interaction to all those classes. If you want to keep all that in one place then this won't work.
Option 4: Make a dictionary that holds Callables and use the class names as keys. Then do something like:
if detected.get_class() in dict:
dict[detected.get_class()].call(detected)
That way you can keep all the logic together in your current script.