Added VariableGetter functionality and some Variable setting components. Also added them to test scene.

This commit is contained in:
2025-10-28 13:09:36 +01:00
parent 8c1157c26e
commit 3fe79f2fd8
11 changed files with 125 additions and 1 deletions
@@ -0,0 +1,30 @@
using Godot;
namespace Babushka.scripts.CSharp.Low_Code.Variables;
/// <summary>
/// An active getter component for calling the payload value of a <see cref="VariableResource"/>.
/// </summary>
public partial class VariableGetter : Node
{
/// <summary>
/// The event resource to listen to.
/// </summary>
[Export] private VariableResource _variableResource;
/// <summary>
/// A signal that is triggered when the payload of one of the <see cref="VariableResource"/> is called.
/// </summary>
[Signal] public delegate void GetPayloadEventHandler(Variant payload);
/// <summary>
/// Gets the Variant payload of a VariableResource on demand.
/// </summary>
/// <returns></returns>
public Variant Get()
{
Variant payload = _variableResource.Payload;
EmitSignal(SignalName.GetPayload, payload);
return payload;
}
}
@@ -0,0 +1 @@
uid://34okoih6wkmu
@@ -3,6 +3,9 @@ using Godot.Collections;
namespace Babushka.scripts.CSharp.Low_Code.Variables;
/// <summary>
/// A passive Node that listens to valuechange-events on a <see cref="VariableResource"/>.
/// </summary>
public partial class VariableListener : Node
{
/// <summary>
@@ -3,6 +3,9 @@ using Godot;
namespace Babushka.scripts.CSharp.Low_Code.Variables;
/// <summary>
/// A <see cref="Variant"/> value wrapper resource used to store state values and notify ingame scripts.
/// </summary>
[GlobalClass]
public partial class VariableResource : Resource
{
@@ -11,6 +14,10 @@ public partial class VariableResource : Resource
/// </summary>
[Export] private bool _showLog;
/// <summary>
/// Public property that manages the access to the payload.
/// Triggers the ValueChange-function when set to a new value.
/// </summary>
[Export]
public Variant Payload
{
@@ -0,0 +1,22 @@
using Godot;
namespace Babushka.scripts.CSharp.Low_Code.Variables.VariantValueChanger;
public partial class VariantIncrementor : Node
{
[Export] private VariableResource _resource;
public void Increment()
{
int integerValue = _resource.Payload.AsInt32();
integerValue++;
_resource.Payload = integerValue;
}
public void Decrement()
{
int integerValue = _resource.Payload.AsInt32();
integerValue--;
_resource.Payload = integerValue;
}
}
@@ -0,0 +1 @@
uid://d1y23ytkt1w2j
@@ -0,0 +1,16 @@
using Godot;
namespace Babushka.scripts.CSharp.Low_Code.Variables.VariantValueChanger;
public partial class VariantToString : Node
{
[Export] private VariableResource _resource;
[Signal] public delegate void PayloadAsStringEventHandler(string payloadAsString);
public void ConvertToString()
{
EmitSignal(SignalName.PayloadAsString, _resource.Payload.AsString());
}
}
@@ -0,0 +1 @@
uid://dco37q6ddm8kv