LokiCat.Godot.R3.ObservableSignals 1.0.37

There is a newer version of this package available.
See the version list below for details.
dotnet add package LokiCat.Godot.R3.ObservableSignals --version 1.0.37
                    
NuGet\Install-Package LokiCat.Godot.R3.ObservableSignals -Version 1.0.37
                    
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.Godot.R3.ObservableSignals" Version="1.0.37" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LokiCat.Godot.R3.ObservableSignals" Version="1.0.37" />
                    
Directory.Packages.props
<PackageReference Include="LokiCat.Godot.R3.ObservableSignals" />
                    
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.Godot.R3.ObservableSignals --version 1.0.37
                    
#r "nuget: LokiCat.Godot.R3.ObservableSignals, 1.0.37"
                    
#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.Godot.R3.ObservableSignals@1.0.37
                    
#: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.Godot.R3.ObservableSignals&version=1.0.37
                    
Install as a Cake Addin
#tool nuget:?package=LokiCat.Godot.R3.ObservableSignals&version=1.0.37
                    
Install as a Cake Tool

LokiCat.Godot.R3.ObservableSignals

A source generator that turns [Signal]-annotated delegates into fully reactive R3 Observable<T> properties.
Supports zero to five signal arguments, automatic EmitSignal(...) wiring, and full Godot editor compatibility.


✨ What It Does

This generator lets you define a signal once using Godot's [Signal] attribute:

[Signal]
public delegate void JumpEventHandler();

💥 And automatically provides:

  • ✅ A backing Subject<T> (_onJump)
  • ✅ A public observable property (OnJump)
  • ✅ A lazy .Subscribe(...) that calls EmitSignal(...) with proper arguments

No need to write Connect(), EmitSignal(), or observable plumbing by hand.


🚀 Quick Start

✅ Define your signal:

[Signal]
public delegate void DamageTakenEventHandler(int amount);

✅ Emit it in your code:

_onDamageTaken.OnNext(42);

✅ Observe it reactively:

OnDamageTaken.Subscribe(amount => GD.Print($"Took {amount} damage!"));

✅ The Godot editor will show a DamageTaken signal.
✅ R3 observers will get updates when the signal fires.


🧠 How It Works

For this:

[Signal]
public delegate void HitEventHandler(Vector3 point, Node target);

The generator emits:

private readonly Subject<(Vector3, Node)> _onHit = new();
private bool _hitConnected;

public Observable<(Vector3, Node)> OnHit {
  get {
    if (!_hitConnected) {
      _hitConnected = true;
      _onHit.Subscribe(value =>
        EmitSignal(nameof(Hit), value.Item1, value.Item2)
      ).AddTo(this);
    }
    return _onHit;
  }
}

✅ One subject powers both EmitSignal(...) and the reactive pipeline.


📦 Installation

dotnet add package LokiCat.Godot.R3.ObservableSignals

Make sure your consumer project defines:

public readonly struct Unit {} // in namespace R3

(Only needed for 0-arg signals.)


✅ Supported Signal Signatures

Delegate Type Observable Type Emission
delegate void JumpEventHandler() Observable<Unit> EmitSignal("Jump")
delegate void DamageEventHandler(int dmg) Observable<int> EmitSignal("Damage", dmg)
delegate void HitEventHandler(Vector3, Node) Observable<(Vector3, Node)> EmitSignal("Hit", ...)

Up to 5 arguments supported. More than 5 triggers a warning.


🚨 Generator Warnings

ID Reason
SIGOBS001 Signal delegate has more than 5 parameters
SIGOBS002 Missing R3.Unit type for 0-arg signals
SIGOBS003 EmitSignal("X") is called manually, but will not emit to OnX

⚡ Best Practices

  • Declare signals once with [Signal]
  • Emit signals using _onX.OnNext(...) — not EmitSignal(...)
  • Observe using OnX.Subscribe(...)
  • Use .Where, .Throttle, .TakeUntil(...) for filtered pipelines
  • Expose Observable<T>s in interfaces to keep logic clean

💡 Advanced

If you manually call EmitSignal(...), observers on OnX will not receive anything.
Only _onX.OnNext(...) propagates to both EmitSignal(...) and the observable.


📜 License

MIT License

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.70 238 7/2/2025
1.0.69 119 6/21/2025
1.0.68 106 6/21/2025
1.0.65 142 6/19/2025
1.0.64 141 6/19/2025
1.0.63 140 6/19/2025
1.0.62 138 6/19/2025
1.0.61 141 6/19/2025
1.0.60 142 6/19/2025
1.0.59 140 6/19/2025
1.0.58 143 6/19/2025
1.0.57 140 6/19/2025
1.0.56 145 6/19/2025
1.0.55 140 6/19/2025
1.0.54 140 6/18/2025
1.0.53 141 6/18/2025
1.0.52 138 6/18/2025
1.0.51 146 6/18/2025
1.0.47 154 6/14/2025
1.0.40 155 6/14/2025
1.0.38 164 6/14/2025
1.0.37 139 5/9/2025
1.0.36 82 5/9/2025
1.0.35 82 5/9/2025
1.0.34 83 5/9/2025
1.0.33 147 5/8/2025
1.0.32 147 5/8/2025
1.0.31 147 5/1/2025
1.0.30 153 5/1/2025
1.0.29 152 5/1/2025
1.0.28 151 4/30/2025
1.0.26 148 4/30/2025
1.0.25 147 4/30/2025
1.0.24 145 4/30/2025
1.0.23 153 4/30/2025
1.0.22 151 4/30/2025
1.0.21 143 4/30/2025
1.0.20 147 4/30/2025
1.0.19 143 4/29/2025
1.0.18 160 4/29/2025
1.0.17 157 4/28/2025
1.0.16 160 4/27/2025
1.0.15 167 4/27/2025
1.0.14 160 4/27/2025
1.0.13 158 4/27/2025
1.0.12 156 4/27/2025
1.0.11 153 4/27/2025
1.0.9 161 4/27/2025
1.0.7 162 4/27/2025
1.0.1 153 4/27/2025
1.0.0 160 4/27/2025
0.0.6 248 4/19/2025
0.0.5 171 4/19/2025