updating state chart addon
Some checks failed
Create tag and build when new code gets to main / BumpTag (push) Successful in 21s
Create tag and build when new code gets to main / Export (push) Failing after 1m28s

This commit is contained in:
2026-01-27 19:13:53 +01:00
parent 37165d1562
commit b198aba09b
15 changed files with 534 additions and 1 deletions

View File

@@ -11,7 +11,7 @@ namespace GodotStateCharts
/// <summary>
/// The wrapped node.
/// </summary>
protected readonly Node Wrapped;
public readonly Node Wrapped;
protected NodeWrapper(Node wrapped)
{

View File

@@ -0,0 +1,39 @@
// ReSharper disable once CheckNamespace
namespace GodotStateCharts
{
using Godot;
/// <summary>
/// Base class for all wrapper classes for Godot Resource types. Provides common functionality. Not to be used directly.
/// </summary>
public abstract class ResourceWrapper
{
/// <summary>
/// The wrapped resource. Useful for you need to access the underlying resource directly,
/// e.g. for serialization.
/// </summary>
public readonly Resource Wrapped;
protected ResourceWrapper(Resource wrapped)
{
Wrapped = wrapped;
}
/// <summary>
/// Allows to call methods on the wrapped resource deferred.
/// </summary>
public Variant CallDeferred(string method, params Variant[] args)
{
return Wrapped.CallDeferred(method, args);
}
/// <summary>
/// Allows to call methods on the wrapped resource.
/// </summary>
public Variant Call(string method, params Variant[] args)
{
return Wrapped.Call(method, args);
}
}
}

View File

@@ -0,0 +1 @@
uid://j8ro24kpswjd

View File

@@ -0,0 +1,89 @@
// ReSharper disable once CheckNamespace
namespace GodotStateCharts
{
using System;
using Godot;
/// <summary>
/// C# wrapper for the SerializedStateChart Godot resource.
/// </summary>
public class SerializedStateChart : ResourceWrapper
{
private SerializedStateChart(Resource wrapped) : base(wrapped) { }
public static SerializedStateChart Of(Resource resource)
{
if (resource.GetScript().As<Script>() is not GDScript gdScript
|| !gdScript.ResourcePath.EndsWith("serialized_state_chart.gd"))
{
throw new ArgumentException("Given resource is not a SerializedStateChart.");
}
return new SerializedStateChart(resource);
}
public int Version
{
get => Wrapped.Get("version").AsInt32();
set => Wrapped.Set("version", value);
}
public string Name
{
get => Wrapped.Get("name").AsString();
set => Wrapped.Set("name", value);
}
public Godot.Collections.Dictionary ExpressionProperties
{
get => Wrapped.Get("expression_properties").AsGodotDictionary();
set => Wrapped.Set("expression_properties", value);
}
public Godot.Collections.Array QueuedEvents
{
get => Wrapped.Get("queued_events").AsGodotArray();
set => Wrapped.Set("queued_events", value);
}
public bool PropertyChangePending
{
get => Wrapped.Get("property_change_pending").AsBool();
set => Wrapped.Set("property_change_pending", value);
}
public bool StateChangePending
{
get => Wrapped.Get("state_change_pending").AsBool();
set => Wrapped.Set("state_change_pending", value);
}
public bool LockedDown
{
get => Wrapped.Get("locked_down").AsBool();
set => Wrapped.Set("locked_down", value);
}
public Godot.Collections.Array QueuedTransitions
{
get => Wrapped.Get("queued_transitions").AsGodotArray();
set => Wrapped.Set("queued_transitions", value);
}
public bool TransitionsProcessingActive
{
get => Wrapped.Get("transitions_processing_active").AsBool();
set => Wrapped.Set("transitions_processing_active", value);
}
public SerializedStateChartState State
{
get
{
var stateRes = Wrapped.Get("state").As<Resource>();
return stateRes != null ? SerializedStateChartState.Of(stateRes) : null;
}
set => Wrapped.Set("state", value?.Wrapped);
}
}
}

View File

@@ -0,0 +1 @@
uid://vsn1msuytiho

View File

@@ -0,0 +1,89 @@
using System;
using System.Collections.Generic;
using Godot;
namespace GodotStateCharts
{
/// <summary>
/// C# wrapper for the SerializedStateChartState Godot resource.
/// </summary>
public class SerializedStateChartState : ResourceWrapper
{
private SerializedStateChartState(Resource wrapped) : base(wrapped)
{
}
public static SerializedStateChartState Of(Resource resource)
{
if (resource.GetScript().As<Script>() is not GDScript gdScript
|| !gdScript.ResourcePath.EndsWith("serialized_state_chart_state.gd"))
{
throw new ArgumentException("Given resource is not a SerializedStateChartState.");
}
return new SerializedStateChartState(resource);
}
public string Name
{
get => Wrapped.Get("name").AsString();
set => Wrapped.Set("name", value);
}
public int StateType
{
get => Wrapped.Get("state_type").AsInt32();
set => Wrapped.Set("state_type", value);
}
public bool Active
{
get => Wrapped.Get("active").AsBool();
set => Wrapped.Set("active", value);
}
public string PendingTransitionName
{
get => Wrapped.Get("pending_transition_name").AsString();
set => Wrapped.Set("pending_transition_name", value);
}
public float PendingTransitionRemainingDelay
{
get => Wrapped.Get("pending_transition_remaining_delay").AsSingle();
set => Wrapped.Set("pending_transition_remaining_delay", value);
}
public float PendingTransitionInitialDelay
{
get => Wrapped.Get("pending_transition_initial_delay").AsSingle();
set => Wrapped.Set("pending_transition_initial_delay", value);
}
public List<SerializedStateChartState> Children
{
get
{
var wrappedChildren = Wrapped.Get("children").AsGodotArray();
var result = new List<SerializedStateChartState>();
// ReSharper disable once LoopCanBeConvertedToQuery
foreach (var item in wrappedChildren)
{
result.Add(Of(item.As<Resource>()));
}
return result;
}
set
{
var wrappedChildren = new Godot.Collections.Array();
foreach (var child in value)
{
wrappedChildren.Add(child.Wrapped);
}
Wrapped.Set("children", wrappedChildren);
}
}
}
}

View File

@@ -0,0 +1 @@
uid://bxbsjxky868w0

View File

@@ -0,0 +1,32 @@
namespace GodotStateCharts;
using Godot;
public class StateChartSerializer
{
private static readonly GodotObject Wrapped = GD.Load("res://addons/godot_state_charts/state_chart_serializer.gd");
/// <summary>
/// Serializes the given state chart and returns a serialized object that
/// can be stored as part of a saved game.
/// </summary>
/// <param name="stateChart">the state chart to serialize</param>
/// <returns>a resource containing the serialized state</returns>
public static SerializedStateChart Serialize(StateChart stateChart)
{
return SerializedStateChart.Of(Wrapped.Call("serialize", stateChart.Wrapped).As<Resource>());
}
/// <summary>
/// Deserializes the given serialized state chart into the given state chart. Returns a set of
/// error messages. If the serialized state chart was no longer compatible with the current state
/// chart, nothing will happen. The operation is successful when the returned array is empty.
/// </summary>
public static string[] Deserialize(SerializedStateChart serializedStateChart, StateChart stateChart)
{
var variant = Wrapped.Call("deserialize", serializedStateChart.Wrapped, stateChart.Wrapped);
return variant.AsStringArray();
}
}

View File

@@ -0,0 +1 @@
uid://cfttxxidmbax6