godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.07k stars 69 forks source link

Add 'is_connected()' function without parameters to check if signal is connected #8912

Open ShlomiRex opened 5 months ago

ShlomiRex commented 5 months ago

Describe the project you are working on

2D MMORPG

Describe the problem or limitation you are having in your project

When creating signals, it is difficult to follow all of the possible combinations of signals I used in my game.

So I want to force check that my signal is connected first, and if not, the game crashes.

Is there a way to force signals to be connected beforehand? I think its a good idea. For example, if you have a system with more than 100+ signals, how can you follow each one? What happens when a single connection is broken? How would you trouble shoot it?

I think we should also add 'final' keyword or something to signals in GDScript, so that the game engine checks that all the connections are fine.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Its quality of life feature, not really neccesery

You could check with

get_connections().size() > 0

But we should instead have more inline function:

is_connection()

It can also be indicated with

has_connection()

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Simple check in the core of the engine

If this enhancement will not be used often, can it be worked around with a few lines of script?

Yes

Is there a reason why this should be core and not an add-on in the asset library?

As I said before its core of signals

AThousandShips commented 5 months ago

Working on an implementation of this and will open a PR if I manage something good