Chickensoft.PowerUps
1.0.0
AutoInject 2 now contains all of the mixins provided by PowerUps.
See the version list below for details.
dotnet add package Chickensoft.PowerUps --version 1.0.0
NuGet\Install-Package Chickensoft.PowerUps -Version 1.0.0
<PackageReference Include="Chickensoft.PowerUps" Version="1.0.0" />
paket add Chickensoft.PowerUps --version 1.0.0
#r "nuget: Chickensoft.PowerUps, 1.0.0"
// Install Chickensoft.PowerUps as a Cake Addin #addin nuget:?package=Chickensoft.PowerUps&version=1.0.0 // Install Chickensoft.PowerUps as a Cake Tool #tool nuget:?package=Chickensoft.PowerUps&version=1.0.0
🔋 PowerUps
A collection of power-ups for your C# Godot game scripts that work with the SuperNodes source generator.
<p align="center"> <img alt="Chickensoft.PowerUps" src="Chickensoft.PowerUps/icon.png" width="200"> </p>
Currently, two PowerUps are provided by this package: AutoNode
and AutoDispose
.
- 🌲 AutoNode: automatically connect fields and properties to their corresponding nodes in the scene tree.
- 🚮 AutoDispose: automatically dispose of disposable properties owned by your script when it exits the scene tree.
Chickensoft also maintains a third PowerUp for dependency injection called
AutoInject
that resides in its own AutoInject repository.
📦 Installation
Unlike most nuget packages, PowerUps are provided as source-only nuget packages that actually inject the source code for the PowerUp into your project.
Injecting the code directly into the project referencing the PowerUp allows the SuperNodes source generator to see the code and generate the glue needed to make everything work without reflection.
To use the PowerUps, add the following to your .csproj
file. Be sure to get the latest versions for each package on Nuget.
<ItemGroup>
<PackageReference Include="Chickensoft.SuperNodes" Version="1.5.0" PrivateAssets="all" OutputItemType="analyzer" />
<PackageReference Include="Chickensoft.SuperNodes.Types" Version="1.5.0" />
<PackageReference Include="Chickensoft.PowerUps" Version="1.0.0" PrivateAssets="all" />
</ItemGroup>
🌲 AutoNode
The AutoNode
PowerUp automatically connects fields and properties in your script to a declared node path or unique node name in the scene tree whenever the scene is instantiated.
Simply apply the [Node]
attribute to any field or property in your script that you want to automatically connect to a node in your scene.
If you don't specify a node path, the name of the field or property will be converted to a unique node identifier name in PascalCase. For best results, consider using PascalCase for node names in the scene tree.
using Chickensoft.PowerUps;
using Godot;
using SuperNodes.Types;
[SuperNode(typeof(AutoNode))]
public partial class MyNode : Node2D {
public override partial void _Notification(int what);
// Automatically connect this field to the provided node path
[Node("Path/To/MyNode")]
private Node2D _myNode = default!;
// If you don't specify a node path, AutoNode converts the name of the
// field to a unique node path specifier in PascalCase: %MyUniqueNode
[Node]
private Node2D _myUniqueNode = default!;
// Just specify the unique name if it differs in more than just casing from
// the field/property name.
[Node("%OtherUniqueName")]
private Node2D _differentName = default!;
}
🚮 AutoDispose
The AutoDispose
PowerUp will automatically dispose of writeable properties on your script that implement IDisposable
but do not inherit Godot.Node
when the node exits the scene tree, preventing the need for manually cleaning up disposable, non-node objects that your script owns.
AutoDispose was designed to work nicely with the dependency injection system from AutoInject and disposable objects, like the bindings from LogicBlocks.
using Chickensoft.AutoInject;
using Chickensoft.PowerUps;
using Godot;
using SuperNodes.Types;
// Note that Dependent is a PowerUp provided by AutoInject.
[SuperNode(typeof(Dependent), typeof(AutoDispose))]
public partial class MyNode : Node2D {
public override partial void _Notification(int what);
// Use AutoInject to lookup the nearest SomeDisposable object provided above
// us in the scene tree.
//
// Since this is a read-only property, it will not have Dispose called on it
// by AutoDispose when we exit the scene tree. This is desirable since this
// script doesn't own this object — it just needs to use it.
[Dependency]
public SomeDisposable DisposableDependency => DependOn<SomeDisposable>();
// This object will automatically have Dispose called on it by AutoDispose
// when we exit the scene tree since it is a writeable property (which tells
// AutoDispose this script owns it and should dispose of it).
public MyDisposable MyDisposableObject { get; set; } = default!;
// Even though Godot nodes are disposable, this won't be disposed since it
// inherits from Godot.Node. Godot manages node references automatically.
public Node2D OtherNode { get; set; } = default!;
// ...
🐣 Package generated from a 🐤 Chickensoft Template — https://chickensoft.games
Learn more about Target Frameworks and .NET Standard.
This package has 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 | |
---|---|---|---|
4.0.0 | 157 | 6/8/2024 | |
3.0.1-godot4.2.0-beta.5 | 1,793 | 11/8/2023 | |
3.0.0-godot4.2.0-beta.5 | 84 | 11/8/2023 | |
3.0.0-godot4.2.0-beta.1 | 74 | 11/8/2023 | |
2.1.0-godot4.2.0-beta.1 | 111 | 10/21/2023 | |
2.0.0-godot4.2.0-dev.6 | 84 | 10/18/2023 | |
1.0.0 | 501 | 8/27/2023 |
Chickensoft.PowerUps release.