GodotUtils.InstanceResolver
1.0.3
dotnet add package GodotUtils.InstanceResolver --version 1.0.3
NuGet\Install-Package GodotUtils.InstanceResolver -Version 1.0.3
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="GodotUtils.InstanceResolver" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GodotUtils.InstanceResolver --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: GodotUtils.InstanceResolver, 1.0.3"
#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.
// Install GodotUtils.InstanceResolver as a Cake Addin
#addin nuget:?package=GodotUtils.InstanceResolver&version=1.0.3
// Install GodotUtils.InstanceResolver as a Cake Tool
#tool nuget:?package=GodotUtils.InstanceResolver&version=1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Godot Utilities
Instance Resolver
Package for Godot C#. Provides a convenience and reliable way to pass parameters for Instantiate<Node>()
from PackScene
Main Usage
using Godot;
using GodotUtils.InstanceResolver
namespace YourGame.Components;
public partial class Bullet : RigidBody2D, IParamsResolvedNode
{
[Parameter]
private int _damage;
[Parameter]
private int _speed = 100;
[Parameter]
private Texture _texture;
// game logic...
}
Above code will generate a partial class below
namespace YourGame.Components;
partial class Bullet : GodotUtils.InstanceResolver.IResolvedNode<Bullet, Bullet.BuildParameters>
{
public class BuildParameters : GodotUtils.InstanceResolver.Internal.IParameters<Bullet>
{
public required int Damage { get; init; }
private readonly GodotUtils.InstanceResolver.Internal.Models.OptionalValue<int> _speedWrapper = new();
public bool IsSpeedInitialized() => _speedWrapper.IsInitialized;
public int Speed
{
get => _speedWrapper.Value;
init
{
_speedWrapper.Set(value);
}
}
public required global::Godot.Texture Texture { get; init; }
}
public BuildParameters Map(BuildParameters parameters)
{
_damage = parameters.Damage;
if (parameters.IsSpeedInitialized())
{
_speed = parameters.Speed;
}
_texture = parameters.Texture;
}
}
And then you use this code to Instantiate node
readonly PackScene BULLET_INSTANCE = ResourceLoader.Load("<<uid_or_path_of_node_scene>>");
var bullet = BULLET_INSTANCE.Init<Bullet>(node => node.Map(new() { Damage = 10, Texture = texture }));
With Node Scene with out a Parameter, you can implement INoResolvedParams
and use directly INSTANCE.Init<NoParamNode>()
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- GodotSharp (>= 4.2.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.