LokiCat.GodotNodeInterfaces.Observables 1.0.15

There is a newer version of this package available.
See the version list below for details.
dotnet add package LokiCat.GodotNodeInterfaces.Observables --version 1.0.15
                    
NuGet\Install-Package LokiCat.GodotNodeInterfaces.Observables -Version 1.0.15
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LokiCat.GodotNodeInterfaces.Observables" Version="1.0.15" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LokiCat.GodotNodeInterfaces.Observables" Version="1.0.15" />
                    
Directory.Packages.props
<PackageReference Include="LokiCat.GodotNodeInterfaces.Observables" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LokiCat.GodotNodeInterfaces.Observables --version 1.0.15
                    
#r "nuget: LokiCat.GodotNodeInterfaces.Observables, 1.0.15"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LokiCat.GodotNodeInterfaces.Observables@1.0.15
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LokiCat.GodotNodeInterfaces.Observables&version=1.0.15
                    
Install as a Cake Addin
#tool nuget:?package=LokiCat.GodotNodeInterfaces.Observables&version=1.0.15
                    
Install as a Cake Tool

LokiCat.GodotNodeInterfaces.Observables

Generate R3 Observables from Chickensoft.GodotNodeInterfaces signals

NuGet CI


Overview

This project provides a Roslyn source generator that automatically creates R3 observable extensions for each signal exposed by the Chickensoft.GodotNodeInterfaces interfaces.

You get strongly typed, composable observables that make it easy to work with Godot signals in a reactive way using R3.


โœจ Features

  • ๐Ÿ”ง Zero config: Just install the package and observe away.
  • โšก Automatic discovery of all signals defined in Chickensoft.GodotNodeInterfaces.
  • ๐Ÿงช Fully tested generator logic.
  • ๐Ÿงต Handles custom delegate signal types (like ButtonPressedEventHandler).
  • ๐Ÿ“ฆ Designed for .NET 7+, compatible with Godot 4.x C# projects.

๐Ÿ“ฆ Installation

Install via NuGet:

dotnet add package LokiCat.GodotNodeInterfaces.Observables

๐Ÿ”Œ Usage

No setup is required. Once the package is installed, the source generator will run during build and add extension methods for each interface's signals.

You can observe any Godot signal (from the Chickensoft interfaces) like so:

public partial class MyNode : Node2D {
  public override void _Ready() {
    this.OnPressedAsObservable()
      .Subscribe(_ => GD.Print("Pressed!"));
  }
}

The method name pattern is:

On[SignalName]AsObservable()

These methods are automatically added to the interface types like IButton, IArea2D, etc.

Each observable uses the signal's native delegate (including custom Godot signal delegate types), and returns Observable<T> where T is:

  • The signal parameter type (if 1 parameter)
  • A tuple (T1, T2, ...) (if multiple parameters)
  • Unit (if no parameters)

๐Ÿงช Examples

Observing Pressed from IButton

button.OnPressedAsObservable()
  .Subscribe(_ => GD.Print("Button was pressed"));

Observing MouseEntered from IArea2D

area.OnMouseEnteredAsObservable()
  .Subscribe(_ => ShowTooltip());

Observing complex signal with parameters

For a signal like:

event InputEventEventHandler(Godot.Node viewport, Godot.InputEvent @event, long shapeIdx);

Generated observable extension:

collision.OnInputEventAsObservable()
  .Subscribe(tuple => {
    var (viewport, evt, shapeIdx) = tuple;
    GD.Print($"Input received on shape {shapeIdx}");
  });

Composing observables with R3

button.OnPressedAsObservable()
  .ThrottleFirst(TimeSpan.FromMilliseconds(500))
  .Subscribe(_ => GD.Print("Throttled click!"));

โš™๏ธ Dependencies


๐Ÿงฑ How It Works

  • Uses Roslyn source generation to discover every event declared in Chickensoft.GodotNodeInterfaces interfaces.
  • Ignores inherited events (to avoid duplicate generation).
  • Generates extension methods per event with exact types.
  • Handles custom Godot signal delegates with correct constructor/parameter logic.

All source is generated at compile time and added to your build transparently.


๐Ÿงช Tests

Tests cover:

  • Events with 0, 1, or many parameters
  • Delegates with and without constructors
  • Namespace resolution
  • Method name and return type formatting

You can run tests locally:

dotnet test

๐Ÿ›  Development

To build from source:

dotnet build -c Release

To pack for NuGet:

dotnet pack -c Release

๐Ÿ™ Credits


๐Ÿ“„ License

MIT

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • net7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.23 149 5/10/2025
1.0.22 392 4/19/2025
1.0.21 186 4/19/2025
1.0.20 170 4/19/2025
1.0.19 112 4/19/2025
1.0.18 115 4/19/2025
1.0.17 209 4/15/2025
1.0.16 214 4/15/2025
1.0.15 219 4/13/2025
1.0.14 201 4/13/2025
1.0.13 198 4/13/2025