GodotRx
GodotRx is a set of reactive extensions for Godot C# (Mono), providing observables for signals, lifecycle events, input events, and frame events. It also includes awaitable tasks, time scale-based schedulers, and reactive properties to enhance reactive programming in Godot.
https://github.com/semickolon/GodotRxGodotRx: Reactive Extensions for Godot C#
GodotRx is a powerful library designed to bring reactive programming paradigms to Godot Engine using C#. It offers a suite of reactive extensions that transform Godot's signals and events into observables, making it easier to manage asynchronous and event-driven logic.
Key Features
- Signals as Observables: Convert Godot signals into observables with full type information, enabling a more streamlined and type-safe approach to event handling.
-
Lifecycle Events: Expose node lifecycle methods such as
_Process
and_Input
as observables, allowing you to react to these events in a reactive manner. - Input Events: Provide observables for common input events, simplifying input handling and making it more reactive.
- Frame Events: Expose frame events like idle, physics, pre-draw, and post-draw as observables and awaitable tasks.
- Time-Based Operations: Includes time scale-based schedulers and delay functionalities.
- Reactive Properties: Offers reactive properties for easier change notifications and data binding, including computed properties and properties derived from existing members.
Usage and Installation
GodotRx requires C# 8.0 or higher and is designed for Godot 3.x. Due to the lack of plugin support for C# in Godot 3.x, installation involves copying the addons/godotrx
folder into your project. The library provides extension methods and reactive property implementations to facilitate reactive programming in Godot.
How It Works
GodotRx leverages code generation to map GDScript signals to C# extension methods with type information. It uses a combination of GDScript and C# to intercept object freeing for automatic housekeeping of subscriptions. For lifecycle events, it utilizes child nodes as proxies to intercept method calls indirectly.