How to create a "signal proxy"?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By kelaia

I have this code:
enter image description here

I need to handle any signal from any node and send it to the “signal handler”. The signal handler needs to know all the parameters emitted along with the signal and other parameters (added using array binding).

In the signal handler I have the following (not working):
enter image description here

But I need something like this (to be able to handle multiple cases):
enter image description here

Any way to do this?

:bust_in_silhouette: Reply From: Inces

I only code in GSL, so my advice may not be applicable by Your case, but…

it looks like You want to achieve classic observer pattern there. At least with GSL it is more practical to only introduce all signals by name in signal handler node. With this approach emitter nodes don’t emit signal by themselves, but call emit() of signal handler, with all arguments they want to bind for this. Receiver nodes can than connect themelves to signals of their interests, always connecting to signal handler.

I need something like that, but I can’t create a function (in c#) for each signal. Any way to connect any signal (from any node) to a single defined function? I need to expose this functionality to users at runtime so I can’t manually create the bindings.

kelaia | 2021-11-17 17:57

I wish I could help but I have no idea about c# limitations.

You say You need a way to connect every various signal to one function. In GSL I would use one signal for every node but with varying bindings, or with one bound dictionary.

Maybe I could come up with some universal sollution if You said something about this project, what are those signals used for in game and how does user change it in runtime ?

Inces | 2021-11-17 18:13

I’m porting RPG Maker VX Ace to use godot as “runtime”. RM has many limitations, I can’t export to any OS other than Windows, it uses GDI as graphical API…

I’ve done a lot of things, most of the core is already running (sprites, bitmaps, audio, tilemap…). Now I’m trying to integrate Godot’s features and expose them to be used in rpg maker scripts.

I want to be able to create scenes using godot and use them within the game. The hard part is that I can’t directly wire the node’s signals to a ruby callback, nor can I use a lambda to handle a signal (it would be much easier that way).

The most important thing is that I will be able to use the godot ui resources from the rpg maker scripts, this is essential. I can manually configure the signals in this case, but this will restrict users and they will not be able to create custom controls with custom signals.

I’m using C# because of the async features and because IronRuby matches the exact version used in the rpg maker (ruby 1.9, yeah…).

kelaia | 2021-11-17 21:43