I hope I can articulate, what I want to achieve. I tried to find an answer by myself, but I just coulnd't find anything, maybe I googled the wrong questions? I already asked on Discord, but there was a lot going on and I think this is a better place. It's my first game, everything is coupled which is bad, I just wanted to get my hands dirty. But I'm struggling with a basic concept: signals
So I'm making an Earthbound-like RPG. You wander around in an Overworld and if you come close to an enemy, you enter a turn-based battle with said enemy. Let's say, my Level has mutliple Rats (the enemy), which I placed there, so they are not instanced at runtime. Every Rat has a scene as a child: BattleStart. That scene is an Area2D and on entering, a little animation plays and when the animation is finished, the BattleStart scene emits a custom signal.
My problem: In my Main-script, I need to connect the signal, but in order to connect to the BattleStart scene of every Rat, i need to know their path. But what if there are multiple rats, then also skeletons and so on? Do I need to connect to every single one of them, since they all have a different name?
$World/Environment/Rat/BattleStart.connect("enter_battle", self, "_on_transition_animation_ended")
$World/Environment/Rat2/BattleStart.connect("enter_battle", self, "_on_transition_animation_ended")
$World/Environment/Skeleton/BattleStart.connect("enter_battle", self, "_on_transition_animation_ended")
$World/Environment/Skeleton2/BattleStart.connect("enter_battle", self, "_on_transition_animation_ended")
Do I need to do that for tens or hundreds of enemies? I always want to connect to that one BattleStart scene, which is part of every enemy. Or shouldn't I do that? If my approach is completely wrong, please tell me how to do it. I think this is actually a very common case, isn't it? Because you often have multiple instances of scenes and all of them should send a signal to one parent somewhere up above. What do I miss? Please explain to me elaborately, I'm a beginner.
Thanks a lot in advance