You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One useful feature GDScript has is the ability to suspend execution of the current function and wait for a signal to be emitted before resuming.
Kotlin has an awesome coroutine, and it should be possible to recreate a similar behaviour. Godot uses signals intensively. Not being able to wait for them create many cases where a speudocode that could look like this:
I suggest to create a coroutine context for Godot kotlin that would extend the signal class by adding an await method.
I don't recommend supporting the registration of suspend functions directly as they do not work the same way as regular functions and would require an important rework of the library's internals + the entry generator.
Instead the usage would look like this:
When using signal1.await() it would call the C++ code to create a new Object called GodotContinuation that will connect to the signal. When the signal is emitted, GodotContinuation would then callback the JVM to resume the coroutine execution. The more complex implementations details are to be investigated, as I am not familiar with the lower level layer of Kotlin coroutines right now.
The text was updated successfully, but these errors were encountered:
One useful feature GDScript has is the ability to suspend execution of the current function and wait for a signal to be emitted before resuming.
Kotlin has an awesome coroutine, and it should be possible to recreate a similar behaviour. Godot uses signals intensively. Not being able to wait for them create many cases where a speudocode that could look like this:
ends up looking like this:
I suggest to create a coroutine context for Godot kotlin that would extend the signal class by adding an await method.
I don't recommend supporting the registration of suspend functions directly as they do not work the same way as regular functions and would require an important rework of the library's internals + the entry generator.
Instead the usage would look like this:
When using signal1.await() it would call the C++ code to create a new Object called GodotContinuation that will connect to the signal. When the signal is emitted, GodotContinuation would then callback the JVM to resume the coroutine execution. The more complex implementations details are to be investigated, as I am not familiar with the lower level layer of Kotlin coroutines right now.
The text was updated successfully, but these errors were encountered: